Sorry - I should probably use "i" at some point in the loop :-)

import pybel
for i, mol in enumerate("smi", "testfile.smi"):
  mol.write("mol2", "output%d.mol2" % i, overwrite=True)


On 4 January 2012 14:03, Noel O'Boyle <baoille...@gmail.com> wrote:
> How about using Python's enumerate function as follows:
>
> import pybel
> for i, mol in enumerate("smi", "testfile.smi"):
>  mol.write("mol2", mol.title + ".mol2", overwrite=True)
>
> On 4 January 2012 13:36, Cyberbroker1 <rene.buett...@rwth-aachen.de> wrote:
>> Thank you very much.
>>
>> You understand me exactly! Its perfect!
>>
>> Now im just wondering how i could make the command line prompt for
>> openbabel:
>>
>> obabel -ismi - testfile.smi -omol -m O output.mol
>>
>> into a pyhton script. That would make everything much much faster and
>> easier.
>>
>> import pybel
>> mymol = list(pybel.readfile("smi","testfile.smi")).next # and heres my
>> problem
>> mymol.write('mol','output1.mol')
>>
>>
>> #my problem: How do i can call the other molecules in the file besides the
>> first one?
>>
>> --
>> View this message in context: 
>> http://forums.openbabel.org/one-input-file-multiple-output-files-tp4254723p4261260.html
>> Sent from the General discussion mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------------------------------
>> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
>> infrastructure or vast IT resources to deliver seamless, secure access to
>> virtual desktops. With this all-in-one solution, easily deploy virtual
>> desktops for less than the cost of PCs and save 60% on VDI infrastructure
>> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
>> _______________________________________________
>> OpenBabel-discuss mailing list
>> OpenBabel-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to