[Bio] / DrugTargets / best_pdb.pl Repository:
ViewVC logotype

View of /DrugTargets/best_pdb.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (download) (as text) (annotate)
Fri Jun 2 15:45:45 2006 UTC (13 years, 11 months ago) by hwang
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +3 -1 lines
Fixed broken links. Separated the tag from the link so there won't be broken links in the future.

use FIG;
use FIG_Config;
use File::Temp qw/ :mktemp /;

my $fig      = new FIG;
my $temp_dir = $FIG_Config::temp;
my $toFile   = "$temp_dir/seq$$.txt";

$pdb_dir  = "/home/fangfang/public_html/PDB-U";

$usage = "best_pdb [-bound|-free] peg \n\n";

$db       = "$FIG_Config::fig/var/DrugTargets/fasta.free";
$db_bound = "$FIG_Config::fig/var/DrugTargets/fasta.bound"; 
$pdb_dir  = (-e $pdb_dir) ? $pdb_dir : "/Volumes/big/PDB-U";

for (@ARGV) {
    (/^-bound/) && ($db = $db_bound, next);
    (/^-free/) && next;
    (/^-/) && (print(STDERR "Invalid flag: $_\n"), $trouble = 1, next);
    $peg = $_;
}
die "Usage: $usage" if ($trouble || !$peg);

if (! $ENV{"BLASTMAT"}) { $ENV{"BLASTMAT"} = "$FIG_Config::blastmat" }

my $blastall = "$FIG_Config::ext_bin/blastall";

$seq =  $fig->get_translation($peg);
exit unless $seq;

open TMP, ">$toFile" or "print can't write to file";
print TMP $seq;
close(TMP);

#print $seq;

&verifyDb( $db, "p" );
	
@out = map { $_} `$blastall -i $toFile -d $db -p blastp`;


for (@out) {
    if (($_ =~ /\Apdb/)) {
	$_ =~ s/\s+/\t/g; 
	$_ =~ s/\t$//;
	@cols     = split(/\t/);
	$pdb      = $cols[0];
	$bitScore = $cols[1];
	$eValue   = $cols[2];
	$eValue   =~ s/^e/1e/i;
	$entry    = ($pdb =~ /(\d\w{3})/, $1);
 	#this is old $url      =  "http://pdb-test-c01-03.sdsc.edu/pdb/explore.do?structureId=$entry";
        $url = "http://www.rcsb.org/pdb/explore.do?structureId=$entry";

	$title    = "";

	if (open(F, "$pdb_dir/$pdb") or die print "cannot open pdb files") {
	    while (<F>) {
		chomp;
		if (/^TITLE/i){
		    my $str = (/TITLE\s+\d*\s*(.*)\b/i, $1);
		    $str =~ s/\s*$entry.*//i;
		    $title .= "$str ";
		} elsif (/^JRNL.*TITL/i) {
		    my $str = (/TITL\s+\d*\s*(.*)\b/i, $1);
		    $str =~ s/\s*$entry.*//i;
		    $title .= "$str ";
		} elsif ($title) {
		    last;
		}
	    }
	    close(F);
    	}
	print join("\t", $pdb, $eValue, $url, $title). "\n"; 
	last;
    }
}
    
sub verifyDb {
    my($db,$type) = @_;

    if ($type =~ /^p/i) {
	if ((! -s "$db.psq") || (-M "$db.psq" > -M $db)) {
	    system "$FIG_Config::ext_bin/formatdb -p T -i $db";
	}
    } else {
	if ((! -s "$db.nsq") || (-M "$db.nsq" > -M $db)) {
	    system "$FIG_Config::ext_bin/formatdb -p F -i $db";
	}
    }
}	

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3