def checkSingleBond(atom1, atom2, d_min = 1.42): """check distance between two atoms (1.42) in: atom1 and atom2 out: 0 or 1""" distance = calcul.distanceTwoatoms(atom1, atom2) if distance >= d_min: return 1 else: return 0
def AreaCOO (pr_init): """calculation of volume around nitrogen of primary amine in: filePDB with only primary amine, extreme value of l_angle, structure subs out: file format filePDB with water only one half of imidazole are inspected""" subs = "COO" pr_volume = pathManage.CreatePathDir(pr_init + "Volume/") filout = open (pr_volume + "volume_" + subs + ".pdb", "w") l_atom_sub = structure.substructureCoord(subs) def_volume = structure.criteraAngle(subs) writePDBfile.coordinateSection(filout, l_atom_sub, "HETATM") angle_inf = def_volume["angle"][0] angle_sup = def_volume["angle"][1] d_inf = def_volume["distance"][0] d_sup = def_volume["distance"][1] for atom_sub in l_atom_sub : if atom_sub["name"] == "O01" : atomO1 = atom_sub if atom_sub["name"] == "O02" : atomO2 = atom_sub if atom_sub["name"] == "C02" : atomC2 = atom_sub if atom_sub["name"] == "C01" : atomC1 = atom_sub atom_center = calcul.CenterPoint(atomO1, atomO2) serial = 0 for x_test in [atom_center["x"] + x * 0.2 for x in range (-50,60)] : for y_test in [atom_center["y"] + y * 0.2 for y in range (-50,60)] : for z_test in [atom_center["z"] + z * 0.2 for z in range (-50,60)] : atom_test = structure.genericAtom(x_test, y_test, z_test) dist = calcul.distanceTwoatoms(atom_test, atom_center) # case where the calculation of angle is impossible try : angle = calcul.Angle3Atoms(atomC2, atom_center, atom_test) except : continue if dist <= d_sup and dist >= d_inf: if angle >= angle_inf and angle <= angle_sup : serial = serial + 1 atom_test["serial"] = serial atom_test["resSeq"] = serial writePDBfile.coordinateStructure(atom_test, "HETATM", filout) filout.close() WriteParameter (pr_volume + subs + ".param", subs, def_volume, serial)
def AeraTertiary (pr_init): """calculation of volume around nitrogen of primary amine in: filePDB with only primary amine, extreme value of l_angle, structure subs out: file format filePDB with water""" subs = "III" pr_volume = pathManage.CreatePathDir(pr_init + "Volume/") filout = open (pr_volume + "volume_" + subs + ".pdb", "w") l_atom_sub = structure.substructureCoord(subs) def_volume = structure.criteraAngle(subs) writePDBfile.coordinateSection(filout, l_atom_sub, "HETATM") angle_inf = def_volume["angle"][0] angle_sup = def_volume["angle"][1] d_inf = def_volume["distance"][0] d_sup = def_volume["distance"][1] for atom_sub in l_atom_sub : if atom_sub["element"] == "N" : atomN = atom_sub elif atom_sub["element"] == "C" : if "atomC1" in locals() : if "atomC2" in locals(): atomC3 = atom_sub else : atomC2 = atom_sub else : atomC1 = atom_sub serial = 0 for x_test in [atomN["x"] + x * 0.2 for x in range (-50,60)] : for y_test in [atomN["y"] + y * 0.2 for y in range (-50,60)] : for z_test in [atomN["z"] + z * 0.2 for z in range (-50,60)] : atom_test = structure.genericAtom(x_test, y_test, z_test) distance = calcul.distanceTwoatoms(atom_test, atomN) if distance < d_sup and distance > d_inf: l_angles = calcul.angleTertiaryAmineCalculVol(atomN, atom_test, atomC1, atomC2, atomC3) if l_angles[0] > angle_inf and l_angles[1] > angle_inf and l_angles[2] > angle_inf: if l_angles[0] < angle_sup and l_angles[1] < angle_sup and l_angles[2] < angle_sup: serial = serial + 1 atom_test["serial"] = serial atom_test["resSeq"] = serial writePDBfile.coordinateStructure(atom_test, "HETATM", filout) filout.close() WriteParameter (pr_volume + subs + ".param", subs, def_volume, serial)
def AreaGuanidium (pr_init): """calculation of volume around nitrogen of primary amine in: filePDB with only primary amine, extreme value of l_angle, structure subs out: file format filePDB with water""" subs = "GAI" pr_volume = pathManage.CreatePathDir(pr_init + "Volume/") filout = open (pr_volume + "volume_" + subs + ".pdb", "w") l_atom_sub = structure.substructureCoord(subs) def_volume = structure.criteraAngle(subs) writePDBfile.coordinateSection(filout, l_atom_sub, "HETATM") #filout.close () #ddd angle_inf = def_volume["angle"][0] angle_sup = def_volume["angle"][1] d_inf = def_volume["distance"][0] d_sup = def_volume["distance"][1] for atom_sub in l_atom_sub : if atom_sub["name"] == "N01" : atomN1 = atom_sub if atom_sub["name"] == "C01" : atomC1 = atom_sub count = 0 for x_test in [atomC1["x"] + x * 0.3 for x in range (-100,100)] : for y_test in [atomC1["y"] + y * 0.3 for y in range (-100,100)] : for z_test in [atomC1["z"] + z * 0.3 for z in range (-100,100)] : atom_test = structure.genericAtom(x_test, y_test, z_test) distance = calcul.distanceTwoatoms(atom_test, atomC1) l_angleC1 = calcul.anglePrimaryAmineCalculVol(atomC1, atomN1, atom_test) # print distance, l_angleC1 if distance < d_sup and distance > d_inf: if l_angleC1[0] > angle_inf and l_angleC1[0] < angle_sup : count = count + 1 atom_test["count"] = count atom_test["resSeq"] = count writePDBfile.coordinateStructure(atom_test, "HETATM", filout) filout.close() WriteParameter (pr_volume + subs + ".param", subs, def_volume, count)
def Nclose (atom, l_at_lig) : d_min = 100 for at_lig in l_at_lig : if at_lig["element"] != "N" : continue else : d = calcul.distanceTwoatoms(atom, at_lig) if d < d_min : d_min = d atom_temp = deepcopy(at_lig) if "atom_temp" in locals() : return atom_temp else : return {}
def controlLenCNBond (listAtomLigand, listDistance): """For each CN bond in list atom ligand, retrieve distance between C and N in: list atom ligand, list distance retrieve out: append in list ligand the distance""" for atom in listAtomLigand: if atom["element"] == "N": matrixConnect = atom["connect"] for serial in matrixConnect: atomConect = retrieveAtom.serial(serial, listAtomLigand) if atomConect != 0 and atomConect["element"] == "C": distance = calcul.distanceTwoatoms(atom, atomConect) listDistance.append(distance)
def checkLigandHooked (l_atom_complex, l_atom_lig, thresold = 1.65): l_atom_prot = deepcopy(l_atom_complex) for atom_lig in l_atom_lig : i = 0 nb_atom = len(l_atom_prot) while i < nb_atom : d = calcul.distanceTwoatoms(l_atom_prot[i], atom_lig) if d < thresold : print d return 1 # reduce combination with atom away elif d > (thresold * len (l_atom_lig)) : del l_atom_prot[i] nb_atom = nb_atom - 1 i = i + 1 return 0
def BondLengthCandX (l_atom_lig, X_element) : l_dist = [] l_serialX = searchPDB.ListSerialElement(l_atom_lig, str(X_element)) for serialX in l_serialX : # print serialX l_atom_connectX, connect = retrieveAtom.atomConnect(l_atom_lig, serialX) i = 0 nb_connect = len (connect) while i < nb_connect : if len(l_atom_connectX) >= 2 : dist = calcul.distanceTwoatoms(l_atom_connectX[0], l_atom_connectX[1]) # print dist if dist != 100 : l_dist.append (str(dist)) i = i + 1 return l_dist
def neighbors(rayon, atom_central, pdb, subs = "global", l_atom_lig = [] ): # change the name because in the same time function and variable """Search neighbors for all ligand in : rayon where is atoms, central atom, pdb file out : list atoms found""" l_atom = [] linesPDB = loadFile.openPdbFile(pdb) for line in linesPDB: if search("^ATOM", line) or search("^HETATM", line): atom = parsing.lineCoords(line) if atom != {} and atom["element"] != "H": distance = calcul.distanceTwoatoms(atom_central, atom) if distance <= rayon and distance != 0.0: if atom_central["resSeq"] != atom["resSeq"]: # check if variation if tool.atomInList(l_atom, atom) == 0: atom["distance"] = distance atom["angleSubs"] = calcul.angleSubs(atom_central, atom, l_atom_lig, subs) atom["classification"] = structure.classificationATOM(atom) l_atom.append(atom) return l_atom
def retrieveLigand (l_atom, name_ligand, extend = 2, debug = 0): """ Retrieve list of ligand in PDB args: -> PDB parsed -> name ligand return: list of ligand with atoms """ if debug : print "-control ligand select-" print name_ligand, "NAME ligand" print "l144 - parse PDB" print "****************" name_ligand = name_ligand.upper () list_atom_ligand = [] for element in l_atom : if element ["resName"] == name_ligand : list_atom_ligand.append (deepcopy(element)) for atomLigand in list_atom_ligand: atomLigand["connect"].append(atomLigand["serial"]) for atom_ligand_connect in list_atom_ligand: distance = calcul.distanceTwoatoms(atomLigand, atom_ligand_connect) if distance < extend and distance != 0: if not atom_ligand_connect["serial"] in atomLigand["connect"]: atomLigand["connect"].append(atom_ligand_connect["serial"]) # Check exotic bound (SE-C...) with special length of bound if checkConnectMatrix(list_atom_ligand) == 0 : if debug : print "- exotic ligand -, recursive distance" print "l165 - parse PDB" print "Threshold: ", extend print "--------------------" if extend <= 4.0 : return retrieveLigand (l_atom, name_ligand, extend + 0.1, debug = 0) return separateByLigand (list_atom_ligand)
def Guanidium(l_at_connect_N, l_atom_lig): """search Guanidium in: list atom connected of nitrogen, list atom ligand out: 1 or 0""" connectN1 = toolSubstructure.matrixElement(l_at_connect_N) nb_NH = 0 l_atom_out = [] # atom lateral if connectN1 == ["N", "C"] : l_at_connect_c, connectC = retrieveAtom.atomConnect(l_atom_lig , l_at_connect_N[1]["serial"]) if connectC == ["C", "N", "N", "N"] : l_atom_out.append (deepcopy(l_at_connect_c[0])) # append C groupAtomN1, conect_N1 = retrieveAtom.atomConnect(l_atom_lig , int (l_at_connect_c[0]["connect"][1])) groupAtomN2, conect_N2 = retrieveAtom.atomConnect(l_atom_lig , int (l_at_connect_c[0]["connect"][2])) groupAtomN3, conect_N3 = retrieveAtom.atomConnect(l_atom_lig , int (l_at_connect_c[0]["connect"][3])) l_conect = [conect_N1, conect_N2, conect_N3] l_group_atom = [groupAtomN1, groupAtomN2, groupAtomN3] i = 0 while i < 3 : if l_conect[i] == ["N", "C"] : nb_NH = nb_NH + 1 i = i + 1 elif l_conect[i] == ["N", "C", "C"]: if l_group_atom[i][1]["serial"] != l_at_connect_c[0]["serial"] : l_atom_out.append (deepcopy(l_group_atom[i][1])) elif l_group_atom[i][2]["serial"] != l_at_connect_c[0]["serial"] : l_atom_out.append (deepcopy(l_group_atom[i][2])) else : print "ERROR l158" return [0, []] i = i + 1 else : return [0, []] # check number primary connectN1 -> case GAI not take, change ? if nb_NH == 2 : l_atom_out.append (deepcopy(groupAtomN1[0])) l_atom_out.append (deepcopy(groupAtomN2[0])) l_atom_out.append (deepcopy(groupAtomN3[0])) else : return [0, []] # atom central structure elif connectN1 == ["N", "C", "C"] : for at_conect in l_at_connect_N[1:] : l_group_at, conect_N = retrieveAtom.atomConnect(l_atom_lig , at_conect["serial"]) if conect_N == ["C", "N", "N", "N"] : l_c_central = l_group_at l_atom_out.append (deepcopy(l_c_central[0])) for group_at in l_group_at[1:] : l_goup_N, connect_N = retrieveAtom.atomConnect(l_atom_lig , group_at["serial"]) if connect_N == ["N", "C"] : nb_NH = nb_NH + 1 else : l_atom_out.append (deepcopy(l_group_at[0])) if nb_NH >= 2 and len (l_atom_out) >= 2 : l_atom_out.append (deepcopy(l_c_central[1])) l_atom_out.append (deepcopy(l_c_central[2])) l_atom_out.append (deepcopy(l_c_central[3])) else : return [0, []] if len (l_atom_out) != 5 : return [0,[]] else : # append 2 carbons l_C, connectC = retrieveAtom.atomConnect(l_atom_lig , l_atom_out[0]["serial"]) if connectC == ["C", "N", "N", "N"] : l_serial = [l_atom_out[1]["serial"], l_atom_out[0]["serial"]] atomC1 = l_atom_out[1] else : l_serial = [l_atom_out[0]["serial"], l_atom_out[1]["serial"]] atomC1 = l_atom_out[0] # distance between C2 and N d1 = calcul.distanceTwoatoms(atomC1, l_atom_out[2]) d2 = calcul.distanceTwoatoms(atomC1, l_atom_out[3]) d3 = calcul.distanceTwoatoms(atomC1, l_atom_out[4]) l_dist = [d1, d2, d3] l_dist.sort () for dist in l_dist : if dist == d1 : l_serial.append (l_atom_out[2]["serial"]) elif dist == d2 : l_serial.append (l_atom_out[3]["serial"]) else : l_serial.append (l_atom_out[4]["serial"]) return [1,l_serial] return [0, []]