T , 2012-05-23 16:06 +0200, Hitesh Patel rakstīja:
> How can I join two molecules at specified atoms. These joining atoms might
> have same Index numbers, because two joining atoms are in different
> molecules.

It goes along these lines:

builder = ob.OBBuilder()
# Use ring conformations from existing 3D coordinates
builder.SetKeepRings()
# Copy molecule if necessary
mol = ob.OBMol(parent)
# Disable charge perception if desired
mol.SetAutomaticPartialCharge(False)
# Remember the size of molecule
n = mol.NumAtoms()
# Add second molecule
mol += mol2
# Copy over any extra residue info from mol2 if necessary, since +=
# doesn't do it for you.
# Figure out the numbers for atoms in connection
a = n
b = n + 5 # 5th atom in mol2
# There are alternatives to this, e.g., finding atom by name.
# Atom names are stored in residues, so first get the residue
res = mol.GetResidue(mol.NumResidues()-2)
for i in ob.OBResidueAtomIter(res):
    if res.GetAtomID(i) == aname:
        a = i.GetIdx()
        break
# The same for the second atom
res = mol.GetResidue(mol.NumResidues()-1)
for i in ob.OBResidueAtomIter(res):
    if res.GetAtomID(i) == bname:
        b = i.GetIdx()
        break
# Connect the fragments
builder.Connect(mol, a, b)


Reinis


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
OpenBabel-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to