Showing
1 changed file
with
94 additions
and
0 deletions
... | @@ -1181,6 +1181,100 @@ def get_euclidian_distance(L1, L2): | ... | @@ -1181,6 +1181,100 @@ def get_euclidian_distance(L1, L2): |
1181 | e += float(L1[i] - L2[i])**2 | 1181 | e += float(L1[i] - L2[i])**2 |
1182 | return np.sqrt(e) | 1182 | return np.sqrt(e) |
1183 | 1183 | ||
1184 | +def distance(coord1, coord2): | ||
1185 | + """ | ||
1186 | + Returns the distance between two points using their coordinates (x, y, z) | ||
1187 | + """ | ||
1188 | + if (coord1 == [] or coord2 == []) : | ||
1189 | + return None | ||
1190 | + else : | ||
1191 | + return math.sqrt((coord1[0]-coord2[0])**2 + (coord1[1]-coord2[1])**2 + (coord1[2]-coord2[2])**2) | ||
1192 | + | ||
1193 | +def pos_b1(res) : | ||
1194 | + """ | ||
1195 | + Returns the coordinates of virtual atom B1 (center of the first aromatic cycle) | ||
1196 | + """ | ||
1197 | + coordb1=[] | ||
1198 | + somme_x_b1=0 | ||
1199 | + somme_y_b1=0 | ||
1200 | + somme_z_b1=0 | ||
1201 | + moy_x_b1=0 | ||
1202 | + moy_y_b1=0 | ||
1203 | + moy_z_b1=0 | ||
1204 | + #different cases | ||
1205 | + #some residues have 2 aromatic cycles | ||
1206 | + if res.get_resname() in ['A', 'G', '2MG', '7MG', 'MA6', '6IA', 'OMG' , '2MA', 'B9B', 'A2M', '1MA', 'E7G', 'P7G', 'B8W', 'B8K', 'BGH', '6MZ', 'E6G', 'MHG', 'M7A', 'M2G', 'P5P', 'G7M', '1MG', 'T6A', 'MIA', 'YG', 'YYG', 'I', 'DG', 'N79', '574', 'DJF', 'AET', '12A', 'ANZ', 'UY4'] : | ||
1207 | + c=0 | ||
1208 | + names=[] | ||
1209 | + for atom in res : | ||
1210 | + if (atom.get_fullname() in ['N9', 'C8', 'N7', 'C4', 'C5']) : | ||
1211 | + c=c+1 | ||
1212 | + names.append(atom.get_name()) | ||
1213 | + coord=atom.get_vector() | ||
1214 | + somme_x_b1=somme_x_b1+coord[0] | ||
1215 | + somme_y_b1=somme_y_b1+coord[1] | ||
1216 | + somme_z_b1=somme_z_b1+coord[2] | ||
1217 | + else : | ||
1218 | + c=c | ||
1219 | + #calcul coord B1 | ||
1220 | + if c != 0 : | ||
1221 | + moy_x_b1=somme_x_b1/c | ||
1222 | + moy_y_b1=somme_y_b1/c | ||
1223 | + moy_z_b1=somme_z_b1/c | ||
1224 | + coordb1.append(moy_x_b1) | ||
1225 | + coordb1.append(moy_y_b1) | ||
1226 | + coordb1.append(moy_z_b1) | ||
1227 | + #others have only one cycle | ||
1228 | + if res.get_resname() in ['C', 'U', 'AG9', '70U', '1RN', 'RSP', '3AU', 'CM0', 'U8U', 'IU', 'E3C', '4SU', '5HM', 'LV2', 'LHH', '4AC', 'CH', 'Y5P', '2MU', '4OC', 'B8T', 'JMH', 'JMC', 'DC', 'B9H', 'UR3', 'I4U', 'B8Q', 'P4U', 'OMU', 'OMC', '5MU', 'H2U', 'CBV', 'M1Y', 'B8N', '3TD', 'B8H'] : | ||
1229 | + c=0 | ||
1230 | + for atom in res : | ||
1231 | + if (atom.get_fullname() in ['C6', 'N3', 'N1', 'C2', 'C4', 'C5']): | ||
1232 | + c=c+1 | ||
1233 | + coord=atom.get_vector() | ||
1234 | + somme_x_b1=somme_x_b1+coord[0] | ||
1235 | + somme_y_b1=somme_y_b1+coord[1] | ||
1236 | + somme_z_b1=somme_z_b1+coord[2] | ||
1237 | + #calcul coord B1 | ||
1238 | + if c != 0 : | ||
1239 | + moy_x_b1=somme_x_b1/c | ||
1240 | + moy_y_b1=somme_y_b1/c | ||
1241 | + moy_z_b1=somme_z_b1/c | ||
1242 | + coordb1.append(moy_x_b1) | ||
1243 | + coordb1.append(moy_y_b1) | ||
1244 | + coordb1.append(moy_z_b1) | ||
1245 | + return(coordb1) | ||
1246 | + | ||
1247 | +def pos_b2(res): | ||
1248 | + """ | ||
1249 | + Returns the coordinates of virtual atom B2 (center of the second aromatic cycle, if exists) | ||
1250 | + """ | ||
1251 | + coordb2=[] | ||
1252 | + somme_x_b2=0 | ||
1253 | + somme_y_b2=0 | ||
1254 | + somme_z_b2=0 | ||
1255 | + moy_x_b2=0 | ||
1256 | + moy_y_b2=0 | ||
1257 | + moy_z_b2=0 | ||
1258 | + | ||
1259 | + if res.get_resname() in ['A', 'G', '2MG', '7MG', 'MA6', '6IA', 'OMG' , '2MA', 'B9B', 'A2M', '1MA', 'E7G', 'P7G', 'B8W', 'B8K', 'BGH', '6MZ', 'E6G', 'MHG', 'M7A', 'M2G', 'P5P', 'G7M', '1MG', 'T6A', 'MIA', 'YG', 'YYG', 'I', 'DG', 'N79', '574', 'DJF', 'AET', '12A', 'ANZ', 'UY4'] : #2 cycles aromatiques | ||
1260 | + c=0 | ||
1261 | + for atom in res : | ||
1262 | + if atom.get_fullname() in ['C6', 'N3', 'N1', 'C2', 'C4', 'C5'] : | ||
1263 | + c=c+1 | ||
1264 | + coord=atom.get_vector() | ||
1265 | + somme_x_b2=somme_x_b2+coord[0] | ||
1266 | + somme_y_b2=somme_y_b2+coord[1] | ||
1267 | + somme_z_b2=somme_z_b2+coord[2] | ||
1268 | + #calcul coord B2 | ||
1269 | + if c!=0 : | ||
1270 | + moy_x_b2=somme_x_b2/c | ||
1271 | + moy_y_b2=somme_y_b2/c | ||
1272 | + moy_z_b2=somme_z_b2/c | ||
1273 | + coordb2.append(moy_x_b2) | ||
1274 | + coordb2.append(moy_y_b2) | ||
1275 | + coordb2.append(moy_z_b2) | ||
1276 | + return coordb2 | ||
1277 | + | ||
1184 | if __name__ == "__main__": | 1278 | if __name__ == "__main__": |
1185 | 1279 | ||
1186 | os.makedirs(runDir + "/results/figures/", exist_ok=True) | 1280 | os.makedirs(runDir + "/results/figures/", exist_ok=True) | ... | ... |
-
Please register or login to post a comment