def create_atomobj(atomList): """ Create a bunch of atom objects based on the cml file. Returns a list of atom objects Keyword Arguments: atomList -- The list of atoms found in the cml file to pass in and split """ for i in range(0, len(atomList)): atoms.append(help.get_atoms(atomList,i)) aList = help.object_list(atoms[i]) atom.append(Atom(aList[0],aList[1],aList[2],aList[3],aList[4])) return atom
def create_bondobj(bondList): """ Create a bunch of bond objects based on the cml file. Returns a list of bond objects Keyword Arguments: bondList -- The list of bonds found in the cml file to pass in and split """ for j in range(0, len(bondList)): bonds.append(help.get_atoms(bondList,j)) bList = help.bond_list(bonds[j]) newBond = Bond(bList[0],bList[1],bList[2]) bond.append(newBond) fromAtom = find_atom_by_id(bList[1]) toAtom = find_atom_by_id(bList[2]) fromAtom.Atom_Bonds.append(bList[2]) toAtom.Atom_Bonds.append(bList[1]) return bond
#constructor def __init__(self, bond_type, bond_master, bond_slave): self.bond_type = bond_type self.bond_master = bond_master self.bond_slave = bond_slave #begin parsing, gets single atom. do in method tree = ET.parse(file) root = tree.getroot() atomList = root.findall('./atomArray/atom') bondList = root.findall('./bondArray/bond') #create a bunch of atoms objects for i in range(0, len(atomList)): atoms.append(help.get_atoms(atomList,i)) aList = help.object_list(atoms[i]) atom.append(Atom(aList[0],aList[1],aList[2],aList[3],aList[4])) print " ATOMS " print "-----------" for k in range(0, len(atom)): print "Atom id: %s" % atom[k].atom_id print "Atom type: %s" % atom[k].atom_type print "X position: %s" % atom[k].x_pos print "Y position: %s" % atom[k].y_pos print "Z position: %s" % atom[k].z_pos print "" #create a bunch of bond objects for j in range(0, len(bondList)):