[Bio] / FigWebServices / proteinfamilies.cgi Repository:
ViewVC logotype

Diff of /FigWebServices/proteinfamilies.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.20, Wed Oct 12 21:03:16 2005 UTC revision 1.21, Sat Oct 22 17:43:49 2005 UTC
# Line 456  Line 456 
456    my $tab=[];    my $tab=[];
457    my $allfams;    my $allfams;
458    
459      #begin the html so we can add hidden things
460      push @$html, $cgi->start_form(-method=>'get'), $cgi->p("For protein <b>$peg</b>, which has the unique ID <b>$cid</b>, this is the EQUIV set.");
461      push @$html, $cgi->hidden(-name=>'querycid', -value=>$fig->prot_to_cid($peg));
462    
463    # this block will make a table with all IDs of all proteins in CID.    # this block will make a table with all IDs of all proteins in CID.
464    # Ross doesn't want that, so we don't use it    # Ross doesn't want that, so we don't use it
465    if (0)    if (0)
# Line 484  Line 488 
488    
489    $tab=&HTML::merge_table_rows($tab, {3=>1, 4=>1});    $tab=&HTML::merge_table_rows($tab, {3=>1, 4=>1});
490    my $col_hdrs=['CID', 'Protein', 'Function of Proteins', 'Family', 'Family Function', 'No. Prots In Family'];    my $col_hdrs=['CID', 'Protein', 'Function of Proteins', 'Family', 'Family Function', 'No. Prots In Family'];
491    push @$html, $cgi->start_form(-method=>'get'), $cgi->p("For protein <b>$peg</b>, which has the unique ID <b>$cid</b>, this is the EQUIV set."),    push @$html, &HTML::make_table($col_hdrs, $tab, ""),  "\n", $cgi->p("To differentiate families in this table, please choose two families:"),
   &HTML::make_table($col_hdrs, $tab, ""),  "\n", $cgi->p("To differentiate families in this table, please choose two families:"),  
