AE, 

you need to delete the loaded file before loading another. cmd.save will save 
ALL objects in the buffer by default as you have experienced yourself. Also 
your handling of the filename is slightly off, since pymol strips the extender 
upon loading, i.e. "test01.pdb" becomes "test01" object. You have two choices 
here, either you can retain all files in the buffer (not sure if this is your 
intention) or use Pymol as a file converter (you could use BABEL for that as 
well, might work better ?!). This is how I would write the code (untested 
however):

cmd.reinitialize()
myDir = ‘/dirWithFiles'

for filename in os.listdir(myDir):
        cmd.load (filename)
        obj_name = os.path.splitext(filename)[0]
        filenameN = obj_name + '.mol'
        cmd.save(filename, obj_name)
        cmd.delete(obj_name)    # comment out this line of you want to keep all 
files in the buffer


-----Original Message-----
From: AE [mailto:alsalisb...@yahoo.com] 
Sent: Saturday, June 06, 2015 5:54 AM
To: pymol-users@lists.sourceforge.net
Subject: Re: [PyMOL] How to forbid merging of files?

Good day,

I have several thousands of files, which I upload using the loop:

myDir = ‘/dirWithFiles'
for filename in os.listdir(myDir):
        cmd.load (filename)
        filenameN = os.path.splitext(filename)[0]
        cmd.save(filenameN + '.mol')
        cmd.disable(filename)

I am trying to save them one by one in a different (.mol) format. However, the 
files are saved together, i.e.: first file opened contains only molecule from 
the first file; second: first + second; third: first + second + third etc. But 
I want firstFile.readableFormat to be converted into firstFile.mol, 
secondFile.readableFormat - secondFile.mol etc, without any addition of other 
files. How can I do that?

Thank you,

Best Regards,

Alsa

Sorry I have sent it already, accidentally forgot to finish the question in 
subject(
------------------------------------------------------------------------------
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
------------------------------------------------------------------------------
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to