Hi, 
Am Freitag, den 18.02.2011, 17:43 +0000 schrieb JP:

> I have a set of molecules in a mol2 file (DUD set) and I would like to
> read them ALL at one go (MolFromMol2File gives me only one molecule,
> possible the first).
> 
> 
> Any ideas how to do this solely with RDKit ?
simply use python for this task.
attached is a example script where you possibly have to adapt the
delimiter.

regards 
uwe


import rdkit.Chem

def RetrieveMol2Block(fileLikeObject, delimiter="@<TRIPOS>MOLECULE"):
    """generator which retrieves one mol2 block at a time
    """
    mol2 = []
    for line in fileLikeObject:
        if line.startswith(delimiter) and mol2:
            yield "".join(mol2)
            mol2 = []
        mol2.append(line)
    if mol2:
        yield "".join(mol2)

if __name__ == "__main__":
    import sys
    import rdkit.Chem.Descriptors as descr
    with open(sys.argv[1]) as fi:
        for mol2 in RetrieveMol2Block(fi):
            rdkMolecule = rdkit.Chem.MolFromMol2Block(mol2)
            print descr.MolWt(rdkMolecule)
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to