Hi,

Given a directory that your files are in, called "input_dir" the
following should start an iteration over all files called
output<something>.mol2.

filtered_files = filter(lambda x:
(os.path.basename(x).lower().startswith("output") and
(os.path.splitext(x)[1].lower() == ".mol2")), os.listdir(input_dir))
for file in filtered_files:


Hope that helps,

Toby Wright


--
InhibOx

On 4 January 2012 12:38, Noel O'Boyle <baoille...@gmail.com> wrote:
> If I understand correctly, then something like...
>
> import pybel
> for i in range(1,100):
>  inputfile = "output%d.mol2" % i
>  mol = pybel.readfile("mol2", inputfile).next()
>  mol.write("mol2", mol.title + ".mol2", overwrite=True)
>
> On 4 January 2012 12:27, Cyberbroker1 <rene.buett...@rwth-aachen.de> wrote:
>> great, thank you again^^
>>
>> But there is still one problem left.
>>
>> import pybel
>> for mol in pybel.readfile("mol2", "-output1.mol2"): # I will have plenty of
>> "outputX.mol2" files
>>        filename = mol.OBMol.GetTitle()
>>        filename = filename + ".mol2"
>>        output = open(filename,"w") # erase existing file, if any
>>        output.write(mol.write("mol2"))
>>        output.close()
>>
>> I know that it will be done with some kind of loop, but i have no idea how
>> to programm it.
>>
>> Best
>>
>> Cy
>>
>> --
>> View this message in context: 
>> http://forums.openbabel.org/one-input-file-multiple-output-files-tp4254723p4261039.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

------------------------------------------------------------------------------
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