492    "Family 1: &nbsp; ", $cgi->popup_menu(-name=>"family1", -values=>[sort {$a cmp $b} keys %$allfams], -labels=>$allfams),    "Family 1: &nbsp; ", $cgi->popup_menu(-name=>"family1", -values=>[sort {$a cmp $b} keys %$allfams], -labels=>$allfams),
493    " &nbsp; Family 2: &nbsp; ", $cgi->popup_menu(-name=>"family2", -values=>[sort {$a cmp $b} keys %$allfams], -labels=>$allfams),    " &nbsp; Family 2: &nbsp; ", $cgi->popup_menu(-name=>"family2", -values=>[sort {$a cmp $b} keys %$allfams], -labels=>$allfams),
494    $cgi->p("Limit the display to proteins from ", &choose_focus($cgi), "\n"),    $cgi->p("Limit the display to proteins from ", &choose_focus($cgi), "\n"),
# Line 537  Line 540 
540    
541   if ($cgi->param("1and2")) {   if ($cgi->param("1and2")) {
542    my $tab;    my $tab;
543      my @evidence;
544    map {    map {
545      my $cid=$_;      my $cid=$_;
546        #push @evidence, &compare_two_cids($cgi->param('querycid'), $cid);
547        push @evidence, &IHatePfams($cgi->param('querycid'), $cid);
548      map {push @$tab, [$cid, $_, &functionate($_)]} sort grep {/^$focus/} $fig->cid_to_prots($cid)      map {push @$tab, [$cid, $_, &functionate($_)]} sort grep {/^$focus/} $fig->cid_to_prots($cid)
549      } @{&set_utilities::intersection($fam1, $fam2)};      } @{&set_utilities::intersection($fam1, $fam2)};
550    
551    $tab=&HTML::merge_table_rows($tab);    $tab=&HTML::merge_table_rows($tab);
552    push @$html, $cgi->hr, $cgi->h3("Proteins that are in both $fam_id1 (" , $fig->family_function($fam_id1) , ") and in $fam_id2 (" ,    push @$html, $cgi->hr, $cgi->h3("Proteins that are in both $fam_id1 (" , $fig->family_function($fam_id1) , ") and in $fam_id2 (" ,
553            $fig->family_function($fam_id2) . ")\n"), &HTML::make_table(["CID", "Protein ID", "Function"], $tab, "");            $fig->family_function($fam_id2) . ")\n"), &HTML::make_table(["CID", "Protein ID", "Function"], $tab, ""),
554              $cgi->hr, $cgi->h3("Evidence for the connections between proteins and the families they are in"),
555              $cgi->p("These tables show the connections between the families. In the first row of each table is the initial family that you chose, and in the second row is the comparator. The first column is the CID and the remaining columns are the protein families that these two CIDs are in. In each cell are the external IDs that are (a) in the CIDs per the row headers AND (b) in the families per column headers. Thus, if you are here from <a href=\"http://listeria.uchicago.edu/dev/FIG/proteinfamilies.cgi?querycid=965112&family1=fig%7CPF002033&family2=mcl%7CORTHOMCL676&focus=all&1and2=on&differentiate=Differentiate+these+families&.cgifields=1not2&.cgifields=2not1&.cgifields=1and2\">this link</a> cog|thrB is in the family cog|COG0083 and has the ID 965112 and sp|P00547 has the ID 965112 and is in the families pfam|PB000121, pfam|PB007585, pfam|PF00288.12, pir|PIRSF000676, sp|PS00627, and tigr|TIGR00191"),
556              @evidence;
557     }
558    
559     if ($cgi->param("1and2b")) {
560      # figure out all the families we know about
561      my %families;
562      map
563      {
564       my $cid=$_;
565       map
566       {
567        $families{$_}=1;
568       }
569       $fig->in_family($cid);
570      } @{&set_utilities::intersection($fam1, $fam2)};
571      my @families=sort {$a cmp $b} keys %families;
572    
573      # now figure out all the external IDs in those families
574      my $extids;
575      map
576      {
577       my $fam=$_;
578       map
579       {
580        $extids->{$_}->{$fam}=1;
581       } $fig->ext_ids_in_family($fam);
582      } @families;
583    
584      my $tab;
585      map
586      {
587       my $cid=$_;
588       map
589       {
590        my $prot=$_;
591        my $row=[$cid, $prot, &functionate($prot)];
592        map {($extids->{$prot}->{$_}) ? push @$row, $prot : push @$row, " &nbsp; "} @families;
593        push @$tab, $row;
594       } sort grep {/^$focus/} $fig->cid_to_prots($cid)
595      } @{&set_utilities::intersection($fam1, $fam2)};
596    
597      my $skip;
598      map {$skip->{$_+4}=1} (0 .. $#families);
599      $tab=&HTML::merge_table_rows($tab, $skip);
600    
601      map {s/\|/\|<br>/} @families;
602      my $colhdrs=["CID", "Protein", "Function", @families];
603      my $title="Proteins in ". $fig->family_function($fam_id1). " ($fam_id1) AND in " . $fig->family_function($fam_id2). " ($fam_id2)\n";#$fam_id1, $fam_id2
604      push @$html, HTML::make_table($colhdrs, $tab, $title);
605     }
606    
607     if ($cgi->param("1and2c")) {
608      # figure out all the families we know about
609      my %families;
610      map
611      {
612       my $cid=$_;
613       map
614       {
615        $families{$_}=1;
616       }
617       $fig->in_family($cid);
618      } @{&set_utilities::intersection($fam1, $fam2)};
619      my @families=sort {$a cmp $b} grep {!/$fam_id1/} grep {!/$fam_id2/} keys %families;
620      unshift @families, ($fam_id1, $fam_id2);
621    
622      # now figure out all the external IDs in those families
623      my $extids;
624      map
625      {
626       my $fam=$_;
627       map
628       {
629        $extids->{$_}->{$fam}=1;
630       } $fig->ext_ids_in_family($fam);
631      } @families;
632    
633      my $tab;
634      map
635      {
636       my $cid=$_;
637       my $row=[$cid];
638       map
639       {
640        my $prot=$_;
641        map {($extids->{$prot}->{$families[$_]}) ? $row->[$_+1] = $prot : 1 } (0 .. $#families);
642       } sort grep {/^$focus/} $fig->cid_to_prots($cid);
643       unless ($#$row == $#families+1) {$#$row=$#families+1}
644       push @$tab, $row;
645      } @{&set_utilities::intersection($fam1, $fam2)};
646    
647      $tab=&HTML::merge_table_rows($tab);
648    
649      map {s/\|/\|<br>/} @families;
650      my $colhdrs=["CID", @families];
651      my $title="Proteins in ". $fig->family_function($fam_id1). " ($fam_id1) AND in " . $fig->family_function($fam_id2). " ($fam_id2)\n";#$fam_id1, $fam_id2
652      push @$html, HTML::make_table($colhdrs, $tab, $title);
653     }
654    
655     if ($cgi->param("1not2c")) {
656      # figure out all the families we know about
657      my %families;
658      map
659      {
660       my $cid=$_;
661       map
662       {
663        $families{$_}=1;
664       }
665       $fig->in_family($cid);
666      } @{&set_utilities::set_diff($fam1, $fam2)};
667      my @families=sort {$a cmp $b} grep {!/$fam_id1/} grep {!/$fam_id2/} keys %families;
668      unshift @families, ($fam_id1, $fam_id2);
669    
670      # now figure out all the external IDs in those families
671      my $extids;
672      map
673      {
674       my $fam=$_;
675       map
676       {
677        $extids->{$_}->{$fam}=1;
678       } $fig->ext_ids_in_family($fam);
679      } @families;
680    
681      my $tab;
682      map
683      {
684       my $cid=$_;
685       my $row=[$cid];
686       map
687       {
688        my $prot=$_;
689        map {($extids->{$prot}->{$families[$_]}) ? $row->[$_+1] = $prot : 1 } (0 .. $#families);
690       } sort grep {/^$focus/} $fig->cid_to_prots($cid);
691       unless ($#$row == $#families+1) {$#$row=$#families+1}
692       push @$tab, $row;
693      } @{&set_utilities::set_diff($fam1, $fam2)};
694    
695      $tab=&HTML::merge_table_rows($tab);
696    
697      map {s/\|/\|<br>/} @families;
698      my $colhdrs=["CID", @families];
699      my $title="Proteins in ". $fig->family_function($fam_id1). " ($fam_id1) AND in " . $fig->family_function($fam_id2). " ($fam_id2)\n";#$fam_id1, $fam_id2
700      push @$html, HTML::make_table($colhdrs, $tab, $title);
701   }   }
702    
703    
704  }  }
705    
706    
# Line 554  Line 709 
709   my $peg=shift;   my $peg=shift;
710   return scalar($fig->function_of($peg));   return scalar($fig->function_of($peg));
711  }  }
712    
713    
714    sub compare_two_cids {
715     my ($id1, $id2)=@_;
716     # which families is ID in and why?
717     # going via the external IDs, although I am not convinced we need to do this
718     my $family;
719     map {
720      my $id=$_;
721      map
722      {
723       map {$family->{$_}->{$id}++} $fig->ext_family_for_id($_)
724      } $fig->cid_to_prots($id);
725     } ($id1, $id2);
726    
727     # find the families that have both id1 and id2
728     my $tab;
729     map
730     {
731      push @$tab, [$_, $family->{$_}->{$id1}, $family->{$_}->{$id2}] if ( $family->{$_}->{$id1} &&  $family->{$_}->{$id2} );
732     } keys %$family;
733    
734     return &HTML::make_table(["Family", "Cnx to $id1", "Cnx to $id2"], $tab, "Connections (cnx) between proteins and families"), $cgi->p("\n");
735    }
736    
737    
738    sub IHatePfams {
739     my ($id1, $id2)=@_;
740     # id1 and id2 are cids
741    
742     # what families are the cids in?
743     my %families;
744     map {$families{$_}=1} ($fig->in_family($id1), $fig->in_family($id2));
745     my @families=sort {$a cmp $b} keys %families;
746    
747     # what external IDs are the cids
748     my %external;
749     map {$external{$_}=$id1} $fig->cid_to_prots($id1);
750     map {$external{$_}=$id2} $fig->cid_to_prots($id2);
751    
752    
753     my $tab=[];
754     foreach my $cid ($id1, $id2)
755     {
756      my $row=[$cid];
757      foreach my $fam (@families) {
758       # which proteins are in $fam
759       my $cell;
760       foreach my $id ($fig->ext_ids_in_family($fam))
761       {
762        $cell .= "$id<br>" if ($external{$id} eq $cid);
763       }
764       $cell = " &nbsp; " unless ($cell);
765       push @$row, $cell;
766      }
767      push @$tab, $row;
768     }
769    
770     &HTML::make_table(["CID", @families], $tab, "Proteins in families");
771    }
772    
773    
774    
775    
776    

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3