[Bio] / FigKernelPackages / Observation.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/Observation.pm

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

revision 1.8, Tue Jun 19 22:11:25 2007 UTC revision 1.9, Wed Jun 20 16:43:13 2007 UTC
# Line 5  Line 5 
5    
6  use strict;  use strict;
7  use warnings;  use warnings;
8  use Table;  use HTML;
9    
10  1;  1;
11    
# Line 24  Line 24 
24    
25  Example:  Example:
26    
27    
28  use FIG;  use FIG;
29  use Observation;  use Observation;
30    
# Line 101  Line 102 
102    
103  =over 9  =over 9
104    
105    =item IDENTICAL (seq)
106    
107  =item SIM (seq)  =item SIM (seq)
108    
109  =item BBH (seq)  =item BBH (seq)
# Line 336  Line 339 
339      else{      else{
340          #IPR,CDD,CELLO,PFAM,SIGNALP - attribute based          #IPR,CDD,CELLO,PFAM,SIGNALP - attribute based
341          my %domain_classes;          my %domain_classes;
342            my $identical_flag=0;
343            my $pch_flag=0;
344          foreach my $class (@$classes){          foreach my $class (@$classes){
345              if($class =~/(IPR|CDD|PFAM)/){              if($class =~/(IPR|CDD|PFAM)/){
346                  $domain_classes{$class} = 1;                  $domain_classes{$class} = 1;
   
347              }              }
348                elsif ($class eq "IDENTICAL")
349                {
350                    $identical_flag = 1;
351          }          }
352                elsif ($class eq "PCH")
353                {
354                    $pch_flag = 1;
355                }
356            }
357    
358            if ($identical_flag ==1)
359            {
360                get_identical_proteins($fid,\@matched_datasets);
361            }
362            if ( (defined($domain_classes{IPR})) || (defined($domain_classes{CDD})) || (defined($domain_classes{PFAM})) ) {
363          get_attribute_based_domain_observations($fid,\%domain_classes,\@matched_datasets);          get_attribute_based_domain_observations($fid,\%domain_classes,\@matched_datasets);
364            }
365            if ($pch_flag == 1)
366            {
367                get_functional_coupling($fid,\@matched_datasets);
368            }
369    
370          #add CELLO and SignalP later          #add CELLO and SignalP later
371      }      }
# Line 352  Line 375 
375          if($dataset->{'type'} eq "dom"){          if($dataset->{'type'} eq "dom"){
376              $object = Observation::Domain->new($dataset);              $object = Observation::Domain->new($dataset);
377          }          }
378            if($dataset->{'class'} eq "PCH"){
379                $object = Observation::FC->new($dataset);
380            }
381            if ($dataset->{'class'} eq "IDENTICAL"){
382                $object = Observation::Identical->new($dataset);
383            }
384          push (@$objects, $object);          push (@$objects, $object);
385      }      }
386    
# Line 608  Line 637 
637          my $organism = $fig->org_of($fid);          my $organism = $fig->org_of($fid);
638          my $who = $row->[1];          my $who = $row->[1];
639          my $assignment = $row->[2];          my $assignment = $row->[2];
640          $dataset = [ { name => 'class', value => "IDENTICAL" },  
641                       { name => 'id' , value => $id},          my $dataset = {'class' => 'IDENTICAL',
642                       { name => 'organism', value => "$organism"} ,                         'id' => $id,
643                       { name => 'database', value => $who },                         'organism' => $organism,
644                       { name => 'description' , value => $assignment}                         'type' => 'seq',
645                       ];                         'database' => $who,
646                           'function' => $assignment
647                           };
648    
649          push (@{$datasets_ref} ,$dataset);          push (@{$datasets_ref} ,$dataset);
650      }      }
651    
# Line 650  Line 682 
682          my $id = $row->[1];          my $id = $row->[1];
683          my $score = $row->[0];          my $score = $row->[0];
684          my $description = $row->[2];          my $description = $row->[2];
685          $dataset = [ { name => 'class', value => "FC" },          my $dataset = {'class' => 'PCH',
686                       { name => 'score' , value => $score},                         'score' => $score,
687                       { name => 'id', value => "$id"} ,                         'id' => $id,
688                       { name => 'description' , value => $description}                         'type' => 'fc',
689                       ];                         'function' => $description
690                           };
691    
692          push (@{$datasets_ref} ,$dataset);          push (@{$datasets_ref} ,$dataset);
693      }      }
694  }  }
# Line 775  Line 809 
809      return $self->{organism};      return $self->{organism};
810  }  }
811    
812    =head3 function (internal)
813    
814    Returns the function of the identical sequence
815    
816    =cut
817    
818    sub function {
819        my ($self) = @_;
820    
821        return $self->{function};
822    }
823    
824  =head3 database (internal)  =head3 database (internal)
825    
826  Returns the database of the identical sequence  Returns the database of the identical sequence
# Line 787  Line 833 
833      return $self->{database};      return $self->{database};
834  }  }
835    
 #package Observation::Identical;  
 #1;  
 #  
 #our @ISA = qw(Observation);  # inherits all the methods from Observation  
