def get_angles(angle,opls): """ Gets the angles from a given opls file and assigns them to the relevant angle objects from the parse file. Is a void method Keyword Arguments: angle - The list of angle objects to add attributes to opls - The opls angle objects from the opls file """ #PROBABLY SLIGHTLY INCORRECT TODO a_master = p.find_atom_by_id(angle.Angle_master).bond_id a_slave1 = p.find_atom_by_id(angle.Angle_slave1).bond_id a_slave2 = p.find_atom_by_id(angle.Angle_slave2).bond_id if a_slave1 == "" or a_slave2 == "": return for i in range(0,len(opls)): if a_slave1 <= a_slave2: oplsList = [a_slave1,a_master,a_slave2] if oplsList[0] == opls[i].angle_slave1 and oplsList[1] == opls[i].angle_master and oplsList[2] == opls[i].angle_slave2: angle.Angle_equib_len = opls[i].equib_len angle.Angle_force_const = opls[i].force_const elif a_slave2 < a_slave1: oplsList = [a_slave2,a_master,a_slave1] if oplsList[0] == opls[i].angle_slave2 and oplsList[1] == opls[i].angle_master and oplsList[2] == opls[i].angle_slave1: angle.Angle_equib_len = opls[i].equib_len angle.Angle_force_const = opls[i].force_const
def is181(atom,opls): number = 180 if atom.atom_type == "N": if atom.Num_Bonds == 3: if p.find_atom_by_id(atom.Atom_Bonds[0]).atom_type == "C" and p.find_atom_by_id(atom.Atom_Bonds[1]).atom_type == "C" and p.find_atom_by_id(atom.Atom_Bonds[2]).atom_type == "C": assign_atom_vars(atom,number,opls) return True return False
def is17(atom,opls): number = 16 if atom.atom_type == "C": if atom.Num_Bonds == 3: bondList = [p.find_atom_by_id(atom.Atom_Bonds[0]).atom_type,p.find_atom_by_id(atom.Atom_Bonds[1]).atom_type,p.find_atom_by_id(atom.Atom_Bonds[2]).atom_type] if "C" in bondList: bondList.remove("C") if "C" in bondList and "H" in bondList: assign_atom_vars(atom,number,opls)
def is10(atom,opls): number = 9 if atom.atom_type == "C": if atom.Num_Bonds == 4: bondList = [p.find_atom_by_id(atom.Atom_Bonds[0]),p.find_atom_by_id(atom.Atom_Bonds[1]),p.find_atom_by_id(atom.Atom_Bonds[2]),p.find_atom_by_id(atom.Atom_Bonds[3])] bondList.sort() if bondList[0].atom_type == "C" and bondList[1].atom_type == "H" and bondList[2].atom_type == "H" and bondList[3].atom_type == "H": assign_atom_vars(atom,number,opls) return True return False
def is13(atom,opls): number = 12 if atom.atom_type == "C" and atom.Num_Bonds == 4: bondList = [p.find_atom_by_id(atom.Atom_Bonds[0]).atom_type,p.find_atom_by_id(atom.Atom_Bonds[1]).atom_type,p.find_atom_by_id(atom.Atom_Bonds[2]).atom_type,p.find_atom_by_id(atom.Atom_Bonds[3]).atom_type] if "H" in bondList: bondList.remove("H") if "H" in bondList: bondList.remove("H") if "C" in bondList: bondList.remove("C") if "N" in bondList: assign_atom_vars(atom,number,opls) elif "C" in bondList: assign_atom_vars(atom,number,opls)
def get_bond(aBond,opls): """ Sets the equil_len and force constant for each bond. No returns, is void. Keyword Arguments: aBond - The list of bonds to set the opls values opls - The list of opls bond values created by getBonds """ master_id = p.find_atom_by_id(aBond.bond_master).bond_id slave_id = p.find_atom_by_id(aBond.bond_slave).bond_id if slave_id == "": return for i in range(0,len(opls)): if master_id == opls[i].bond_master and slave_id == opls[i].bond_slave: aBond.bond_force_const = opls[i].force_const aBond.bond_equib_len = opls[i].equib_len elif master_id == opls[i].bond_slave and slave_id == opls[i].bond_master: aBond.bond_force_const = opls[i].force_const aBond.bond_equib_len = opls[i].equib_len
def is178(atom,opls): number = 177 if atom.atom_type == "O" and atom.Num_Bonds == 1: if p.find_atom_by_id(atom.Atom_Bonds[0]).atom_type == "C": assign_atom_vars(atom,number,opls)
def is177(atom,opls): number = 176 if atom.atom_type == "C" and atom.Num_Bonds == 3: bondList = [p.find_atom_by_id(atom.Atom_Bonds[0]).atom_type,p.find_atom_by_id(atom.Atom_Bonds[1]).atom_type,p.find_atom_by_id(atom.Atom_Bonds[2]).atom_type] if "C" in bondList and "N" in bondList and "O" in bondList: assign_atom_vars(atom,number,opls)
def is26(atom,opls): number = 25 if atom.atom_type == "S" and atom.Num_Bonds == 2: if p.find_atom_by_id(atom.Atom_Bonds[0]).atom_type == "C" and p.find_atom_by_id(atom.Atom_Bonds[1]).atom_type == "C": assign_atom_vars(atom,number,opls)
opls_atoms = op.create_opls_atom(opls_atom_ids,opls_van,opls_partial) #op.print_opls_atoms(opls_atoms) opls_bonds = op.create_opls_bond(opls_bond) #op.print_opls_bonds(opls_bonds) opls_angles = op.create_opls_angle(opls_angle) #op.print_opls_angles(opls_angles) #get opls molecules for i in range(0,len(atom)): tm.get_molecule(atom[i],opls_atoms) #get opls bonds for i in range(0,len(bond)): if p.find_atom_by_id(bond[i].bond_master).atom_type == "H" or p.find_atom_by_id(bond[i].bond_slave).atom_type == "H": continue op.get_bond(bond[i],opls_bonds) #get opls angles for i in range(0,len(AngleList)): op.get_angles(AngleList[i],opls_angles) #print again to see the opls changes, this time printing the extra info #p.print_atoms(atom,True) #p.print_bonds(bond,True) #p.print_angles(AngleList,True) #count the atoms found earlier by get_molecule tester.count_atoms(opls_atoms,atom)