Hi everyone, How to write PyMol commands in Python script, save a session and then save a .png file of the same ? I have an input file which has the protein information i.e name, chain, and a list of residues. I want to plot the C-alpha atoms of these residues for each protein & calculate distances between this set of atoms, save these operations in a .pse file and also a .png file of the same. Below, I am writing all the commands which I use in PyMol.
However, I am having trouble automating this procedure for a large number of proteins. ***Input file [testpy.txt](Fields: PDB ID, chain, residue1, residue2, residue3*** 2YYI.pdb A 13 28 30 2YYG.pdb A 45 42 67 . . . . ***PyMol Commands*** 1) load 2YYI.pdb 2) hide everything 3) show cartoon 4) set cartoon_transparency, 0.8 5) set dash_gap, 0 6) set sphere_scale, 0.45 7) set sphere_mode, 4 8) bg_color white 9) select resi 13+28+30 and chain A and n. CA 10) distance d, sele and n. CA , sele and n. CA 11) hide labels, d* 12) show spheres, sele 13) color red, sele 14) save session_2YYI.pse 15) ray 1000,1000 16) png ~/Desktop/temp/2YYI_A.png In the above set of commands, I am opening each PDB file as mentioned in the 1st column of the input file, selecting chain as in the 2nd column, and selecting residues as mentioned in the next 3 columns. Also when i save the sessions and the png file, I am taking them from the input file. How can i automate this procedure such that I have a total of 2 png files and 2 sessions for each of the pdb that I am listing in the input file. I have tried doing this but, cant get ahead due to errors. I am not much of a coder in Python. PLease help. This is how far i have got. ***** from pymol import cmd def process_line(x): pdbid,res1,res2,res3 = x.split() cmd.load(pdbid) cmd.bg_color("white") cmd.hide("everything") cmd.show("cartoon") cmd.select((resi %s + resi %s + resi %s and chain %s name CA)"%(chain,res1,res2,res3)) cmd.distance("d","sele and n. CA, sele and n. CA") cmd.hide("labels","d*") cmd.color("sele", red) cmd.show("spheres","sele") cmd.ray(1000,1000) cmd.save("%s_%s".pse)%(pdbid,chain) cmd.png("%s_%s")%(pdbid,chain) cmd.delete(pdbid.split(',')[0]) def process_all(filename): for line in open(filename): process_line(line) process_all("testpy.txt") ***** What is going wrong? how can this be automated for all the pdbid's listed in input file ? errors I get: File "/usr/lib/pymodules/python2.6/pymol/parser.py", line 338, in parse parsing.run_file(path,self.pymol_names,self.pymol_names) File "/usr/lib/pymodules/python2.6/pymol/parsing.py", line 455, in run_file execfile(file,global_ns,local_ns) File "anu.py", line 19, in <module> process_all("testpy.txt") File "anu.py", line 17, in process_all process_line(line) File "anu.py", line 10, in process_line cmd.save(thisSession.pse) - Anasuya -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ------------------------------------------------------------------------------ Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk _______________________________________________ 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