Hi Dustin,
I have used a combination of perl and bash scripts to accomplish something
similar to what you're doing. The one small difference is that I was loading
several PDB files (not SDFs). You'll have to figure out how to do this part
if it's significantly different from the loading command for PDFs. Also, it
may be much easier to do all of the above in python if you know python...I
don't know it that well (and I DO know perl) so I try to avoid python...to
each his own.
Assuming you want to load and do some simple manipulations with each SDF file,
you can adapt the following protocol as you wish:
1. Make a master pymol log file containing all the manipulations you wish
except for the read and write commands (these will vary depending on the file
name and will be added by the perl script below. Here's an example of such a
pymol log file. The file will contain the exact text of all the pymol
commands you wish to run in pymol once you have your SDF file loaded. If you
only want to convert the files (no other pymol manuplations), ignore this
part. I call this file master.pml.
*****************master.pml*****************************
bg_color white
set cartoon_transparency=0.00001
set cartoon_loop_radius=0.2200
set cartoon_loop_quality=20
set cartoon_sampling=20
select PROT1, rnase_ptppap_1mol and i. 1-124
color blue, PROT1
hide everything, PROT1
show cartoon, PROT1
cartoon loop, (i. 1-124)
select pTppAp, rnase_ptppap_1mol and i. 901
color red, pTppAp
show sticks, pTppAP
center pTppAp
move y,9
move x,-2
move z,30
****************************************************************
2. Next I would use a perl script to create individual pymol log files for all
the PDB files (or in your case SDF files) in the directory. This script is
written for the linux (*nix) file format. You will have to adapt if you are
using Windows. You will also have to get Perl if you are working on Windows.
It is free. I call this script make_pml.pl. Be sure to type 'chmod 755
make_pml.pl' when you copy it to the appropriate folder. You will have to
make the appropriate changes from PDB to SDF.
*********************make_pml.pl**********************************
#!/usr/bin/perl
# Run this program from the directory containing your
# PDB files and the master.pml file
use strict;
use warnings;
use Cwd;
# Get the name of the current directory
my $cur_dir=getcwd();
# Get the names of all the PDB files in the current directory
my @pdb_files = <*.pdb>;
@pdb_files = glob("*.pdb");
# Remove the .pdb extension from each name
foreach my $pdb_file (@pdb_files) {
my @pdb_tmp = split /\./, $pdb_file;
$pdb_file = $pdb_tmp[0];
}
# For each pdb file, print a load command and then the text of the master.pml
file
# Finish with a command to save the output as a PNG
foreach my $pdb_file (@pdb_files) {
# Open each a pml file for each PDB file
open(CUR_PML, "> $pdb_file.pml") || die("Cannot open ouput file
$pdb_file.pml.");
print CUR_PML "load $cur_dir/$pdb_file.pdb\n\n";
# Open the master pml file
open(MASTER_PML, "< master.pml") || die("Cannot open master.pml file.");
# Now copy each line from master.pml to the new pml file
while (my $input = <MASTER_PML>) {
chomp($input);
print CUR_PML "$input\n";
}
close(MASTER_PML);
# Now print the command to save as a PNG
print CUR_PML "png $pdb_file.png\n";
}
*******************************************************************
3. Finally, I would write a bash script to run all of this. You can load
pymol with the -c flag for batch operations (I think this was one of your
specific questions). Again, type 'chmod 755 run_pymol.sh' when you get this
file in the right spot.
********************run_pymol.sh*************************************
#!/bin/bash
unset noclobber
# Create all the *.pml files from a perl script
./make_pml.pl
# load all figures from pymol scripts
# You can remove the -c option to load the gui
# Loading the gui doesn't work well with batch operations
# Get a list of all the pymol log files
pml_files=*.pml
for pml_file in $pml_files
do
pymol -c $pml_file
done
********************************************************************
4. That's it...just type ./run_pymol.sh from a folder containing all your PDF
files, the master.pml file, and this run_pymol.sh file. Again, if the
command for loading SDF files is different from the simple "load" command in
the perl script, you can adapt as necessary.