Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Louis BECQUEY
/
RNANet
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Louis BECQUEY
2021-02-01 14:41:33 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6086e50896c60a0629555adee8b410757601365f
6086e508
1 parent
3afda63d
catching warnings from divisions by zero
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
RNAnet.py
statistics.py
RNAnet.py
View file @
6086e50
...
...
@@ -41,6 +41,8 @@ from Bio.Seq import MutableSeq
from
Bio.SeqRecord
import
SeqRecord
from
Bio.Align
import
MultipleSeqAlignment
runDir
=
os
.
getcwd
()
def
trace_unhandled_exceptions
(
func
):
@wraps
(
func
)
def
wrapped_func
(
*
args
,
**
kwargs
):
...
...
@@ -2626,7 +2628,6 @@ def work_save(c, homology=True):
if
__name__
==
"__main__"
:
runDir
=
os
.
getcwd
()
fileDir
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
ncores
=
read_cpu_number
()
pp
=
Pipeline
()
...
...
statistics.py
View file @
6086e50
...
...
@@ -944,7 +944,7 @@ def par_distance_matrix(filelist, f, label, consider_all_atoms, s):
coordinates_with_gaps
.
append
(
coordinates
[
i
-
nb_gap
])
# Build the pairwise distances
d
=
np
.
zeros
((
len
(
s
.
seq
),
len
(
s
.
seq
)),
dtype
=
np
.
float
16
)
d
=
np
.
zeros
((
len
(
s
.
seq
),
len
(
s
.
seq
)),
dtype
=
np
.
float
32
)
for
i
in
range
(
len
(
s
.
seq
)):
for
j
in
range
(
len
(
s
.
seq
)):
if
np
.
isnan
(
coordinates_with_gaps
[
i
])
.
any
()
or
np
.
isnan
(
coordinates_with_gaps
[
j
])
.
any
():
...
...
@@ -1024,10 +1024,16 @@ def get_avg_std_distance_matrix(f, consider_all_atoms, multithread=False):
p
.
join
()
exit
(
1
)
if
(
counts
>
1
)
.
all
():
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"error"
)
# Calculation of the average matrix
avg
=
avg
/
counts
try
:
avg
=
avg
/
counts
assert
(
counts
>
0
)
.
all
()
except
RuntimeWarning
as
e
:
# there will be division by 0 if count is 0 at some position = gap only column
pass
np
.
savetxt
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'_average.csv'
,
avg
,
delimiter
=
","
,
fmt
=
"
%.3
f"
)
fig
,
ax
=
plt
.
subplots
()
...
...
@@ -1040,7 +1046,12 @@ def get_avg_std_distance_matrix(f, consider_all_atoms, multithread=False):
plt
.
close
()
# Calculation of the standard deviation matrix by the Huygens theorem
std
=
np
.
sqrt
(
std
/
counts
-
np
.
power
(
avg
,
2
))
try
:
std
=
np
.
sqrt
(
std
/
counts
-
np
.
power
(
avg
/
counts
,
2
))
assert
(
counts
>
0
)
.
all
()
except
RuntimeWarning
as
e
:
# there will be division by 0 if count is 0 at some position = gap only column
pass
np
.
savetxt
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'_stdev.csv'
,
std
,
delimiter
=
","
,
fmt
=
"
%.3
f"
)
fig
,
ax
=
plt
.
subplots
()
...
...
Please
register
or
login
to post a comment