Hello pyMol Users,

I have recently started working with pyMol. Here is my script, which one of the 
users (I am not sure whether it is right or not to write the name) has helped 
me to fix:

import os
from pymol import cmd
cmd.reinitialize()
myDir = '/Users/User/myFolder'
#print(myDir)
for filename in os.listdir(myDir):
        print('HERE FILENAME is' , filename)
        if os.access(filename, os.R_OK):
                #check whether file exists and readable
                if ‘cif' in filename:
                        #only cif format is needed
                        cmd.load (filename)
                        obj_name = os.path.splitext(filename)[0]
                        filenameN = obj_name + '.mol'
                        cmd.save(filenameN, obj_name)
                        cmd.delete(obj_name)


Here is the mistake log:

File 
"/usr/local/Cellar/pymol/1.7.2.1/libexec/lib/python2.7/site-packages/pymol/importing.py",
 line 819, in load
    _processCIF(cif,oname,state,quiet,discrete,_self)
  File 
"/usr/local/Cellar/pymol/1.7.2.1/libexec/lib/python2.7/site-packages/pymol/importing.py",
 line 409, in _processCIF
    for i, rec in enumerate(cif):
  File 
"/usr/local/Cellar/pymol/1.7.2.1/libexec/lib/python2.7/site-packages/chempy/cif.py",
 line 671, in next
    rec = CIFRec(self.datablocks_it.next())
  File 
"/usr/local/Cellar/pymol/1.7.2.1/libexec/lib/python2.7/site-packages/chempy/cif.py",
 line 226, in __init__
    self.read_chem_comp_bond()
  File 
"/usr/local/Cellar/pymol/1.7.2.1/libexec/lib/python2.7/site-packages/chempy/cif.py",
 line 575, in read_chem_comp_bond
    if self.read_chem_comp_bond_atom_ids(None, loop.keys, loop.rows):
  File 
"/usr/local/Cellar/pymol/1.7.2.1/libexec/lib/python2.7/site-packages/chempy/cif.py",
 line 557, in read_chem_comp_bond_atom_ids
    name_dict[self.index_to_str(label_2,value)]]

KeyError: ‘AtomName’

#atom name, e.g. ‘O’, ‘H2'


Selector-Error: Invalid selection name «obj_name".
(obj_name)<--
Traceback (most recent call last):
  File 
"/usr/local/Cellar/pymol/1.7.2.1/libexec/lib/python2.7/site-packages/pymol/parsing.py",
 line 452, in run_file
    execfile(file,global_ns,local_ns)
  File 
"/usr/local/Cellar/pymol/1.7.2.1/libexec/lib/python2.7/site-packages/pymol/parsing.py",
 line 447, in execfile
    b.execfile(filename, global_ns, local_ns)
  File "/Users/User/pyMolScript.py", line 13, in <module>
    cmd.save(filenameN, obj_name)
  File 
"/usr/local/Cellar/pymol/1.7.2.1/libexec/lib/python2.7/site-packages/pymol/exporting.py",
 line 626, in save
    io.mol.toFile(_self.get_model(selection,state,ref,ref_state),filename)

  File 
"/usr/local/Cellar/pymol/1.7.2.1/libexec/lib/python2.7/site-packages/pymol/querying.py",
 line 1064, in get_model
    if _raising(r,_self): raise pymol.CmdException

CmdException:  Error: None

Can you, please, tell how to fix this? And, if possible, what caused the 
mistake?

Thank you,

Best Regards,

Alsa


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