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

View of /DrugTargets/ShowTable.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (download) (as text) (annotate)
Mon Oct 2 22:01:11 2006 UTC (13 years, 2 months ago) by hwang
Branch: MAIN
CVS Tags: HEAD
Changes since 1.21: +56 -38 lines
Take out columns that are not wanted by Leslie

#!/usr/bin/perl  
#Kaitlyn Hwang

use strict;

use FIG_Config;
use FIG;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use File::Temp qw/ :mktemp  /;
use File::stat;

my $fig = new FIG;
my $cgi = new CGI;
my $drugBuffer;
my @getCheckBoxValue;

my $temp_dir = $FIG_Config::temp;
my $save_dir = "$FIG_Config::fig/var/DrugTargets/NewFiles";

#print "<p>$cgi->param('master_table')";
my $fdir = "$FIG_Config::fig/var/DrugTargets/NewFiles/";
my $flist = "$fdir/master_tables.list";
my $alist = "$fdir/author.list";

my %tdict = ();
my %adict = ();

#print "location of fdir $fdir\n";
#print "location of flist $flist\n";

open(FLIST, $flist) or die print "can't find the files to open $flist";
for (<FLIST>) {
    chomp;
    my ($name, $file) = split(/\t/);
    $tdict{$name} = $file;
}


open(ALIST, $alist) or die print "can't find the author literature files to open $flist";
for (<ALIST>) {
    chomp;
    my ($authorName, $entry) = split(/\t/);
    $adict{$authorName} = $entry;
}

&printHeader;
#print "<FONT SIZE=2>";
#&delete_old_files;
&printForm;


my $checkBoxNo = @getCheckBoxValue;


@getCheckBoxValue=&getValue;

shift (@getCheckBoxValue);

if ($getCheckBoxValue[0]=~ m/pdb/) {
    &getPDB(@getCheckBoxValue);
}
else {
    &getHomologs(@getCheckBoxValue);
}



my $currentTable;

if($cgi->param('View')) {
    &showFile;
}


if($cgi->param('sort')){

    &sortTable;
}

if($cgi->param('Display Table')) {

    &showLiterature;

}

if($cgi->param('Save Query as Working table')) {
       
    my $saveToName = $cgi->param('saveName');
    $saveToName =~ s/Working Table.*?oldFileName-//g;
    my $userFileName =~ s/Working Table://g;
    #$userFileName =~ s/$saveToName//g;
    #$userFileName =~ s/oldFileName-//g;
    
    print "now is ".$saveToName;
   
    my $from = "$temp_dir/$saveToName";
    my $to = "$save_dir/WriteFiles/$saveToName";

}


my @currentTable;


##############
# Subroutines
##############


