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-01-31 14:49:45 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
810f5fcfefc07ef7dbf9d7ce22779ba20beb25f4
810f5fcf
1 parent
a8cd46e8
prevent div by zero if no 3D structures in the folder
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
26 deletions
statistics.py
statistics.py
View file @
810f5fc
...
...
@@ -944,7 +944,6 @@ def par_distance_matrix(filelist, f, label, consider_all_atoms, s):
coordinates_with_gaps
.
append
(
coordinates
[
i
-
nb_gap
])
# Build the pairwise distances
print
(
"> Computing distances for"
,
s
.
id
)
d
=
np
.
zeros
((
len
(
s
.
seq
),
len
(
s
.
seq
)),
dtype
=
np
.
float16
)
for
i
in
range
(
len
(
s
.
seq
)):
for
j
in
range
(
len
(
s
.
seq
)):
...
...
@@ -953,7 +952,6 @@ def par_distance_matrix(filelist, f, label, consider_all_atoms, s):
else
:
d
[
i
,
j
]
=
get_euclidian_distance
(
coordinates_with_gaps
[
i
],
coordinates_with_gaps
[
j
])
print
(
"> finished."
)
np
.
savetxt
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
s
.
id
.
strip
(
"
\'
"
)
+
'.csv'
,
d
,
delimiter
=
","
,
fmt
=
"
%.3
f"
)
return
1
-
np
.
isnan
(
d
)
.
astype
(
int
),
np
.
nan_to_num
(
d
),
np
.
nan_to_num
(
d
*
d
)
...
...
@@ -1026,31 +1024,32 @@ def get_avg_std_distance_matrix(f, consider_all_atoms, multithread=False):
exit
(
1
)
# Calculation of the average matrix
avg
=
avg
/
counts
np
.
savetxt
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'_average.csv'
,
avg
,
delimiter
=
","
,
fmt
=
"
%.3
f"
)
fig
,
ax
=
plt
.
subplots
()
im
=
ax
.
imshow
(
avg
)
cbar
=
ax
.
figure
.
colorbar
(
im
,
ax
=
ax
)
cbar
.
ax
.
set_ylabel
(
"Angströms"
,
rotation
=-
90
,
va
=
"bottom"
)
ax
.
set_title
(
f
"Average distance between {f} residues (Angströms)"
)
fig
.
tight_layout
()
fig
.
savefig
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'_average.png'
,
dpi
=
300
)
plt
.
close
()
if
(
counts
>
1
)
.
all
():
# Calculation of the average matrix
avg
=
avg
/
counts
np
.
savetxt
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'_average.csv'
,
avg
,
delimiter
=
","
,
fmt
=
"
%.3
f"
)
fig
,
ax
=
plt
.
subplots
()
im
=
ax
.
imshow
(
avg
)
cbar
=
ax
.
figure
.
colorbar
(
im
,
ax
=
ax
)
cbar
.
ax
.
set_ylabel
(
"Angströms"
,
rotation
=-
90
,
va
=
"bottom"
)
ax
.
set_title
(
f
"Average distance between {f} residues (Angströms)"
)
fig
.
tight_layout
()
fig
.
savefig
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'_average.png'
,
dpi
=
300
)
plt
.
close
()
# Calculation of the standard deviation matrix by the Huygens theorem
std
=
np
.
sqrt
(
std
/
counts
-
np
.
power
(
avg
,
2
))
np
.
savetxt
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'_stdev.csv'
,
std
,
delimiter
=
","
,
fmt
=
"
%.3
f"
)
fig
,
ax
=
plt
.
subplots
()
im
=
ax
.
imshow
(
std
)
cbar
=
ax
.
figure
.
colorbar
(
im
,
ax
=
ax
)
cbar
.
ax
.
set_ylabel
(
"Angströms"
,
rotation
=-
90
,
va
=
"bottom"
)
ax
.
set_title
(
f
"Standard deviation of distances between {f} residues (Angströms)"
)
fig
.
tight_layout
()
fig
.
savefig
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'_std.png'
,
dpi
=
300
)
plt
.
close
()
# Calculation of the standard deviation matrix by the Huygens theorem
std
=
np
.
sqrt
(
std
/
counts
-
np
.
power
(
avg
,
2
))
np
.
savetxt
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'_stdev.csv'
,
std
,
delimiter
=
","
,
fmt
=
"
%.3
f"
)
fig
,
ax
=
plt
.
subplots
()
im
=
ax
.
imshow
(
std
)
cbar
=
ax
.
figure
.
colorbar
(
im
,
ax
=
ax
)
cbar
.
ax
.
set_ylabel
(
"Angströms"
,
rotation
=-
90
,
va
=
"bottom"
)
ax
.
set_title
(
f
"Standard deviation of distances between {f} residues (Angströms)"
)
fig
.
tight_layout
()
fig
.
savefig
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'_std.png'
,
dpi
=
300
)
plt
.
close
()
# Save log
with
open
(
runDir
+
'/results/distance_matrices/'
+
f
+
'_'
+
label
+
'/'
+
f
+
'.log'
,
'a'
)
as
logfile
:
...
...
Please
register
or
login
to post a comment