I'm writing a script in Python to be executed in PyMOL. Unfortunately I got stuck right at the beginning, when I'm trying to load .pdb's from "converged.nam" file. The relevant bit of the script is the following:

from pymol.cgo import *
from pymol import cmd

loadedStuff=open("converged.nam", 'r')
linie = loadedStuff.readlines()
for n in range(len(linie)): linie[n] = linie[n][:-1]
for n in range(len(linie)): print n, linie[n]
for n in linie: cmd.load(n,n)

Unfortunately, it is not working - I keep on getting:

0 compstatin.pdb_14
1 compstatin.pdb_72
2 compstatin.pdb_91
3 compstatin.pdb_93
4 compstatin.pdb_78
5 compstatin.pdb_34
6 compstatin.pdb_32
7 compstatin.pdb_7
8 compstatin.pdb_47
9 compstatin.pdb_31
10 compstatin.pdb_5
ExecutiveProcessPDBFile-Error: Unable to open file 'compstatin.pdb_14'.
Traceback (most recent call last):
  File "/usr/local/pymol/modules/pymol/parsing.py", line 407, in run_file
  File "align.py", line 8, in ?
    for n in linie: cmd.load(n,n)
  File "/usr/local/pymol/modules/pymol/importing.py", line 575, in load
    if _raising(r): raise pymol.CmdException
CmdException: <pymol.CmdException instance at 0x56fdc6cc>

When I manually form a list containing all the compstatin entries than it is working, so it must be something with how it processes the list which it gets from the file. I can't really understand why that is so, especially given how it correctly pronts out the content of the list that captures the content of the file. I am obviously making some silly mistake here... any suggestions?

Thank you,
Mateusz Maciejewski


Mateusz Maciejewski,
University of Edinburgh
Joseph Black Chemistry Bldg, West Mains Rd.,
Edinburgh EH9 3JJ, U.K.
Phone (44) (0) 131 650 4704 (group office)