-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
204 lines (151 loc) · 7.37 KB
/
Copy pathmain.py
File metadata and controls
204 lines (151 loc) · 7.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/env python
# -*- coding : utf8 -*-
"""
Authors: Maud De Tollenaere & Severine Liegeois
Contact: de.tollenaere.maud@gmail.com & sliegeois@yahoo.fr
Date: 02/05/2017
Description: A program that analyzes the sRNP H/ACA complex of the archea Pyroccocus abyssi.
"""
from ParserPDB import *
from computeInterface import *
import sys, os
def usage():
print ("""
This program allows you to analyze a molecular dynamics in PDB format.
Inputs: - a PDB file (ATOM format) containing the reference structure
- a PDB file (ATOM format) containing all the structures of the dynamics
Outputs: - Root Mean Square Deviation (RMSD) for the whole structure or for particular domains
- Distance matrices between residues or domains
- Residues' frequency of belonging to an interface
- Duration of contact between key residues
==================================================================================
Arguments
obligatory:
===========
-ref -> pdb file containing the reference structure of the protein/RNA complex
-conf -> pdb file containing the different conformations of the complex
optional:
=========
-th -> threshold to define a contact,in Ansgtrom (default = 9.0)
-rmsd -> if rmsd = 'CA', computes the RMSD between alpha carbons of two residues
and returns it.
if rmsd = 'CM', commputes the RMSD between the centers of mass of the two
residues and returns it. (default = 'CM')
-mode -> if mode = 'atom', computes the distance between all the atoms of two residues
or of a residue and a nucleotide and returns the smallest distance.
if mode = 'CM', computes the distance between the centers of mass and returns it.
(default = 'CM)
""")
def exists_file(f):
"""
Teste si un fichier de sortie existe deja dans le repertoire courant.
:param f: Nom du fichier de sortie.
:return: True si le fichier existe deja, False sinon
"""
if os.path.exists(f):
return True
return False
def overwrite_file(f):
"""
Si un fichier de sortie existe deja, demande a l'utilisateur s'il veut l'ecraser.
:param f: Nom du fichier de sortie.
:return: Nom du fichier de sortie.
"""
overwrite = "No"
while ((overwrite == "No" or overwrite == "no") and exists_file(f)):
overwrite = input("This file already exists ! Do you want to overwrite this file ? (yes / no) ")
if overwrite == "No" or overwrite == "no":
f = input("Please, enter the name of the output file: ")
return f
# Get arguments
# =============
try:
ref_file = sys.argv[sys.argv.index("-ref")+1]
except:
usage()
print("ERROR: please, enter the name of the reference pdb input")
sys.exit()
try:
conf_file = sys.argv[sys.argv.index("-conf")+1]
except:
usage()
print("ERROR: please, enter the name of the conformations pdb input")
sys.exit()
try:
f = open(ref_file)
f.close()
except:
print("ERROR: this file does not exist: ", ref_file)
sys.exit()
try:
f = open(conf_file)
f.close()
except:
print("ERROR: this file does not exist: ", conf_file)
sys.exit()
try:
threshold = float(sys.argv[sys.argv.index("-th")+1])
except:
threshold = 9.0
try:
rmsd_mode = sys.argv[sys.argv.index("-rmsd")+1]
except:
rmsd_mode = "CM"
try:
dist_mode = sys.argv[sys.argv.index("-mode")+1]
except:
dist_mode = "CM"
list_dom_prot = input("Please, enter the list of proteic domains identifiers (example: A1,A2,A3,A4) :").split(sep=",")
dom_rna = input("Please, enter the RNA domain identifier (example: B) :")
parsing_list = list(list_dom_prot)
parsing_list.append(dom_rna)
# ----------------------------------------
# Parsing de la conformation de reference
# ----------------------------------------
ref = PDBparser(ref_file, parsing_list)
# ------------------------------
# Parsing des 500 conformations
# ------------------------------
frames = PDBparserMulti(conf_file, parsing_list)
# --------------------------------------------------------------------------------------------
# Calcul du RMSD entre la structure de reference et chacune des conformations de la dynamique
# --------------------------------------------------------------------------------------------
rmsd_output = input("Please, enter the name of the output file to store the RMSDs\n(example: rmsd.txt): ")
# Verifie si le fichier existe deja:
rmsd_output = overwrite_file(rmsd_output)
computeRMSD(ref, frames, list_dom_prot, rmsd_mode, rmsd_output)
# ---------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------
# Calcul de la matrice des distances entre chaque domaine proteique et l'ARN pour la structure de reference
# ----------------------------------------------------------------------------------------------------------
distmat_ref = input("Do you want to show the distance matrices (between the proteic domains and RNA)\nfor the reference structure as heatmaps ? (yes / no) ")
if distmat_ref == "yes" or distmat_ref == "Yes":
for dom in list_dom_prot:
distMatrix(ref, dom, dom_rna, dist_mode)
# -------------------------------------------------------------------------------------------------
# Calcul de la frequence d'appartenance a l'interface avec l'ARN pour chaque residu de la proteine
# -------------------------------------------------------------------------------------------------
freq_output = input("Please, enter the name of the output file to store the frequences\nof belonging to the interface (example: freq.txt): ")
freq_output = overwrite_file(freq_output)
writing = input("Do you want to get a pdb file with B-factors different for\nresidues belonging to the interface ? (yes / no)")
if writing == "yes" or writing == "Yes":
bfactor_output = input("Please enter the name of the output pdb file (example: bfactor.pdb):")
bfactor_output = overwrite_file(bfactor_output)
freq_interface = resInterface(frames, list_dom_prot, dom_rna, threshold, dist_mode, freq_output, writePDB=bfactor_output)
else:
freq_interface = resInterface(frames, list_dom_prot, dom_rna, threshold, dist_mode, freq_output)
# ------------------------------------------------------------------------------------
# Calcul des temps de contact entre paires de residus choisis a partir de la Figure 2
# ------------------------------------------------------------------------------------
pairs = {'41': {'dom1':'A4', 'res2':'32', 'dom2':'B'},
'100':{'dom1':'A4', 'res2':'31', 'dom2':'B'},
'46': {'dom1':'A4', 'res2':'25', 'dom2':'B'},
'34': {'dom1':'A3', 'res2':'33', 'dom2':'B'},
'6' : {'dom1':'A3', 'res2':'63', 'dom2':'A4'},
'66': {'dom1':'A4', 'res2':'41', 'dom2':'A3'},
'98': {'dom1':'A4', 'res2':'30', 'dom2':'B'},
'26': {'dom1':'A3', 'res2':'65', 'dom2':'A4'}}
contact_output = input("Please, enter the name of the output file to store the durations\n of contact: ")
contact_output = overwrite_file(contact_output)
duration = int(input("Please, enter the duration of the dynamic (in ns):"))
contacts = contactTime(pairs, frames, threshold, duration, dist_mode, contact_output)