Re: [PyMOL] Deleting and Loading multiple SDF files

2010-09-23 Thread Michael Lerner
Hi Renuka,

Please keep all PyMOL-related correspondence on the mailing list. That way,
other people can find the answers by reading the mailing list or searching
the web.

Your task is now getting a little more complicated. I think you'll probably
want to define some Python functions and use them. It's useful to know that
using the distance command with mode=2 will show polar contacts. Also,
distance objects with names starting with an underscore won't show up in the
GUI.


I'd do something like this:

1. Define some functions in a Python file that you can use via run (or
perhaps in your .pymolrc). [see
http://www.pymolwiki.org/index.php/Python_Integration and
http://www.pymolwiki.org/index.php/Script_Tutorial]. You'll need to pass the
name of your protein to these functions.

import os
from pymol import cmd

def loadclust(filename,protname):
cmd.load(filename)
dir,fname = os.path.split(filename)
# PyMOL automatically names the object by the filename
fname,extension = os.path.splitext(fname)
# cluster_4 -- 4
custernum = fname.split('_')[1]
# hidden from GUI display because it starts with _
polarname = '_polar_'+clusternum
cmd.dist(polarname,fname,protname,mode=2)
cmd.extend('loadclust',loadclust)
def delclust(filename):
dir,fname = os.path.split(filename)
# PyMOL automatically names the object by the filename
fname,extension = os.path.splitext(fname)
# cluster_4 -- 4
custernum = fname.split('_')[1]
# hidden from GUI display because it starts with _
polarname = '_polar_'+clusternum
cmd.delete(fname)
cmd.delete(polarname)
cmd.extend('delclust',delclust)

2. Then you should be able to use a similar procedure to
before. Remember that you now need to delete things and pass the name of
your protein to the functions so that polar contacts can be displayed
correctly:

for i in glob.glob(Model_1/cluster_*.sdf): loadclust(i,myprotein)

analyze things

for i in glob.glob(Model_1/cluster_*.sdf): delclust(i,myprotein)

for i in glob.glob(Model_2/cluster_*.sdf): loadclust(i,myprotein)

Unfortunately, I don't have any SD files on hand, so I haven't tested these!
Some modification may be necessary. You should also check out the script
that Jason linked.

Cheers,

-Michael

On Wed, Sep 22, 2010 at 11:52 AM, Renuka Robert renukarob...@ymail.comwrote:

 Dear Michael
 Thanks for your detailed reply. This is what exactly i needed. Now i want
 to find the hydrogen bonding between each cluster files and the protein. So
 i do the following step

 cd /home/user

 import glob


  then I load the Model_1 files with


  for i in glob.glob(Model_1/cluster_*.sdf): cmd.load(i)


  Now hydrogen bond should be displayed between protein and
 Model_1/cluster_*.sdf. Polar contacts in different colors would be more
 appreciated.


  Could you please attach your script in the above command, so that all the
 cluster_*.sdf is loaded and its polar contacts is displayed in one press.


  Thanks in advance

 Renuka.


 --- On *Wed, 22/9/10, Michael Lerner 
 mglerner+sourcefo...@gmail.commglerner%2bsourcefo...@gmail.com
 * wrote:


 From: Michael Lerner 
 mglerner+sourcefo...@gmail.commglerner%2bsourcefo...@gmail.com
 
 Subject: Re: [PyMOL] Deleting and Loading multiple SDF files
 To: Renuka Robert renukarob...@ymail.com
 Cc: PyMOL-users@lists.sourceforge.net
 Date: Wednesday, 22 September, 2010, 1:46 PM


 Hi Renuka,

 If I understand correctly, this is what you want to do:

 1. Load up all of the cluster*.sdf files in Model_1.
 2. Analyze them
 3. Delete them
 4. Load up all of the cluster*.sdf files in Model_2.
 5. Analyze them
 6. Delete them
 etc.

 If that's right, I think the easiest thing is just to change to the
 directory that contains your Model_N subdirectories. In your example, that
 would be:

 cd /home/user
 import glob

 then load the Model_1 files with

 for i in glob.glob(Model_1/cluster_*.sdf): cmd.load(i)

 then analyze them. It sounds like you're analyzing them by hand; if you're
 analyzing them by running some scripts, we can probably help to automate
 that process as well.

 After analyzing them, (and saving your results!), you'll want to delete the
 current batch of cluster files and load the new ones:

 delete cluster_*
 for i in glob.glob(Model_2/cluster_*.sdf): cmd.load(i)

 Note that you only have to type import glob once.

 Hope that helps,

 -Michael

 On Wed, Sep 22, 2010 at 9:12 AM, Renuka Robert 
 renukarob...@ymail.comhttp://mc/compose?to=renukarob...@ymail.com
  wrote:

  Dear Pymol users


  I have to do TWO jobs simultaneously in PYMOL.


  JOB 1: Load multiple *sdf files


  I have set of ligand files in *.sdf format as follows:


  /home/user/Model_1/cluster_1.sdf

 /home/user/Model_1/cluster_2.sdf

 /home/user/Model_1/cluster_3.sdf


  /home/user/Model_2/cluster_1.sdf

 /home/user/Model_2/cluster_2.sdf

 /home/user/Model_2/cluster_3.sdf


  /home/user/Model_3/cluster_1.sdf

 /home/user/Model_3/cluster_2.sdf

 /home/user/Model_3/cluster_3

[PyMOL] Deleting and Loading multiple SDF files

2010-09-22 Thread Renuka Robert






p { margin-bottom: 0.08in; }

Dear Pymol users



I have to do TWO jobs simultaneously in
PYMOL.



JOB 1: Load multiple *sdf files



I have set of ligand files in *.sdf
format as follows:



/home/user/Model_1/cluster_1.sdf
/home/user/Model_1/cluster_2.sdf
/home/user/Model_1/cluster_3.sdf



/home/user/Model_2/cluster_1.sdf
/home/user/Model_2/cluster_2.sdf
/home/user/Model_2/cluster_3.sdf



/home/user/Model_3/cluster_1.sdf
/home/user/Model_3/cluster_2.sdf
/home/user/Model_3/cluster_3.sdf



I've got an answer from one of the
PYMOL user as:



PyMOLimport glob
PyMOLfor i in
glob.glob(cluster_*.sdf): cmd.load(i)



But this command works only in the
present working directory. For the next try I have to change my
directory every time. Like:



cd /home/user/Model_1/
PyMOLimport glob
PyMOLfor i in
glob.glob(cluster_*.sdf): cmd.load(i)



cd /home/user/Model_2/
PyMOLimport glob
PyMOLfor i in
glob.glob(cluster_*.sdf): cmd.load(i)



cd /home/user/Model_3/
PyMOLimport glob
PyMOLfor i in
glob.glob(cluster_*.sdf): cmd.load(i)



Could you please tell me how to load
these multiple *.sdf files in one command without changing the
directory?



JOB2: Delete multiple *.sdf files



I have to analyze cluster_*.sdf files
of several 100 directories.
 So when I load cluster_*.sdf files from
directory Model_2, the already loaded cluster:*.sdf files from
Model_1 should be deleted. 
Like wise when I load cluster_*.sdf files
from directory Model_3, the already loaded cluster:*.sdf files from
Model_2 should be deleted.

I am not good in programming. Could
anybody help me in scripting to sort out this problem?



Thanks in advance.
Regards
Renuka


--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev___
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

Re: [PyMOL] Deleting and Loading multiple SDF files

2010-09-22 Thread Jason Vertrees
Hi Renuka,

Check out the loadDir PyMOL script (
http://www.pymolwiki.org/index.php/LoadDir).  You can do stuff like,

# load all PDBs in the directory ../
loadDir ../, *.pdb

# load all SDFs in ../../mySDFs
loadDir ../../mySDFs/state*.sdf

Cheers,

-- Jason

On Wed, Sep 22, 2010 at 9:12 AM, Renuka Robert renukarob...@ymail.comwrote:

  Dear Pymol users


  I have to do TWO jobs simultaneously in PYMOL.


  JOB 1: Load multiple *sdf files


  I have set of ligand files in *.sdf format as follows:


  /home/user/Model_1/cluster_1.sdf

 /home/user/Model_1/cluster_2.sdf

 /home/user/Model_1/cluster_3.sdf


  /home/user/Model_2/cluster_1.sdf

 /home/user/Model_2/cluster_2.sdf

 /home/user/Model_2/cluster_3.sdf


  /home/user/Model_3/cluster_1.sdf

 /home/user/Model_3/cluster_2.sdf

 /home/user/Model_3/cluster_3.sdf


  I've got an answer from one of the PYMOL user as:


  PyMOLimport glob

 PyMOLfor i in glob.glob(cluster_*.sdf): cmd.load(i)


  But this command works only in the present working directory. For the
 next try I have to change my directory every time. Like:


  cd /home/user/Model_1/

 PyMOLimport glob

 PyMOLfor i in glob.glob(cluster_*.sdf): cmd.load(i)


  cd /home/user/Model_2/

 PyMOLimport glob

 PyMOLfor i in glob.glob(cluster_*.sdf): cmd.load(i)


  cd /home/user/Model_3/

 PyMOLimport glob

 PyMOLfor i in glob.glob(cluster_*.sdf): cmd.load(i)


  Could you please tell me how to load these multiple *.sdf files in one
 command without changing the directory?


  JOB2: Delete multiple *.sdf files


  I have to analyze cluster_*.sdf files of several 100 directories.


 So when I load cluster_*.sdf files from directory Model_2, the already
 loaded cluster:*.sdf files from Model_1 should be deleted.

 Like wise when I load cluster_*.sdf files from directory Model_3, the
 already loaded cluster:*.sdf files from Model_2 should be deleted.


 I am not good in programming. Could anybody help me in scripting to sort
 out this problem?


  Thanks in advance.

 Regards

 Renuka



 --
 Start uncovering the many advantages of virtual appliances
 and start using them to simplify application deployment and
 accelerate your shift to cloud computing.
 http://p.sf.net/sfu/novell-sfdev2dev
 ___
 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




-- 
Jason Vertrees, PhD
PyMOL Product Manager
Schrodinger, LLC

(e) jason.vertr...@schrodinger.com
(o) +1 (603) 374-7120
--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev___
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