Python |
PyDaylight | Acquire the pydaylight-1.0.tar.gz archive. |
---|---|
% gzip -dc pydaylight-1.0.tar.gz | tar xf - % cd pydaylight-1.0/ % more README % python setup.py build % su root # python setup.py install |
PyDaylight cansmi.py |
#!/usr/bin/env python import string, sys from daylight import Smiles, DaylightError def main(argv): while 1: line = sys.stdin.readline() if not line: break smi = string.split(line[:-1])[0] try: mol = Smiles.smilin(smi) s = mol.cansmiles(1) print s except DaylightError, msg: print "Can't make unique SMILES for %s: %s" % (repr(smi), msg) if __name__ == "__main__": main(sys.argv) |
---|---|
% echo "OCC" | python cansmi.py CCO | |
Component Exploration |
% python ... >>> from daylight import Smiles, DaylightError >>> print Smiles.__doc__ Given a SMILES string, create a Molecule or Reaction from daylight import Smiles mol = Smiles.smilin("c1ccccc") rxn = Smiles.smilin("C[13CH2]OC1CCC(O1)(C=O)C(C)CC>CC(O)C>CCC(C)c1ccco1") >>> dir(Smiles) ['Molecule', 'Reaction', 'TYP_MOLECULE', 'TYP_REACTION', '__builtins__', '__doc__', '__file__' , '__name__', 'daylight', 'dt_smilin', 'dt_smilin_addh', 'dt_type', 'smart_ptr', 'smilin', 'smilin_addh'] >>> Smiles.dt_smilin <built-in function dt_smilin> >>> Smiles.smilin("c1ccccc") Traceback (most recent call last): File "<stdin>", line 1, in ? File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/daylight/Smiles.py", line 62, in smilin raise daylight.BadFormat, msg daylight.BadFormat: ERROR: Unclosed ring: 1 (dy_parse_smiles) |