On Wed, Apr 21, 2010 at 8:42 PM, Robert Hanson <[email protected]> wrote:
> I know I'm not the first to think of doing this -- what else is out there in
> this regard?
Maybe someone will like the attached perl script,
to convert Rasmol to Jmol.
Place the 3 files in the same directory, make executable the
file testRasmol2Jmol with chmod +x testRasmol2Jmol
and run it providing the full path of the rasmol script and the
name of a file to store the Jmol script:
./testRasmol2Jmol myRasmol.spt myJmol.spt
It will read from 'myRasmol.spt' and write on 'myJmol.spt'
The script testRasmol2Jmol is only a skeleton and might be
improved easily for batch conversion.
Jaim
--
Dr Jaime Prilusky | [email protected]
Head Bioinformatics |
R&D Bioinformatics and Data Management |
Department of Biological Services |
Weizmann Institute of Science | fax: 972-8-9344113
76100 Rehovot - Israel | tel: 972-8-9344959
OCA, http://oca.weizmann.ac.il (the protein structure/function database)
Proteopedia, http://proteopedia.org (because life has more than 2D)
------------------------------------------------------------------------
#!/usr/bin/perl
my $VERSION = "1.04"; my $AUTHOR="Prilusky"; my $YEAR="2009";
use Rasmol2jmol;
use Utils;
my $rasmolF = $ARGV[0];
my $jmolF = $ARGV[1];
Rasmol2jmol::rasmol2jmol($rasmolF,$jmolF);
package Rasmol2jmol;
my $VERSION = "1.04"; my $AUTHOR="Prilusky"; my $YEAR="2009";
use Utils;
sub rasmol2jmol {
my($rawF,$jmolF) = @_;
my ($jmolT);
foreach my $l (split(/\n/,loadFromFile($rawF))) {
trim(\$l); next unless ($l);
next if ($l =~ /^#|echo|pause|define/);
unless ($l =~ /^#/) {
($l) = split(/\s+#/,$l);
fixLoadPDB(\$l) if ($l =~ /load pdb/);
next if ($l =~ /set slabmode|set shadow/);
if ($l =~ /boundingbox/) { $l = "boundbox OFF"; next;}
$l .= ";" unless ($l =~ /\;\s*$/);
}
$jmolT .= "$l\n";
}
saveToFile($jmolT,$jmolF);
}
sub fixLoadPDB {
my($l) = @_;
my($pdbID) = $$l =~ /\s+\"?(\d\w\w\w)\./;
$$l = "load /cgi-bin/getlateststructure?${pdbID}";
return;
}
1;
package Utils;
my $VERSION = "1.02"; my $AUTHOR="Prilusky"; my $YEAR="2009";
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(trim dolog doNothing loadFromFile saveToFile);
sub saveToFile { my($data,$file)=...@_; local(*OUT);open(OUT,">$file");print
OUT $data;close OUT;}
sub doNothing { print "Status: 204 Do Nothing\n\n"; exit; }
sub trim { my($s)=...@_;$$s=~s/^\s+//;$$s=~s/\s+$//;$$s=~s/\s+/ /g;}
sub loadFromFile { my($file)=...@_; my($buff,$c);
if (-f $file) {local(*IN); open(IN,$file); while (read(IN,$c,2000)) { $buff
.= $c;} close(IN);}
return $buff;
}
sub dolog {
my($msg,$log) = @_; my $date = localtime(); chomp ($date); print "$date
$msg\n";
$$log .= "$date $msg\n" if (ref $log);
}
1;
------------------------------------------------------------------------------
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users