def mol_graph_to_schrodinger_struct(mol_graph: MoleculeGraph): """ Convert a pymatgen MoleculeGraph object to a Schrodinger Structure object Args: mol_graph (pymatgen.analysis.graphs.MoleculeGraph): MoleculeGraph to be converted Returns: struct: schrodinger.structure.Structure object """ struct = create_new_structure(num_atoms=0) for site in mol_graph.molecule: symbol = site.specie.name pos = site.coords struct.addAtom(symbol, pos[0], pos[1], pos[2]) for atom in struct.atom: atom.formal_charge = 0 struct.atom[1].formal_charge = mol_graph.molecule.charge # Credit to Xiaowei Xie for edge in mol_graph.graph.edges.data(): struct.addBond(edge[0] + 1, edge[1] + 1, 1) return struct
def __init__(self, pv_file = None): self.distances = red_black_tree() self.min_res = None self.max_res = None self.pv_file = pv_file if self.pv_file is not None: self.get_receptor_structure() else: self.receptor = structure.create_new_structure() self.fingerprints = sift_gen(self.receptor)
def split_protein_protein_complex(st_path): st = structure.StructureReader(st_path).next() chains = [c for c in st.chain] print chains antibody = structure.create_new_structure() antibody.title = '%s_antibody' %(st.title) antigen = structure.create_new_structure() antigen.title = '%s_antigen' %(st.title) for chain in chains: # considering this chain for a in st.chain[chain.name].atom: #if a.bond_total == 0:continue if chain.name in 'HLAB':# it is antibody antibody.addAtom(a.element,a.x,a.y,a.z,a.color,a.atom_type) else: antigen.addAtom(a.element,a.x,a.y,a.z,a.color,a.atom_type) antibody.write('%s.pdb' %antibody.title) antigen.write('%s.pdb' %antigen.title) return antigen, antibody
def ase_atoms_to_structure(atoms): """ Convert an ase atoms instance into a structure instance """ #print("atoms[0]: ", atoms[0]) # for i in range(0, atoms.get_number_of_atoms()): # print("atoms[%d]: %s"%(i, atoms[i])) st = create_new_structure() elements = list(map(mm.mmat_get_element_by_atomic_number, atoms.get_atomic_numbers())) carts = atoms.get_positions() natoms = len(atoms) for iat in range(natoms): st.addAtom(elements[iat], carts[iat, 0], carts[iat, 1], carts[iat, 2]) if all(atoms.get_pbc()): unit_cell = atoms.get_cell() abc_keys = [ xtal.Crystal.CHORUS_BOX_A_KEYS, xtal.Crystal.CHORUS_BOX_B_KEYS, xtal.Crystal.CHORUS_BOX_C_KEYS, ] # lattice vecs are rows of ASE unit cell for ivec, abc_key in enumerate(abc_keys): for jvec, key in enumerate(abc_key): st.property[key] = unit_cell[ivec, jvec] # tell xtal this is P1 xtal.make_p1(st, in_place=True) maximally_bonded, bonds, pbc_bonds = xtal.connect_atoms(st) st.property[xtal.PBC_POSITION_KEY] = xtal.ANCHOR_PBC_POSITION % ('0', '0', '0') st_out = xtal.get_cell( st, xtal_kwargs={'bonding': 'on', 'bond_orders': 'off', 'translate': 'off'} ) #print("maximally_bonded", maximally_bonded) #print("bonds", bonds) #print("pbc_bonds", pbc_bonds) #print(st_out.getXYZ()) return st_out
def read_structure(conn): """ Read a structure from the particle and bond tables of a database connection. Returns a schrodinger.structure.Structure object. The atoms get properties added with their database id and their sigma and epsilon parameters. """ st = structure.create_new_structure() c = conn.cursor() atoms = {} for id, anum, x, y, z, sigma, epsilon, formal_charge in c.execute( "select particle.id, anum, x, y, z, sigma, epsilon, formal_charge " "from particle, nonbonded_param " "where particle.nbtype==nonbonded_param.id"): el = mm.mmat_get_element_by_atomic_number(anum) atom = atoms[id] = st.addAtom(el, x, y, z) atom.property[FORMAL_CHARGE_PROP] = formal_charge atom.property[ID_PROP] = id atom.property[SIGMA_PROP] = sigma atom.property[EPSILON_PROP] = epsilon for p0, p1, order in c.execute('select p0, p1, "order" from bond'): st.addBond(atoms[p0], atoms[p1], int(order)) return st
def read_structure(conn): """ Read a structure from the particle and bond tables of a database connection. Returns a schrodinger.structure.Structure object. The atoms get properties added with their database id and their sigma and epsilon parameters. """ st = structure.create_new_structure() c = conn.cursor() atoms = {} for id, anum, x, y, z, charge in c.execute( "select particle.id, anum, x, y, z,charge " "from particle, nonbonded_param " "where particle.nbtype==nonbonded_param.id"): el = mm.mmat_get_element_by_atomic_number(anum) atom = atoms[id] = st.addAtom(el, x, y, z) atom.property[CHARGE] = charge atom.property[ID_PROP] = id for p0, p1, order in c.execute('select p0, p1, "order" from bond'): st.addBond(atoms[p0], atoms[p1], int(order)) return st
def get_receptor_structure(self): if os.path.exists(self.pv_file): self.receptor = structure.StructureReader(self.pv_file).next() else: self.receptor = structure.create_new_structure()