836    
837  =head3 display_identical()  ############################################################
838    ############################################################
839    package Observation::Identical;
840    
841    use base qw(Observation);
842    
843    sub new {
844    
845        my ($class,$dataset) = @_;
846        my $self = $class->SUPER::new($dataset);
847        $self->{id} = $dataset->{'id'};
848        $self->{organism} = $dataset->{'organism'};
849        $self->{function} = $dataset->{'function'};
850        $self->{database} = $dataset->{'database'};
851    
852        bless($self,$class);
853        return $self;
854    }
855    
856    =head3 display()
857    
858  If available use the function specified here to display the "raw" observation.  If available use the function specified here to display the "raw" observation.
859  This code will display a table for the identical protein  This code will display a table for the identical protein
860    
861    
862  B<Please note> that URL linked to in display_method() is an external component and needs to added to the code for every class of evidence.  B<Please note> that URL linked to in display_method() is an external component and needs to added to the code for every class of evi
863    dence.
864    
865  =cut  =cut
866    
867  sub display_identical {  sub display{
868      my ($self, $fid, $cgi) = @_;      my ($self, $cgi, $dataset) = @_;
   
     my $content;  
     my $array=Observation->get_objects($fid);  
869    
870      my $all_domains = [];      my $all_domains = [];
871      my $count_identical = 0;      my $count_identical = 0;
872      foreach my $thing (@$array) {      my $content;
873        foreach my $thing (@$dataset) {
874          next if ($thing->class ne "IDENTICAL");          next if ($thing->class ne "IDENTICAL");
875          my $single_domain = [];          my $single_domain = [];
876          push(@$single_domain,$thing->class);          push(@$single_domain,$thing->database);
877          my $id = $thing->id;          my $id = $thing->id;
878          $count_identical++;          $count_identical++;
879          push(@$single_domain,&HTML::set_prot_links($cgi,$id));          push(@$single_domain,&HTML::set_prot_links($cgi,$id));
880          push(@$single_domain,$thing->organism);          push(@$single_domain,$thing->organism);
881          push(@$single_domain,$thing->database);          #push(@$single_domain,$thing->type);
882          push(@$single_domain,$thing->description);          push(@$single_domain,$thing->function);
883          push(@$all_domains,$single_domain);          push(@$all_domains,$single_domain);
884      }      }
885    
886      if ($count_identical >0){      if ($count_identical >0){
887          my $table_component = $self->application->component('DomainTable');          $content = $all_domains;
   
         $table_component->columns ([ { 'name' => 'Name', 'filter' => 1 },  
                                      { 'name' => 'ID' },  
                                      { 'name' => 'Organism' },  
                                      { 'name' => 'Database' },  
                                      { 'name' => 'Assignment' }  
                                      ]);  
         $table_component->data($all_domains);  
         $table_component->show_top_browse(1);  
         $table_component->show_bottom_browse(1);  
         $table_component->items_per_page(50);  
         $table_component->show_select_items_per_page(1);  
         $content .= $table_component->output();  
888      }      }
889      else{      else{
890          $content = "<p>This PEG does not have any essentially identical proteins</p>";          $content = "<p>This PEG does not have any essentially identical proteins</p>";
# Line 845  Line 892 
892      return ($content);      return ($content);
893  }  }
894    
895    1;
896    
897    
898    #########################################
899    #########################################
900    package Observation::FC;
901    1;
902    
903    use base qw(Observation);
904    
905    sub new {
906    
907        my ($class,$dataset) = @_;
908        my $self = $class->SUPER::new($dataset);
909        $self->{score} = $dataset->{'score'};
910        $self->{id} = $dataset->{'id'};
911        $self->{function} = $dataset->{'function'};
912    
913        bless($self,$class);
914        return $self;
915    }
916    
917    =head3 display()
918    
919    If available use the function specified here to display the "raw" observation.
920    This code will display a table for the identical protein
921    
922    
923    B<Please note> that URL linked to in display_method() is an external component and needs to added to the code for every class of evi
924    dence.
925    
926    =cut
927    
928    sub display {
929        my ($self,$cgi,$dataset, $fid) = @_;
930    
931        my $functional_data = [];
932        my $count = 0;
933        my $content;
934    
935        foreach my $thing (@$dataset) {
936            my $single_domain = [];
937            next if ($thing->class ne "PCH");
938            $count++;
939    
940            # construct the score link
941            my $score = $thing->score;
942            my $toid = $thing->id;
943            my $link = $cgi->url(-relative => 1) . "?user=master&request=show_coupling_evidence&prot=$fid&to=$toid&SPROUT=";
944            my $sc_link = "<a href=$link>$score</a>";
945    
946            push(@$single_domain,$sc_link);
947            push(@$single_domain,$thing->id);
948            push(@$single_domain,$thing->function);
949            push(@$functional_data,$single_domain);
950        }
951    
952        if ($count >0){
953            $content = $functional_data;
954        }
955        else
956        {
957            $content = "<p>This PEG does not have any functional coupling</p>";
958        }
959        return ($content);
960    }
961    
962    
963    #########################################
964    #########################################
965  package Observation::Domain;  package Observation::Domain;
966    
967  use base qw(Observation);  use base qw(Observation);

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3