Hi Tsjerk,

I am getting two errors. Is there a problem with line endings? I am taking the code in emails and on the wiki and pasting it into a text editor (BBEdit), then copying that and pasting into the PyMOL command line. The text editor is saving the text with Unix (LF) which I take to mean Line Feeds.

Here is what PyMOL says -

PyMOL>def ssfilter(sslist):\
PyMOL> i=1\
PyMOL> j=len(sslist)-1\
PyMOL> while i<j:\
PyMOL> if sslist[i][2] == sslist[i+1][2]:\
PyMOL> sslist.pop(i)\
PyMOL> j = j - 1\
PyMOL> else:\
PyMOL> i=i+2\
PyMOL> return sslist
Traceback (most recent call last):
  File "/home/local/warren/MacPyMOL070703/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py", line 257, in parse
  File "<string>", line 2
      i=1
     ^
SyntaxError: invalid syntax
PyMOL>sslist=[]
PyMOL>cmd.iterate("n. ca", "sslist.append( [resn,resi,ss] )" )
PyMOL>print ssfilter( sslist )
Traceback (most recent call last):
  File "/home/local/warren/MacPyMOL070703/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py", line 456, in parse
  File "<string>", line 1, in ?
NameError: name 'ssfilter' is not defined 



Note that when I copy and paste from your email directly, I get a different error.

Traceback (most recent call last):
  File "/home/local/warren/MacPyMOL070703/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py", line 257, in parse
  File "<string>", line 1
     def ssfilter(sslist):\
                            ^
SyntaxError: invalid token 

That's what prompted me to use the text editor, as it looks like a line ending problem.

Frieda

On Oct 9, 2007, at 9:07 AM, Tsjerk Wassenaar wrote:


Hi Frieda,

The slash should tell Pymol that the following should be parsed as python code, but it should work without too, since "while" is a python keyword. The output you show bothers me. For my case it gives:

[['PRO', '7', 'L'], ['ASP', '8', 'L'], ['PRO', '9', 'H'], ['ALA', '16', 'H'], ['LEU', '17', 'L'], ['LEU', '26', 'L'],...

which seems to correspond to what you want. In your case the list "sslist" seems to remain unchanged in the while loop, suggesting the loop didn't execute.
Maybe a small rewrite:

def ssfilter(sslist):\
  i=1\
  j=len(sslist)-1\
  while i<j:\
    if sslist[i][2] == sslist[i+1][2]:\
      sslist.pop(i)\
      j = j - 1\
    else:\
      i=i+2
\
  return sslist

sslist=[]
cmd.iterate("n. ca", "sslist.append( [resn,resi,ss] )" )
print ssfilter( sslist )


Hope it helps (hope it works :S),

Tsjerk

On 10/9/07, Frieda Reichsman <friedar@nsm.umass.edu > wrote:
Hi Tsjerk,

Note the "/" in front of "while", throws an error, I removed it and got a readout like the following, for each object in the file.

[['MET', '1', 'S'], ['GLN', '2', 'S'], ['VAL', '3', 'S'], ['PHE', '4', 'S'], ['ILE', '5', 'S'], ['MET', '6', 'S'], ['ARG', '7', 'S'], ...

Thanks,
Frieda

On Oct 9, 2007, at 8:36 AM, Tsjerk Wassenaar wrote:

Hi Frieda,

Okay, caught a flaw in the script. Try:

sslist=[]
cmd.iterate("n. ca", "sslist.append( [resn,resi,ss] )" )
i=1
j=len(sslist)-1
/while i<j:\
  if sslist[i][2] == sslist[i+1][2]:\
    sslist.pop(i)\
    j = j - 1\
  else:\
    i=i+2

print sslist

#---
Cheers,

Tsjerk

On 10/9/07, Frieda Reichsman <friedar@nsm.umass.edu> wrote:
Hi Tsjerk,

When I paste your script into the command line of PyMol (MacPyMol to be exact), this is the response:

Traceback (most recent call last):
  File "/home/local/warren/MacPyMOL070703/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py", line 456, in parse
  File "<string>", line 2
     iterate n. ca, sslist.append( [resn,resi,ss] )
             ^
SyntaxError: invalid syntax 

Is there a way to correct this? (BTW, I am not a python scripter. I have some experience with javascript, so I see some similarity, but the syntax is probably going to evade me).

Thanks,
Frieda

On Oct 9, 2007, at 3:35 AM, Tsjerk Wassenaar wrote:

Hi Frieda,

In addition to my previous mail, the following works for me:

sslist=[]
iterate n. ca, sslist.append( [resn,resi,ss] )

/i=1, j=len(sslist)-1
/while i<j:\
  if sslist[i][2] == sslist[i+1][2]:\
    sslist.pop[i]\
    j = j - 1\
  else:\
    i=i+2

Hope it helps,

Tsjerk

On 10/9/07, Tsjerk Wassenaar < tsjerkw@gmail.com> wrote:
Hi Frieda,

There's no such command. You'll have to parse the output you get through a script which filters it in the way you want. This isn't difficult though (good python exercise :p).

Best,

Tsjerk

On 10/9/07, Frieda Reichsman < friedar@nsm.umass.edu> wrote:
Hi,

I would like to get secondary structure information from a PyMOL file. I searched the list and found this:


> I need a list of the secondary structure assigned to each residue by dss in
> pymol. Is there a simple way to write this information to a file, or dump it
> to the screen?

To dump it to the screen, try:

iterate <object name> & n. ca, print resn,resi,ss

and it works, but the output is a long list of every residue. Is there a command to get the output more succinctly, such as

1-5 L
6-10 H
11-15 S

Thanks,
Frieda

///////////////////////////////////////////

Frieda Reichsman
Molecules in Motion
Interactive Molecular Structures

///////////////////////////////////////////



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
PyMOL-users mailing list
PyMOL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pymol-users




--
Tsjerk A. Wassenaar, Ph.D.
Junior UD (post-doc)
Biomolecular NMR, Bijvoet Center
Utrecht University
Padualaan 8
3584 CH Utrecht
The Netherlands
P: +31-30-2539931    
F: +31-30-2537623



--
Tsjerk A. Wassenaar, Ph.D.
Junior UD (post-doc)
Biomolecular NMR, Bijvoet Center
Utrecht University
Padualaan 8
3584 CH Utrecht
The Netherlands
P: +31-30-2539931    
F: +31-30-2537623

///////////////////////////////////////////

Frieda Reichsman
Molecules in Motion
Interactive Molecular Structures

///////////////////////////////////////////





--
Tsjerk A. Wassenaar, Ph.D.
Junior UD (post-doc)
Biomolecular NMR, Bijvoet Center
Utrecht University
Padualaan 8
3584 CH Utrecht
The Netherlands
P: +31-30-2539931    
F: +31-30-2537623

///////////////////////////////////////////

Frieda Reichsman
Molecules in Motion
Interactive Molecular Structures

///////////////////////////////////////////





--
Tsjerk A. Wassenaar, Ph.D.
Junior UD (post-doc)
Biomolecular NMR, Bijvoet Center
Utrecht University
Padualaan 8
3584 CH Utrecht
The Netherlands
P: +31-30-2539931    
F: +31-30-2537623

///////////////////////////////////////////


Frieda Reichsman

Molecules in Motion

Interactive Molecular Structures

http://www.moleculesinmotion.com


///////////////////////////////////////////