From: Tsjerk W. <ts...@gm...> - 2010-03-09 10:53:27
|
I never get used to Pymol doing reply-to-sender in stead of reply-to-list.... :| ---------- Forwarded message ---------- From: Tsjerk Wassenaar <ts...@gm...> Date: Tue, Mar 9, 2010 at 11:51 AM Subject: Re: [PyMOL] succinct secondary structure 'readout' To: Ferdinand Alte <fer...@ch...> Hi Ferdi, Maybe this works better... Save the code below as ss.py and in pymol issue 'run ss.py'. Do make sure to have the path right. In your mail you had a path with both \ and /, which might have caused problems. After having run the script, you'll have a new command, and you can say do 'ss' to get the list for everything or 'ss c. A' to get the list only for chain A. Note that there is no check for chain breaks. If you do something like 'ss ss h' you'll just get one line, which in my case said '56-435 H'. :p Anyone feeling for it, may complicate the code by adding checks for chain breaks and such. Yes, this _is_ just a hack :) Hope it helps, Tsjerk #-----------ss.py---------- def ss(selection="all"): l = [(i.resi,i.ss) for i in cmd.get_model(selection+" and n. ca").atom] ss = [[l[0][0],l[0][0],l[0][1]]] for i in l: if i[1] == ss[-1][2]: ss[-1][1] = i[0] else: ss.append([i[0],i[0],i[1]]) print "\n".join(["%s-%s %s" % (i[0],i[1],i[2] or "L") for i in ss]) cmd.extend("ss", ss) On Tue, Mar 9, 2010 at 8:59 AM, Ferdinand Alte <fer...@ch...> wrote: > Hi, > > > > I would like to get secondary structure information from a PyMol file. I > know that the following command gives a long list of every residue: > > > >>> iterate <object name> & n. ca, print resn,resi,ss > > > > > > I found the following script, that gives you a more “condensed” list (see > below): > > > > > >>> PyMOL>@../..\ss.pml > >>> PyMOL>class SSList:\ > >>> PyMOL>list = []\ > >>> PyMOL>def purge( self, resi, ss ):\ > >>> PyMOL>if not self.list or self.list[-1][0] != ss:\ > >>> PyMOL>self.list.append( [ss, resi, resi ] )\ > >>> PyMOL>else:\ > >>> PyMOL>self.list[-1][2] = resi\ > >>> PyMOL>def __repr__( self ):\ > >>> PyMOL>return "\n".join( map( self.repr_item, self.list ) )\ > >>> PyMOL>def repr_item( self, item ):\ > >>> PyMOL>return item[0]+" ("+item[1]+"-"+item[2]+")" > >>> PyMOL>sslist = SSList() > >>> PyMOL>cmd.iterate( "n. ca", "sslist.purge( resi, ss )" ) > >>> PyMOL>print sslist > >>> L (2-3) > >>> H (4-14) > >>> L (15-23) > >>> H (24-44) > >>> L (45-50) > >>> H (51-72) > >>> L (73-73) > >>> H (74-84) > >>> L (85-86) > > > > I have two problems: the command >> PyMOL>@../..\ss.pml << gives the > following answer in PyMol: “No such file or directory” > > When I leave this command away, and I copy & paste the initial iteration > followed by the script, > > > > iterate SH3 & n. ca, print resn,resi,ss > > class SSList:\ > > list = []\ > > def purge( self, resi, ss ):\ > > if not self.list or self.list[-1][0] != ss:\ > > self.list.append( [ss, resi, resi ] )\ > > else:\ > > self.list[-1][2] = resi\ > > def __repr__( self ):\ > > return "\n".join( map( self.repr_item, self.list ) )\ > > def repr_item( self, item ):\ > > return item[0]+" ("+item[1]+"-"+item[2]+")" > > sslist = SSList() > > cmd.iterate( "n. ca", "sslist.purge( resi, ss )" ) > > print sslist > > > > > > PyMol gives me the following answer: > > > > Iterate: iterated over 68 atoms. > > <pymol.SSList instance at 0x000000000688C648> > > > > > > I still get the long list with every single residue mentioned, but not the > desired “condensed” form. > > Maybe I just don’t know how to print the list on the screen. Or is there > more about it? > > > > > > Thanks for any help, > > > > Ferdi > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > PyMOL-users mailing list (PyM...@li...) > Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users > Archives: http://www.mail-archive.com/pym...@li... > -- Tsjerk A. Wassenaar, Ph.D. Computational Chemist Medicinal Chemist Neuropharmacologist -- Tsjerk A. Wassenaar, Ph.D. Computational Chemist Medicinal Chemist Neuropharmacologist |