Showing
1 changed file
with
28 additions
and
12 deletions
... | @@ -1268,6 +1268,9 @@ def get_euclidian_distance(L1, L2): | ... | @@ -1268,6 +1268,9 @@ def get_euclidian_distance(L1, L2): |
1268 | e += float(L1[i] - L2[i])**2 | 1268 | e += float(L1[i] - L2[i])**2 |
1269 | except TypeError: | 1269 | except TypeError: |
1270 | print("Terms: ", L1, L2) | 1270 | print("Terms: ", L1, L2) |
1271 | + except IndexError: | ||
1272 | + print("Terms: ", L1, L2) | ||
1273 | + | ||
1271 | return np.sqrt(e) | 1274 | return np.sqrt(e) |
1272 | 1275 | ||
1273 | def get_flat_angle(L1, L2, L3): | 1276 | def get_flat_angle(L1, L2, L3): |
... | @@ -1282,7 +1285,7 @@ def get_torsion_angle(L1, L2, L3, L4): | ... | @@ -1282,7 +1285,7 @@ def get_torsion_angle(L1, L2, L3, L4): |
1282 | 1285 | ||
1283 | return calc_dihedral(Vector(L1[0]), Vector(L2[0]), Vector(L3[0]), Vector(L4[0]))*(180/np.pi) | 1286 | return calc_dihedral(Vector(L1[0]), Vector(L2[0]), Vector(L3[0]), Vector(L4[0]))*(180/np.pi) |
1284 | 1287 | ||
1285 | -def pos_b1(res) : | 1288 | +def pos_b1(res): |
1286 | """ | 1289 | """ |
1287 | Returns the coordinates of virtual atom B1 (center of the first aromatic cycle) | 1290 | Returns the coordinates of virtual atom B1 (center of the first aromatic cycle) |
1288 | """ | 1291 | """ |
... | @@ -1334,7 +1337,11 @@ def pos_b1(res) : | ... | @@ -1334,7 +1337,11 @@ def pos_b1(res) : |
1334 | coordb1.append(moy_x_b1) | 1337 | coordb1.append(moy_x_b1) |
1335 | coordb1.append(moy_y_b1) | 1338 | coordb1.append(moy_y_b1) |
1336 | coordb1.append(moy_z_b1) | 1339 | coordb1.append(moy_z_b1) |
1337 | - return(coordb1) | 1340 | + |
1341 | + if len(coordb1): | ||
1342 | + return [coordb1] | ||
1343 | + else: | ||
1344 | + return [] | ||
1338 | 1345 | ||
1339 | def pos_b2(res): | 1346 | def pos_b2(res): |
1340 | """ | 1347 | """ |
... | @@ -1365,7 +1372,10 @@ def pos_b2(res): | ... | @@ -1365,7 +1372,10 @@ def pos_b2(res): |
1365 | coordb2.append(moy_x_b2) | 1372 | coordb2.append(moy_x_b2) |
1366 | coordb2.append(moy_y_b2) | 1373 | coordb2.append(moy_y_b2) |
1367 | coordb2.append(moy_z_b2) | 1374 | coordb2.append(moy_z_b2) |
1368 | - return coordb2 | 1375 | + if len(coordb2): |
1376 | + return [coordb2] | ||
1377 | + else: | ||
1378 | + return [] | ||
1369 | 1379 | ||
1370 | def basepair_apex_distance(res, pair): | 1380 | def basepair_apex_distance(res, pair): |
1371 | """ | 1381 | """ |
... | @@ -1418,6 +1428,7 @@ def basepair_flat_angle(res, pair): | ... | @@ -1418,6 +1428,7 @@ def basepair_flat_angle(res, pair): |
1418 | angles=[a, b, c, d] | 1428 | angles=[a, b, c, d] |
1419 | return angles | 1429 | return angles |
1420 | 1430 | ||
1431 | +@trace_unhandled_exceptions | ||
1421 | def measure_from_structure(f): | 1432 | def measure_from_structure(f): |
1422 | """ | 1433 | """ |
1423 | Do geometric measures required on a given filename | 1434 | Do geometric measures required on a given filename |
... | @@ -1446,6 +1457,7 @@ def measure_from_structure(f): | ... | @@ -1446,6 +1457,7 @@ def measure_from_structure(f): |
1446 | idxQueue.put(thr_idx) # replace the thread index in the queue | 1457 | idxQueue.put(thr_idx) # replace the thread index in the queue |
1447 | setproctitle(f"RNANet statistics.py Worker {thr_idx+1} finished") | 1458 | setproctitle(f"RNANet statistics.py Worker {thr_idx+1} finished") |
1448 | 1459 | ||
1460 | +@trace_unhandled_exceptions | ||
1449 | def measures_wadley(name, s, thr_idx): | 1461 | def measures_wadley(name, s, thr_idx): |
1450 | """ | 1462 | """ |
1451 | Measures the distances and plane angles involving C1' and P atoms | 1463 | Measures the distances and plane angles involving C1' and P atoms |
... | @@ -1496,6 +1508,7 @@ def measures_wadley(name, s, thr_idx): | ... | @@ -1496,6 +1508,7 @@ def measures_wadley(name, s, thr_idx): |
1496 | df = pd.DataFrame(liste_angl, columns=["Residu", "P-C1'-P°", "C1'-P°-C1'°"]) | 1508 | df = pd.DataFrame(liste_angl, columns=["Residu", "P-C1'-P°", "C1'-P°-C1'°"]) |
1497 | df.to_csv(runDir + "/results/geometry/Pyle/angles/angles_plans_wadley "+name+".csv") | 1509 | df.to_csv(runDir + "/results/geometry/Pyle/angles/angles_plans_wadley "+name+".csv") |
1498 | 1510 | ||
1511 | +@trace_unhandled_exceptions | ||
1499 | def measures_aa(name, s, thr_idx): | 1512 | def measures_aa(name, s, thr_idx): |
1500 | """ | 1513 | """ |
1501 | Measures the distance between atoms linked by covalent bonds | 1514 | Measures the distance between atoms linked by covalent bonds |
... | @@ -1657,6 +1670,7 @@ def measures_aa(name, s, thr_idx): | ... | @@ -1657,6 +1670,7 @@ def measures_aa(name, s, thr_idx): |
1657 | 1670 | ||
1658 | df.to_csv(runDir+"/results/geometry/all-atoms/distances/dist_atoms "+name+".csv") | 1671 | df.to_csv(runDir+"/results/geometry/all-atoms/distances/dist_atoms "+name+".csv") |
1659 | 1672 | ||
1673 | +@trace_unhandled_exceptions | ||
1660 | def measures_hrna(name, s, thr_idx): | 1674 | def measures_hrna(name, s, thr_idx): |
1661 | """ | 1675 | """ |
1662 | Measures the distance/angles between the atoms of the HiRE-RNA model linked by covalent bonds | 1676 | Measures the distance/angles between the atoms of the HiRE-RNA model linked by covalent bonds |
... | @@ -1680,7 +1694,7 @@ def measures_hrna(name, s, thr_idx): | ... | @@ -1680,7 +1694,7 @@ def measures_hrna(name, s, thr_idx): |
1680 | 1694 | ||
1681 | chain = next(s[0].get_chains()) | 1695 | chain = next(s[0].get_chains()) |
1682 | residues=list(chain.get_residues()) | 1696 | residues=list(chain.get_residues()) |
1683 | - for res in tqdm(chain0, position=thr_idx+1, desc=f"Worker {thr_idx+1}: {name} measures_hrna", unit="res", leave=False): | 1697 | + for res in tqdm(chain, position=thr_idx+1, desc=f"Worker {thr_idx+1}: {name} measures_hrna", unit="res", leave=False): |
1684 | # distances | 1698 | # distances |
1685 | p_o5p = None | 1699 | p_o5p = None |
1686 | o5p_c5p = None | 1700 | o5p_c5p = None |
... | @@ -1720,12 +1734,12 @@ def measures_hrna(name, s, thr_idx): | ... | @@ -1720,12 +1734,12 @@ def measures_hrna(name, s, thr_idx): |
1720 | atom_b2 = pos_b2(res) # position b2 to be calculated only for those with 2 cycles | 1734 | atom_b2 = pos_b2(res) # position b2 to be calculated only for those with 2 cycles |
1721 | 1735 | ||
1722 | # Distances. If one of the atoms is empty, the euclidian distance returns NaN. | 1736 | # Distances. If one of the atoms is empty, the euclidian distance returns NaN. |
1723 | - last_c4p_p = get_euclidian_distance(last_c4p[0], atom_p[0]) | 1737 | + last_c4p_p = get_euclidian_distance(last_c4p, atom_p) |
1724 | - p_o5p = get_euclidian_distance(atom_p[0], atom_o5p[0]) | 1738 | + p_o5p = get_euclidian_distance(atom_p, atom_o5p) |
1725 | - o5p_c5p = get_euclidian_distance(atom_o5p[0], atom_c5p[0]) | 1739 | + o5p_c5p = get_euclidian_distance(atom_o5p, atom_c5p) |
1726 | - c5p_c4p = get_euclidian_distance(atom_c5p[0], atom_c4p[0]) | 1740 | + c5p_c4p = get_euclidian_distance(atom_c5p, atom_c4p) |
1727 | - c4p_c1p = get_euclidian_distance(atom_c4p[0], atom_c1p[0]) | 1741 | + c4p_c1p = get_euclidian_distance(atom_c4p, atom_c1p) |
1728 | - c1p_b1 = get_euclidian_distance(atom_c1p[0], atom_b1) | 1742 | + c1p_b1 = get_euclidian_distance(atom_c1p, atom_b1) |
1729 | b1_b2 = get_euclidian_distance(atom_b1, atom_b2) | 1743 | b1_b2 = get_euclidian_distance(atom_b1, atom_b2) |
1730 | 1744 | ||
1731 | # flat angles. Same. | 1745 | # flat angles. Same. |
... | @@ -1758,10 +1772,11 @@ def measures_hrna(name, s, thr_idx): | ... | @@ -1758,10 +1772,11 @@ def measures_hrna(name, s, thr_idx): |
1758 | df = pd.DataFrame(liste_dist, columns=["Residu", "C4'-P", "P-O5'", "O5'-C5'", "C5'-C4'", "C4'-C1'", "C1'-B1", "B1-B2"]) | 1772 | df = pd.DataFrame(liste_dist, columns=["Residu", "C4'-P", "P-O5'", "O5'-C5'", "C5'-C4'", "C4'-C1'", "C1'-B1", "B1-B2"]) |
1759 | df.to_csv(runDir + '/results/geometry/HiRE-RNA/distances/dist_atoms_hire_RNA '+name+'.csv') | 1773 | df.to_csv(runDir + '/results/geometry/HiRE-RNA/distances/dist_atoms_hire_RNA '+name+'.csv') |
1760 | df = pd.DataFrame(liste_angl, columns=["Residu", "C4'-P-O5'", "C1'-C4'-P", "C5'-C4'-P", "P-O5'-C5'", "O5'-C5'-C4'", "C5'-C4'-C1'", "C4'-C1'-B1", "C1'-B1-B2"]) | 1774 | df = pd.DataFrame(liste_angl, columns=["Residu", "C4'-P-O5'", "C1'-C4'-P", "C5'-C4'-P", "P-O5'-C5'", "O5'-C5'-C4'", "C5'-C4'-C1'", "C4'-C1'-B1", "C1'-B1-B2"]) |
1761 | - df.to_csv(runDur + '/results/geometry/HiRE-RNA/angles/angles_hire_RNA ' + name + ".csv") | 1775 | + df.to_csv(runDir + '/results/geometry/HiRE-RNA/angles/angles_hire_RNA ' + name + ".csv") |
1762 | - df=pd.DataFrame(liste_angles_torsion, columns=["Residu", "P-O5'-C5'-C4'", "O5'-C5'-C4'-C1'", "C5'-C4'-C1'-B1", "C4'-C1'-B1-B2", "O5'-C5'-C4'-P°", "C5'-C4'-P°-O5'°", "C4'-P°-O5'°-C5'°", "C1'-C4'-P°-O5'°"]) | 1776 | + df=pd.DataFrame(liste_tors, columns=["Residu", "P-O5'-C5'-C4'", "O5'-C5'-C4'-C1'", "C5'-C4'-C1'-B1", "C4'-C1'-B1-B2", "O5'-C5'-C4'-P°", "C5'-C4'-P°-O5'°", "C4'-P°-O5'°-C5'°", "C1'-C4'-P°-O5'°"]) |
1763 | df.to_csv(runDir + '/results/geometry/HiRE-RNA/torsions/angles_torsion_hire_RNA '+name+'.csv') | 1777 | df.to_csv(runDir + '/results/geometry/HiRE-RNA/torsions/angles_torsion_hire_RNA '+name+'.csv') |
1764 | 1778 | ||
1779 | +@trace_unhandled_exceptions | ||
1765 | def measure_hrna_basepairs(cle): | 1780 | def measure_hrna_basepairs(cle): |
1766 | """ | 1781 | """ |
1767 | Open a complete RNAcifs/ file, and run measure_hrna_basepairs_chain() on every chain | 1782 | Open a complete RNAcifs/ file, and run measure_hrna_basepairs_chain() on every chain |
... | @@ -1812,6 +1827,7 @@ def measure_hrna_basepairs(cle): | ... | @@ -1812,6 +1827,7 @@ def measure_hrna_basepairs(cle): |
1812 | idxQueue.put(thr_idx) # replace the thread index in the queue | 1827 | idxQueue.put(thr_idx) # replace the thread index in the queue |
1813 | setproctitle(f"RNANet statistics.py Worker {thr_idx+1} finished") | 1828 | setproctitle(f"RNANet statistics.py Worker {thr_idx+1} finished") |
1814 | 1829 | ||
1830 | +@trace_unhandled_exceptions | ||
1815 | def measure_hrna_basepairs_chain(chain, df, thr_idx): | 1831 | def measure_hrna_basepairs_chain(chain, df, thr_idx): |
1816 | """ | 1832 | """ |
1817 | Cleanup of the dataset | 1833 | Cleanup of the dataset | ... | ... |
-
Please register or login to post a comment