def angleTertiaryAmine (atomNitrogen, atomCounterIon, listAtomLigand): """Calcul for nitrogen and counter ion angles in: atom nitrogen, atom Counter Ions out: list of 3 angles""" matrix = atomNitrogen["connect"] if len(matrix) < 4: print "Atom does not 3 bonds !!" return else: carbon1 = retrieveAtom.serial(matrix[1], listAtomLigand) carbon2 = retrieveAtom.serial(matrix[2], listAtomLigand) carbon3 = retrieveAtom.serial(matrix[3], listAtomLigand) distanceNitrogenCounterIon = distanceTwoatoms(atomNitrogen, atomCounterIon) distanceCarbon1CounterIon = distanceTwoatoms(atomCounterIon, carbon1) distanceCarbon2CounterIon = distanceTwoatoms(atomCounterIon, carbon2) distanceCarbon3CounterIon = distanceTwoatoms(atomCounterIon, carbon3) distanceNitrogenCarbon1 = distanceTwoatoms(atomNitrogen, carbon1) distanceNitrogenCarbon2 = distanceTwoatoms(atomNitrogen, carbon2) distanceNitrogenCarbon3 = distanceTwoatoms(atomNitrogen, carbon3) angle1 = degrees(acos((distanceNitrogenCarbon1 * distanceNitrogenCarbon1 + distanceNitrogenCounterIon * distanceNitrogenCounterIon - distanceCarbon1CounterIon * distanceCarbon1CounterIon) / (2 * distanceNitrogenCarbon1 * distanceNitrogenCounterIon))) angle2 = degrees(acos((distanceNitrogenCarbon2 * distanceNitrogenCarbon2 + distanceNitrogenCounterIon * distanceNitrogenCounterIon - distanceCarbon2CounterIon * distanceCarbon2CounterIon) / (2 * distanceNitrogenCarbon2 * distanceNitrogenCounterIon))) angle3 = degrees(acos((distanceNitrogenCarbon3 * distanceNitrogenCarbon3 + distanceNitrogenCounterIon * distanceNitrogenCounterIon - distanceCarbon3CounterIon * distanceCarbon3CounterIon) / (2 * distanceNitrogenCarbon3 * distanceNitrogenCounterIon))) return [angle1, angle2, angle3]
def retrieveAtomConnected(atom, listAtom): """retrieve list atom connected in: atom, list atoms out: list atoms connected""" listAtom = [] atom = retrieveAtom.serial(int(atom), listAtom) connectMatrix = atom['connect'] for i in connectMatrix: listAtom.append(retrieveAtom.serial(i, listAtom)) return listAtom
def connectMatrixSerialToConnectMatrixElement(connectMatrixSerial, listAtom): '''transform Connect matrix with serial in: connect matrix serial, list atom out: list -> matrix connect element''' link = [] for serial in connectMatrixSerial: try : link.append(retrieveAtom.serial(int(serial), listAtom)["element"]) except : pass return link
def AngleSecondaryFromLig(atomN, atom_neighbor, l_atom_lig): """Calcul for nitrogen and neighbor in: atom nitrogen, atom neighbor out: angle between muddle of 2 cabones and N and neigbbor""" l_connect = atomN["connect"] if len(l_connect) < 3: print "Atom does not 2 bonds !!" return else: atomC1 = retrieveAtom.serial(l_connect[1], l_atom_lig) atomC2 = retrieveAtom.serial(l_connect[2], l_atom_lig) angle1 = Angle3Atoms (atomC1, atomN, atom_neighbor) angle2 = Angle3Atoms (atomC2, atomN, atom_neighbor) return [angle1, angle2]
def appendAtomConnect(atom, listRetrive, atomLigand): listSerial = [] for atomRetrieve in listRetrive : listSerial.append(atomRetrieve["serial"]) for serialAtom in atom["connect"] : if not serialAtom in listSerial : atom = retrieveAtom.serial(serialAtom, atomLigand) if atom != 0 : listRetrive.append(atom)
def coplanar (atom, l_atom_ligand): """Calculate the orthogonal distance between nitrogen atom of tertiary amine and plan with 3 carbons connect in : - atom of nitrogen -> dictionnary - all atom of ligand -> list of atom dictionnary out : - distance -> float""" matrix = atom["connect"] if len(matrix) < 4: print "Atom does not 3 bonds !!" return else: point = [float(retrieveAtom.serial(matrix[0], l_atom_ligand)["x"]), float(retrieveAtom.serial(matrix[0], l_atom_ligand)["y"]), float(retrieveAtom.serial(matrix[0], l_atom_ligand)["z"])] d = symbols("d") atom1 = retrieveAtom.serial(matrix[1], l_atom_ligand) atom2 = retrieveAtom.serial(matrix[2], l_atom_ligand) atom3 = retrieveAtom.serial(matrix[3], l_atom_ligand) point1 = [float(atom1["x"]), float(atom1["y"]), float(atom1["z"])] point2 = [float(atom2["x"]), float(atom2["y"]), float(atom2["z"])] point3 = [float(atom3["x"]), float(atom3["y"]), float(atom3["z"])] v1 = [point3[0] - point1[0], point3[1] - point1[1], point3[2] - point1[2]] v2 = [point2[0] - point1[0], point2[1] - point1[1], point2[2] - point1[2]] a = v1[1] * v2[2] - v1[2] * v2[1] b = v1[2] * v2[0] - v1[0] * v2[2] c = v1[0] * v2[1] - v1[1] * v2[0] d = float(solve(a * point1[0] + b * point1[1] + c * point1[2] - d, d)[0]) nominator = abs(a * point[0] + b * point[1] + c * point[2] - d) denominator = (a ** 2 + b ** 2 + c ** 2) ** (1 / 2) distance = nominator / denominator return distance
def cycleOnlyTestCarbon(serialFirst, serialTest, serialPrevious, atomLigand, test, flagNitrogen) : atomTest = retrieveAtom.serial(serialTest, atomLigand) if serialFirst == atomTest["serial"] and test == 0: return 1 if atomTest == 0 : return 0 if atomTest ["element"] != "C" and test != 0 and serialFirst != serialTest: return 0 for conect in atomTest["connect"] : atomSecond = retrieveAtom.serial(conect , atomLigand) if atomSecond == 0 : return 0 elif atomSecond["element"] == "N" : flagNitrogen = flagNitrogen + 1 if flagNitrogen > 3 : return 0 else : continue elif atomSecond["element"] != "C" : return 0 if test == 0 : return 0 for serialConnect in atomTest["connect"][1:] : if serialConnect != serialPrevious : if cycleOnlyTestCarbon(serialFirst, serialConnect, serialTest, atomLigand, test - 1, flagNitrogen) == 1 : return 1 return 0
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 cycle3(serialFirst, serialTest, serialPrevious, atomLigand, test) : atomTest = retrieveAtom.serial(serialTest, atomLigand) if atomTest == 0 : return 0 if serialFirst in atomTest["connect"] and serialFirst != serialTest and serialFirst != serialPrevious : return 1 if test == 0 : return 0 for serialConnect in atomTest["connect"][1:] : if serialConnect != serialPrevious : if cycle3(serialFirst, serialConnect, serialTest, atomLigand, test - 1) == 1 : return 1 return 0
def anglePrimaryAmine(atomNitrogen, atomCounterIon, atomLigands): """Calcul for nitrogen and counter ion angles in: atom nitrogen, atom Counter Ions out: list of 2 angles""" matrix = atomNitrogen["connect"] if len(matrix) < 2: print "Atom does not 1 bonds !!" return else: carbon1 = retrieveAtom.serial(matrix[1], atomLigands) distanceNitrogenCounterIon = distanceTwoatoms(atomNitrogen, atomCounterIon) distanceCarbon1CounterIon = distanceTwoatoms(atomCounterIon, carbon1) distanceNitrogenCarbon1 = distanceTwoatoms(atomNitrogen, carbon1) angle1 = degrees(acos((distanceNitrogenCarbon1 * distanceNitrogenCarbon1 + distanceNitrogenCounterIon * distanceNitrogenCounterIon - distanceCarbon1CounterIon * distanceCarbon1CounterIon) / (2 * distanceNitrogenCarbon1 * distanceNitrogenCounterIon))) return [angle1]
atomLigand = loadFile.ligandInPDBConnectMatrixLigand(pdb, ligand) writePDBfile.globalStruct(ligand + "_" + pdb + ".pdb", atomLigand) nbAtom = len(atomLigand) # print atomLigand searchPDB.cycleGlobal(atomLigand) # print atomLigand listResult = [] for atom in atomLigand : if atom["element"] == "N" or atom["element"] == "O" or atom["element"] == "C": # impact point if atom["cycle"] == 1 : cycleRetrieve = retrieveAtom.cycle(atom, atomLigand) listResult.append(cycleRetrieve) continue for serialAtom in atom["connect"] : atomRetrieve = retrieveAtom.serial(serialAtom, atomLigand) if atomRetrieve == 0 : continue if atomRetrieve["cycle"] == 1 : cycleRetrieve = retrieveAtom.cycle(atom, atomLigand) listResult.append(cycleRetrieve) continue tool.checkListResult(listResult) nbStruct = 1 for element in listResult : writePDBfile.globalStruct(ligand + "_" + pdb + "_" + str(nbStruct) + ".pdb", element) nbStruct = nbStruct + 1 j = j + 1