[Chimera-users] PDB file opens from chimera GUI but not from python script ( )

Nikolaos Bismpikos nikolaosbismpikos at gmail.com
Wed Jun 7 09:42:36 PDT 2017


Hello, I am having a problem with trying to open a .pdb file using a python
script.

The file opens and the protein structure is displayed properly when I open
the file using the Chimera GUI. However, when I try to run the code from a
python script, using the demo script for looping through .pdb files I get
the following error:

----------------------------------------------------------------------

File "/home/nick/.local/UCSF-Chimera64-1.11.2/lib/python2.7/re.py", line
251, in _compile
    raise error, v # invalid expression

----------------------------------------------------------------------
This is the code I am trying to run:
----------------------------------------------------------------------

import sys
import os
from chimera import runCommand as rc # use 'rc' as shorthand for runCommand
from chimera import replyobj # for emitting status messages

# change to folder with data files
os.chdir("/home/nick/Python/pdb")
print >> sys.stdout, retval

# gather the names of .pdb files in the folder
file_names = [fn for fn in os.listdir(".") if fn.endswith(".pdb")]

# loop through the files, opening, processing, and closing each in turn
for fn in file_names:
    replyobj.status("Processing " + fn) # show what file we're working on
    rc("open " + fn)
    replyobj.status("Opened " + fn) # show what file we're working on
    rc("align ligand ~ligand") # put ligand in front of remainder of
molecule
    rc("focus ligand") # center/zoom ligand
    rc("surf") # surface receptor
    rc("preset apply publication 1") # make everything look nice
    rc("surftransp 15") # make the surface a little bit see-through
    # save image to a file that ends in .png rather than .pdb
    png_name = fn[:-3] + "png"
    rc("copy file " + png_name + " supersample 3")
    rc("close all")

----------------------------------------------------------------------

The error in more detail, including the traceback from the terminal is the
following:

----------------------------------------------------------------------

Processing prediction[NoEnergy-K:0-BS:0.00]-21(20.310186).pdb

Traceback (most recent call last):
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/share/chimeraInit.py", line
683, in init
    chimera.openModels.open(a, prefixableType=1)
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/share/chimera/__init__.py",
line 1929, in open
    models = func(filename, *args, **kw)
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/share/chimera/__init__.py",
line 1299, in _openPython
    loadFunc(sandboxName, fileName, f)
  File "test1.py", line 23, in <module>
    rc("open " + fn)
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/share/chimera/__init__.py",
line 2747, in runCommand
    makeCommand(*args, **kw)
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/share/Midas/midas_text.py",
line 69, in makeCommand
    f(c, args)
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/share/Midas/midas_text.py",
line 1552, in doOpen
    paths = testPath(text, wildcarding)
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/share/Midas/midas_text.py",
line 1538, in testPath
    return glob(expanded)
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/lib/python2.7/glob.py",
line 27, in glob
    return list(iglob(pathname))
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/lib/python2.7/glob.py",
line 49, in iglob
    for name in glob1(os.curdir, basename):
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/lib/python2.7/glob.py",
line 83, in glob1
    return fnmatch.filter(names, pattern)
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/lib/python2.7/fnmatch.py",
line 56, in filter
    _cache[pat] = re_pat = re.compile(res)
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/lib/python2.7/re.py", line
194, in compile
    return _compile(pattern, flags)
  File "/home/nick/.local/UCSF-Chimera64-1.11.2/lib/python2.7/re.py", line
251, in _compile
    raise error, v # invalid expression
error: bad character range

Error while processing test1.py:
error: bad character range

  File "/home/nick/.local/UCSF-Chimera64-1.11.2/lib/python2.7/re.py", line
251, in _compile
    raise error, v # invalid expression

See reply log for Python traceback.


----------------------------------------------------------------------
The error obviously appears at the 2nd line of the for loop (  rc("open " +
fn) )

Any tips on why this might happen? I am using Ubuntu 14.04 LTS and the
Chimera version I installed is chimera-1.11.2-linux_x86_64.bin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20170607/3e95e7e6/attachment.html>


More information about the Chimera-users mailing list