sub delete_old_files {

    opendir(DIR, $temp_dir) or die print "can not open temp dir";

    my @tempFiles = grep(//, readdir(DIR));
    
    closedir(DIR);
    my $currentTime = `date +%s`;
    
    #delete anything more than 1 hours ago 
    my $deleteFileTime = $currentTime - 6900;
    
    #foreach my $tempFiles (@tempFiles) {
    #	my $statFile = stat("$temp_dir/$tempFiles");
    #	my $fileTime = $statFile->ctime;
		 
#	if ($fileTime < $deleteFileTime) {
#	    unlink("$temp_dir/$tempFiles");
	
#	}
#    }

}

sub download{
    
    print $cgi->header("Content-type: application(vnd.ms-excel; name='Excel'");
    print $cgi->header("Content-disposition: attachment; filename=drugData.xls");


    my $dFile="$FIG_Config::fig/var/temp/drugData.xls";
    print $dFile;
    #my $dFile = "$FIG_Config::fig/var/DrugTargets/NewFiles/drugData.xls";
    open(TEMPU, $dFile) or die print "can't open file at $dFile <p>";
    my @temp = <TEMPU>;
    print @temp;

}

sub printHeader {
    print 
	$cgi->header("text/html"),
	$cgi->start_html(-title=>'Drug Targets'),
	$cgi->hr,
	$cgi->end_html;
    

}

sub getValue {
    my @value;
    
    foreach my $key (param) {
	push (@value,param($key));	
    }
    
    return @value;
}


sub loadFiles {
    #load all the files in the directory
    #put it in one orgs
    #print that table
    
    my $getFile;
    my @allFiles;
    while ( my ($key, $value) = each(%tdict)) {
	#print "$key=> $value\n";
	
	open(LFILE, "$fdir/$value") or die print "in loadFiles, can't load the file";
	my @lFile = <LFILE>;
	#need to manipulate the list because of 1st column's heading
	my $arraySize = @lFile;
	push(@allFiles, @lFile[1..$arraySize]);
	close LFILE;
    }
    
    return @allFiles;

}



sub showFile {
 
    my $getFile = $tdict{$cgi->param('master_table')};
       
    open(FLIST, "$fdir/$getFile") or die print "can't find the files";
    my @viewfile = <FLIST>;
    my $fileSize = @viewfile;
    @currentTable=@viewfile[1..$fileSize];
    &printTable(@viewfile[1..$fileSize]);
}


sub downloadFile{

   # my $getFile = $tdict{$cgi->param('master_table')};
    my $getFile='temp.xls';    
    print "Content-Type:application/vnd.ms-excel\n";  
    print "Content-Disposition:attachment;filename=$getFile\n\n";
    open(FLIST, "$fdir/$getFile") or die print "can't download the files";
    while(<FLIST>){
	print;
    }
}


sub printForm {

    my $flist = "$FIG_Config::fig/var/DrugTargets/NewFiles/master_tables.list";
    my %tdict = ();


    open(FLIST, $flist) or die print "can't find the files".$flist;
    for (<FLIST>) {
	chomp;
	my ($name, $file) = split(/\t/);
	$tdict{$name} = $file;
    }
    
    print
	h1('Candidate Therapeutics'),
	#p('Candidate therapeutics  within each table are taken from literature.'),
	p('The NMPDR Drug Targets Pipeline, currently in development, explores genome                                  level drug discovery toward the future goal of in silico drug screening.  A                                    growing library of candidate targets for therapeutic intervention is being                                     generated from NMPDR sequence data, curated literature annotations, and                                        structural data from Protein Data Bank (PDB).'),
	p('Reports of experimental evidence for essentiality, virulence, or antibiotic                                     susceptibility have been associated as "attributes" to gene sequences in the                                    NMPDR.  The curation effort represents a first pass through the literature,                                   simply for proof of concept of the down stream analysis.  Only a few reports                                  of high-throughput screening for such characteristics in important pathogens                                    have been encoded as attributes of the respective genes.  We welcome                                            suggestions of literature that should be curated.'),

	hr,
	p('Search the database by author and the genus'),

	start_form(-action=>'ShowTable.cgi'),
	"View",
	$cgi->popup_menu(-name => 'get_author',
			 -values=>[sort keys %adict],),
	       	
	submit("Display Table"),
	
	p('Search the table by organism'),
	p('<a href=ShowTableKey.cgi> Read explanation of column headers for more information</a>'),
		
        p, 
         "View",
	$cgi->popup_menu(-name => 'sort_table',
			 -values=>[sort keys %tdict],),
	" By ",
	scrolling_list(-name=>'sortby',
		       -values=>['Category', 'Author'],
                       -default=>'Category'),
       	
	submit("sort"),
	
	p,
	hr,
	
		 
}


sub setFilePath{

    my $saveDir = "$FIG_Config::temp";
    my $saveFile = "$saveDir/drugData.csv";
    
    my $dataDir = "$FIG_Config::fig/var/DrugTargets";
    my $saureusFile = "$dataDir/saureusMaster.txt";

    my $strepDir = "$FIG_Config::fig/var/DrugTargets";
    my $strepFile = "$strepDir/strep_thanassi_table.txt";

    if (!open SAUREUS_LIST, $saureusFile) {
	warn "can not open file $saureusFile: $!";
	print "<h1> Cannot open datafile $saureusFile</h1>\n";
	exit 0;
    }

    if (!open SAVED_LIST, $saveFile) {
	warn "can not open file $saveFile: $!";
	print "<h1> Cannot open datafile $saveFile</h1>\n";
	exit 0;
    }

    if (!open STREP_LIST, $strepFile) {
	warn "can not open file $strepFile: $!";
	print "<h1> Cannot open datafile $strepFile</h1>\n";
	exit 0;
    }

    #Some of these are outdated. need to clean up

    my @saureusList=<SAUREUS_LIST>;
    my @strepList=<STREP_LIST>;
    my @orgsList;
    
    
    push @orgsList, [@saureusList];
    push @orgsList, [@strepList];
            
    return @orgsList;
    
        
}


sub printTable {
       
    my $saveDir = "$FIG_Config::temp";

    my(@printList) = @_;
    
    my $num = @printList;
    
    my @html;

    if ($num >=1){

	print "The table is shown with a filter of only displaying PDBs of e value 1e-15 or better. The e values are taken from blastp.";

	print "<table><tr><td bgcolor=#99ffcc>PDB e value is less than 1e-15</td></tr><tr><td bgcolor=#ff957a >PDB e value is greater than 1e-15</td></tr> </table>";
		
	my $saveFile = "$saveDir/drugData$$.xls";
	#my $dFile="$FIG_Config::temp_url/drugData$$.xls";
	my $dFile ="http://bioseed.mcs.anl.gov/~hwang/FIG-Tmp/drugData$$.xls";
	open SAVED_LIST, ">$saveFile" or print "can't open file SAVETO FILE";	
	print 
	
	    
	    
	    hr,
	    start_form(),
	    p,
	    #"Check the checkboxes to compare homologs OR pdbs. Do not mix the query with both pdbs and pegs",
	    p,
	    "<a href=$dFile>Download to Excel<a>",
	    p,
	   
	    #submit('Submit Query'),	    
	    #textfield(-name => 'saveName',
	    #	      -size=>'50px',
	    #	      -default=> "Working Table: yourFileName oldFileName-$newFile"),
	    #submit(-name=>'Save Query as Working table'),
	    	    
	    
	    table({border=>1}),
	    #TR(td('Check to compare homologs'), 
	    #   td('Check to compare pdb with other generated tables'), 
	    TR(td('Genus, Author'),
	       td('Category'), 
	       td('Identifier, by author'), 
	       #td('Aliases from SEED'), 
	       #td('Peg Id'), 
	       #td('Coding sequence length'),
	       #td('Genbank Id'), 
	       #td('Uniprot Id'), 
	       td('Subsystem'),
	       td('Functional Role'), 
	       td('Conservation of Seqs'), 
	       td('PDB Bound'), 
	       td('Eval Bound'), 
	       td('PDB Free'), 
	       td('Eval FreeEval'),  
	       td('PDB FreeTitle'), 
	       #td('PDB SeqLen'), 
	       td('Protdist'), 
	       td('Pass ASP'), 
	       td('Pass Weight of Largets Pocket'), 
	       #td('PDB  Ligand CLiBE'), 
	       #td('Total Energy'), 
	       #td('Van der Waals Interaction'), 
	       #td('Hydrogen Bond'), 
	       #td('Electrostatic Interaction'), 
	       #td('Solvation Energy')
	       );

	print SAVED_LIST "<HTML><BODY>
                         <TABLE BORDER =1><tr>
                         <td>Genus, Author </td>
                         <td>Category</td>
                         <td>Identifier, by author</td>
                         <td>Subsystem</td>
                         <td>Functional Role</td>
                         <td>Conservation of Seqs</td>
                         <td>PDB Bound</td>
                         <td>PDB Bound Eval</td>
                         <td>PDB Free</td>
                         <td>PDB Free Eval</td>
                         <td>PDB Free Title</td>
                         <td>Protdist</td>
                         <td>Pass ASP</td>
                         <td>Pass Weight of Largest Pocket</td>
                         </tr>";
    
    
    
	#my @newlist = @printList[1..$num-1];
	my @newlist = @printList[0..$num];
	#print "something here?" .@newlist;

	foreach my $val (@newlist) {	    
	    chomp($val);
	    my $tCount=0;
	  
	    my @cols = split(/\t/, $val);
	    my $colsNo = @cols;
	  
	    
	    my $author = $cols[0];
	    
	    my $category = $cols[1];
	    my $tagInfo = $cols[2];
	    my $tagUrl  = $cols[3];        
	    my $geneId = $cols[4];
	    my $pegInfo = $cols[5];
	    my $pegSeqLen = $cols[6];
	    my $genbankInfo= $cols[7];
	    my $uidInfo= $cols[8];
	    my $functionalRole = $cols[9];
	    my $consSeq = $cols[10];
	    my $pdbBound = $cols[11];
	    my $pdbBUrl = $cols[12];
	    my $pdbBoundEval = $cols[13];
	    my $pdbFree = $cols[14];
	    my $pdbFUrl = $cols[15];
	    my $pdbFreeEval = $cols[16];
	    my $pdbFreeTitle = $cols[17];
	    my $pdbSeqLen = $cols[18];
	    my $protdistInfo = $cols[19];
	    my $protdistUrl = $cols[20];
	    my $passASPInfo = $cols[21];
	    my $passASPUrl = $cols[22];
	    my $passWInfo = $cols[23];
	    my $passWUrl = $cols[24];
	    my $clibeInfo = $cols[25];
	    my $clibeUrl = $cols[26];
	    my $totalEnergy = $cols[27];
	    my $vanDerWaals = $cols[28];
	    my $hBond = $cols[29];
	    my $eI = $cols[30];
	    my $solvationE = $cols[31];

	    $protdistUrl=~ s/neisseria\./rickettsia\.ci\./g;
	    my $pegId = $pegInfo;
	    my $basicPegId = $pegId;
	    my $pegIdVal = $pegId;
	    $basicPegId =~ s/<.*?>//g;
	    my $pegIdVal =~ s/<.*?>//g;
	    $pegIdVal =~ s/fig\|//g;
	    
	    
	    my $plainFreePDB = $pdbFree;
	    $plainFreePDB =~ s/<.*?>//g;
	    
	    my $plainBoundPDB = $pdbBound;
	    $plainBoundPDB =~ s/<.*?>//g;
	    
	    my $notGoodLabel = " *poor pdb hit*";
	    my $usePdb='empty';
	    my $secondPdb = 'empty';
	    my $clibPdb;

	    #figure out the color, by default the colors are good and represented by white
	    my $pdbFreeColor='white' ;
	    my $pdbBoundColor='white';
	    my $clibeColor = 'white';

	    if ($pdbFreeEval > '1e-19') {
		$pdbFreeColor= '#ff9571';
		$clibeColor= '#ff9571';
	    }
	    
	    if (($pdbFreeEval < '1e-19') && ($pdbFreeEval ne "") ){
		$pdbFreeColor= '#99ffcc';
		$clibeColor= '#99ffcc';
	    }

	    if ($pdbBoundEval > '1e-19') { 
	    	$pdbBoundColor= '#ff957a';    
		$clibeColor= '#ff957a';    
	    
	    }

	    if (($pdbBoundEval <= '1e-19') && ($pdbBoundEval ne "") ){
	    	$pdbBoundColor= '#99ffcc';
		$clibeColor= '#99ffcc';
	    }

	    if (($pdbBoundEval < '1e-19') && ($pdbBoundEval < $pdbFreeEval)) {
		$usePdb = $plainBoundPDB;
		$secondPdb = $plainFreePDB;
	    }

	    if (($pdbFreeEval < '1e-19') && ($pdbFreeEval < $pdbBoundEval) ){
		$usePdb = $plainFreePDB;
		$secondPdb = $plainBoundPDB;
	    }

	    #show where the pegs occurs in the subsystem
	    #print $fig->peg_to_subsystems("fig|158879.1.peg.514");

	    
	    my ($clibe, $clibe_url, $tote, $vdwi, $hbond, $ei, $sole);
	    my $clibe_u;
	    
	    ($clibe, $clibe_url, $tote, $vdwi, $hbond, $ei, $sole) = &get_clibe($usePdb); 
	    $clibe_u = "<a href=$clibe_url>$clibe</a>" if ($clibe);

	    if ($clibe_url eq "") {
		
		($clibe, $clibe_url, $tote, $vdwi, $hbond, $ei, $sole) = &get_clibe($secondPdb); 
		$clibe_u = "<a href=$clibe_url>$clibe</a>" if ($clibe);
	    }

	    if ($clibe_url eq ""){
		$clibeColor = 'white';
	    }
	    
	    #print "<--$usePdb $secondPdb $clibe, $clibe_url, $tote, $vdwi, $hbond, $ei, $sole-><p>";
	    #print "$usePdb clibe attribute-->$clibe--><p>";
	    
	    if($author ne "") {
		my($pAuthor,$org) = split(/-/,$author);
		$author="$org,$pAuthor";
	    }
	   
	    $tagInfo=~ s/_/ /g;
	    my $tag = "<a href=$tagUrl>".$tagInfo."</a>";
	    my $pegId = "<a href=http://www.nmpdr.org/FIG/protein.cgi?prot=".$pegInfo."&user=&SPROUT=1".">".$pegInfo."</a>";
	    my $genbankId = $genbankInfo;
	    $genbankInfo=~ s/, gi\|.*//;
	    	    
	    $genbankId =~ s/, gi\|.*//;
	    $genbankId =~ s/gi\|//;
	    $genbankId = "<a href=http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&val=$genbankId>".$genbankInfo."</a>";
	    #print "genbankId is".$genbankInfo."-->".$genbankId;
	    print "<p>";

	    my $uniprotId = $uidInfo;
	    $uidInfo=~ s/, uni\|.*//;
	    $uniprotId =~ s/, uni\|.*//;
	    $uniprotId =~ s/uni\|//;

	    $uniprotId = "<a href=http://www.pir.uniprot.org/cgi-bin/upEntry?id=$uniprotId>".$uidInfo."</a>";

	    $pdbFUrl=~ s/\.ent//g;
	    $pdbFUrl=~ s/=pdb/=/g;
	    $pdbBUrl=~ s/\.ent//g;
	    $pdbBUrl=~ s/=pdb/=/g;
	    my $pdbFShow = $pdbFree;
	    $pdbFShow =~ s/\.ent//g;
	    $pdbFShow =~ s/^pdb//g;

	    my $pdbBShow = $pdbBound;
	    $pdbBShow =~ s/\.ent//g;
	    $pdbBShow =~ s/^pdb//g;
	    

            $pdbFree = "<a href=$pdbFUrl>".$pdbFShow."<\/a>";
            $pdbBound = "<a href=$pdbBUrl>".$pdbBShow."<\/a>";
	    my $protdist = "<a href=$protdistUrl>".$protdistInfo."<\/a>";
	    my $passASP  = "<a href=$passASPUrl>".$passASPInfo."<\/a>";
	    my $passWeight = "<a href=$passWUrl>".$passWInfo."<\/a>";
	    my $passLigandClibe = "<a href=$clibeUrl>".$clibeInfo."<\/a>";
	    
	    my @subsystem = $fig->subsystems_for_peg($pegInfo);
	    
	    my $subsysName;
	    my $therole;

	    for my $svalue (@subsystem) {
		($subsysName, $therole) = @{$svalue};
	    }
	    my $subsysNameNoUnder = $subsysName;
	    $subsysNameNoUnder =~ s/_/ /g;
	    
	    my $shortOrg = $pegInfo;
	    $shortOrg=~ s/.peg.*//g;
	    $shortOrg=~ s/fig\|//g;
	    

	    my $subsystemUrl= "<a href=http://www.nmpdr.org/FIG/display_subsys.cgi?show_clusters=1&request=show_ssa&sort=by_phylo&ssa_name=$subsysName&user=&focus=$shortOrg&SPROUT=1>$subsysNameNoUnder</a>";

	    
	    
	    

	    print 
		#$cgi->TR(			 			     
		#	 td(checkbox(-name=>'compareHomolog', -value=>$basicPegId, -label=>$basicPegId)),
		#	 td(checkbox(-name=>'comparePDB', -value=>"$plainFreePDB$basicPegId", -label=>$plainFreePDB)),
		$cgi->TR(td($author), td($category),  td($tag),
			 td($subsystemUrl), td($functionalRole),td($consSeq),
			 td({-bgcolor=>$pdbBoundColor}, [$pdbBound]), td({-bgcolor=>$pdbBoundColor}, [$pdbBoundEval]),
			 td({-bgcolor=>$pdbFreeColor}, [$pdbFree]), td( {-bgcolor=>$pdbFreeColor}, [$pdbFreeEval]),
			 td($pdbFreeTitle), td($protdist), td($passASP), td($passWeight) 
			 );	
	    
	
#td($passLigandClibe),td($totalEnergy), td($vanDerWaals), td($hBond), td($eI), td($solvationE));

	    print SAVED_LIST "<tr><td>$author </td><td>$category</td> <td>$tag</td>
                      <td>$subsystemUrl</td>
                      <td>$functionalRole</td><td>$consSeq</td><td>$pdbBound</td><td>$pdbBoundEval</td>
                      <td>$pdbFree</td><td>$pdbFreeEval</td><td>$pdbFreeTitle</td>
                      <td>$protdist</td><td>$passASP</td><td>$passWeight</td>
                      </tr>";
	    


	}
	print SAVED_LIST "</table>";
        print "</table></body></html>";    
	print end_form;
	
    }
}

sub showLiterature {
    
    my $sortVersion = $cgi->param('sortby');
    my @sortColumn;
    my $getAuthorName = $adict{$cgi->param('get_author')};
       
    #print "Hello file is ". $getAuthorName;

    my (@list) = &loadFiles;
    my @displayAuthors;

    foreach(@list) {

	my @cols = split(/\t/);
	
	my $theAuthor = $cols[0];
	
		
	if ($getAuthorName eq $theAuthor) {
	    push(@displayAuthors, $_);
	}
    }
    

    #print @displayAuthors;
    &printTable(@displayAuthors);
}


sub sortTable {
    
    my $sortVersion = $cgi->param('sortby');
    my @sortColumn;
    my $getFile = $tdict{$cgi->param('sort_table')};
       
    #print $getFile;
    open(FLIST, "$fdir/$getFile") or die print "can't find the files";
    my @viewfile = <FLIST>;
    my $fileSize = @viewfile;
    #print "what is the filesize $fileSize";
    my @sortTable=@viewfile[1..$fileSize];

    if (($sortVersion eq 'Category')) {
        @sortColumn = sort sortAlpha @sortTable;
    }

    if (($sortVersion eq 'Author')) {
        @sortColumn = sort sortAuthor @sortTable;
    }
    
    if ($sortVersion eq 'Peg Id') {
        @sortColumn = sort sortNumerical @sortTable;
    }
    
    my $newsortTable = @sortTable;
    my $newnum = @sortColumn;
    #print "original number of $fileSize $newsortTable $newnum"; 
    &printTable(@sortColumn);
}

sub sortAlpha {

    my $sortAlpha = $cgi->param('sortby');
    
    my $column;
    
    my @newA=split(/\t/, $a);
    
    if ($sortAlpha eq 'Category'){
	$column=1;
    }

    if ($sortAlpha eq 'Author'){
	$column=3;
    }

    
    my $aVal = $newA[$column];
    
    $aVal =~ s/<.*?>//g;
    my @newAVal = split(/,/,$aVal);
    my $newA = $newAVal[0];
    #print "a val is $newA ";
    my @newB=split(/\t/, $b);

    my $bVal = $newB[$column];
    $bVal =~ s/<.*?>//g;
    my @newBVal = split(/,/,$bVal);
    my $newB = $newBVal[0];
    #print "b val is $newB <p>";
    my $sortResult = lc ($newA) cmp lc($newB);
}


sub sortAuthor {

    my $column;
    
    my @newA=split(/\t/, $a);
    #print @newA;
    
    my $aVal = $newA[0];
    my ($aAuthor, $aOrg) = split(/-/,$aVal);
        
    my @newB=split(/\t/, $b);
    my $bVal = $newB[0];
    my ($bAuthor, $bOrg) = split(/-/,$bVal);
   
    my $sortResult = lc ($aAuthor) cmp lc($bAuthor);
}


sub sortNumerical {
        
    my @newA=split(/\t/, $a);
    
    my $atVal = $newA[3];
    
    $atVal =~ s/<.*?>//g;
    my @newAVal = split(/,/,$atVal);
    my $newA = $newAVal[0];
    $newA =~ s/SA//g;
    $newA =~ s/SAS//g;
    #$newA =~ s/.*peg\.//g;
    $newA=~ s/fig\|//g;
    my @pegA = split(/\.peg\./, $newA);

    #$pegA[0] is the genome
    #$pegA[1] is the peg 

    #print @pegA[0];

    my @newB=split(/\t/, $b);
    
    my $btVal = $newB[3];
    $btVal =~ s/<.*?>//g;
    my @newBVal = split(/,/,$btVal);
    my $newB = $newBVal[0];
    $newB =~ s/SA//g;
    $newB =~ s/SAS//g;
    $newB=~ s/fig\|//g;
    my @pegB = split(/\.peg\./, $newB);
    
    ($pegA[0] <=> $pegB[0] || $pegA[1] <=> $pegB[1]);
    
    
}





sub getHomologs {
    
    #my (@list) = &setFilePath;     
    my (@list) = &loadFiles;

    my (@homologsList) = @_;
   
    my @orgs;
    my @sims;
    
    my $sim;
    my $id2;
    my @cols;
    my $pegId;
    my $whichOrg;
       
    foreach (@homologsList){
	chomp;
	my @matchPegList="";
	if (/peg/)  {   
	   
	    print "<p><b>homologs for $_</b>";
	    
	    $_ =~ s/\s+//;
	    $_ =~ s/\n//;
	    	    
	    @sims = $fig->sims("$_","1000","1e20","fig");
	    
	    foreach $sim (@sims)
	    {	    
		$id2 = $sim->id2;
		
		foreach (@list){
		   
		    @cols = split(/\t/);
		    $pegId =$cols[3];
		    
		    $pegId=~ s/<.*?>//g;
		    
		    if ($id2 eq $pegId) {
			push(@matchPegList, $_);		    
		    }
		}
				
	    }
	    &printTable(@matchPegList);
	}
	
    }
}

sub getPDB {

    my @comparePDBList = @_;
    my (@list) = &loadFiles;     
    
    foreach my $pdbVal (@comparePDBList) {
	my @matchedPDBList;	
		
	$pdbVal=~ s/fig\|.*//g;
		
	if ($pdbVal ne ""){
	    

	    foreach(@list) {

		my @cols = split(/\t/);
		
		my $thePdb = $cols[11];
		
		$thePdb =~ s/<.*?>//g;
		
		if ($pdbVal eq $thePdb) {
		    push(@matchedPDBList, $_);
		}
	    }
	  
	    
	}
	
	print "<hr><br><b>PDB matches for $pdbVal</b>";
	&printTable(@matchedPDBList);
	
    }
    
}


sub get_clibe {
    
    my ($pdb) = @_;
    #print "get clibe $pdb <p>";
    my $clibe_db = "$FIG_Config::fig/var/DrugTargets/pdb_ligand_clibe_attribute_detailed.txt";
    $clibe_db = "pdb_ligand_clibe_attribute_detailed.txt" unless (-e $clibe_db);
    
    #print "clibe_db $clibe_db<p>";
    
    my $pdb_key =  ($pdb =~/(\d\w{3})/, $1);

    #print "key is $pdb_key<p>";
    my $attr = `grep $pdb_key $clibe_db|head -n1`; 
    
    chomp($attr);
    #print "attr is $attr<p>";
    
    my $url;
    (undef, undef, $attr, $url) = split(/\t/, $attr);

    
    if ($attr =~ /(.*),TotE(.*),VDWI(.*),HBond(.*),EI(.*),SolE(.*)/) {
	
	return ($1, $url, $2, $3, $4, $5, $6);
    } else {
	
	return ();
    }

}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3