[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.2, Tue Jun 12 16:51:53 2007 UTC revision 1.6, Mon Jun 18 16:20:45 2007 UTC
# Line 5  Line 5 
5    
6  use strict;  use strict;
7  use warnings;  use warnings;
8    use Table;
9    
10  1;  1;
11    
# Line 88  Line 89 
89  sub description {  sub description {
90    my ($self) = @_;    my ($self) = @_;
91    
92    return $self->{acc};    return $self->{description};
93  }  }
94    
95  =head3 class()  =head3 class()
# Line 100  Line 101 
101    
102  =over 9  =over 9
103    
104  =item sim (seq)  =item SIM (seq)
105    
106  =item bbh (seq)  =item BBH (seq)
107    
108  =item pch (fc)  =item PCH (fc)
109    
110  =item figfam (seq)  =item FIGFAM (seq)
111    
112  =item ipr (dom)  =item IPR (dom)
113    
114  =item cdd (dom)  =item CDD (dom)
115    
116  =item pfam (dom)  =item PFAM (dom)
117    
118  =item signalp (dom)  =item SIGNALP (dom)
119    
120  =item cello (loc)  =item  CELLO(loc)
121    
122  =item tmhmm (loc)  =item TMHMM (loc)
123    
124  =item hmmtop (loc)  =item HMMTOP (loc)
125    
126  =back  =back
127    
# Line 324  Line 325 
325      my $objects = [];      my $objects = [];
326    my @matched_datasets=();    my @matched_datasets=();
327    
328    # call function that fetches attribut based observations    # call function that fetches attribute based observations
329    # returns an array of arrays of hashes    # returns an array of arrays of hashes
330    #    #
331    get_attribute_based_observations($fid,\@matched_datasets);    get_attribute_based_observations($fid,\@matched_datasets);
332    
333      # read sims
334      get_sims_observations($fid,\@matched_datasets);
335    
336      # read identical proteins list of sequences
337      get_identical_proteins($fid,\@matched_datasets);
338    
339      # read functional coupling
340      get_functional_coupling($fid,\@matched_datasets);
341    
342    # read sims + bbh (enrich BBHs with sims coordindates etc)    # read sims + bbh (enrich BBHs with sims coordindates etc)
343    # read pchs    # read pchs
344    # read figfam match data from 48hr directory (BobO knows how do do this!)    # read figfam match data from 48hr directory (BobO knows how do do this!)
# Line 487  Line 497 
497      }      }
498  }  }
499    
500    =head3 get_sims_observations() (internal)
501    
502    This methods retrieves sims fills the internal data structures.
503    
504    =cut
505    
506    sub get_sims_observations{
507    
508        my ($fid,$datasets_ref) = (@_);
509        my $fig = new FIG;
510        my @sims= $fig->nsims($fid,100,1e-20,"fig");
511        my ($dataset);
512        foreach my $sim (@sims){
513            my $hit = $sim->[1];
514            my $evalue = $sim->[10];
515            my $from = $sim->[8];
516            my $to = $sim->[9];
517            $dataset = [ { name => 'class', value => "SIM" },
518                            { name => 'acc' , value => $hit},
519                            { name => 'type', value => "seq"} ,
520                            { name => 'evalue', value => $evalue },
521                            { name => 'start', value => $from},
522                            { name => 'stop' , value => $to}
523                            ];
524        push (@{$datasets_ref} ,$dataset);
525        }
526    }
527    
528    =head3 get_identical_proteins() (internal)
529    
530    This methods retrieves sims fills the internal data structures.
531    
532    =cut
533    
534    sub get_identical_proteins{
535    
536        my ($fid,$datasets_ref) = (@_);
537        my $fig = new FIG;
538        my @funcs = ();
539    
540        my @maps_to = grep { $_ ne $fid and $_ !~ /^xxx/ } map { $_->[0] } $fig->mapped_prot_ids($fid);
541    
542        foreach my $id (@maps_to) {
543            my ($tmp, $who);
544            if (($id ne $fid) && ($tmp = $fig->function_of($id))) {
545                if ($id =~ /^fig\|/)           { $who = "FIG" }
546                elsif ($id =~ /^gi\|/)            { $who = "NCBI" }
547                elsif ($id =~ /^^[NXYZA]P_/)      { $who = "RefSeq" }
548                elsif ($id =~ /^sp\|/)            { $who = "SwissProt" }
549                elsif ($id =~ /^uni\|/)           { $who = "UniProt" }
550                elsif ($id =~ /^tigr\|/)          { $who = "TIGR" }
551                elsif ($id =~ /^pir\|/)           { $who = "PIR" }
552                elsif ($id =~ /^kegg\|/)          { $who = "KEGG" }
553                elsif ($id =~ /^tr\|/)            { $who = "TrEMBL" }
554                elsif ($id =~ /^eric\|/)          { $who = "ASAP" }
555    
556                push(@funcs, [$id,$who,$tmp]);
557            }
558        }
559    
560        my ($dataset);
561        foreach my $row (@funcs){
562            my $id = $row->[0];
563            my $organism = $fig->org_of($fid);
564            my $who = $row->[1];
565            my $assignment = $row->[2];
566            $dataset = [ { name => 'class', value => "IDENTICAL" },
567                         { name => 'id' , value => $id},
568                         { name => 'organism', value => "$organism"} ,
569                         { name => 'database', value => $who },
570                         { name => 'description' , value => $assignment}
571                         ];
572            push (@{$datasets_ref} ,$dataset);
573        }
574    
575    }
576    
577    =head3 get_functional_coupling() (internal)
578    
579    This methods retrieves the functional coupling of a protein given a peg ID
580    
581    =cut
582    
583    sub get_functional_coupling{
584    
585        my ($fid,$datasets_ref) = (@_);
586        my $fig = new FIG;
587        my @funcs = ();
588    
589        # initialize some variables
590        my($sc,$neigh);
591    
592        # set default parameters for coupling and evidence
593        my ($bound,$sim_cutoff,$coupling_cutoff) = (5000, 1.0e-10, 4);
594    
595        # get the fc data
596        my @fc_data = $fig->coupling_and_evidence($fid,$bound,$sim_cutoff,$coupling_cutoff,1);
597    
598        # retrieve data
599        my @rows = map { ($sc,$neigh) = @$_;
600                         [$sc,$neigh,scalar $fig->function_of($neigh)]
601                      } @fc_data;
602    
603        my ($dataset);
604        foreach my $row (@rows){
605            my $id = $row->[1];
606            my $score = $row->[0];
607            my $description = $row->[2];
608            $dataset = [ { name => 'class', value => "FC" },
609                         { name => 'score' , value => $score},
610                         { name => 'id', value => "$id"} ,
611                         { name => 'description' , value => $description}
612                         ];
613            push (@{$datasets_ref} ,$dataset);
614        }
615    }
616    
617  =head3 get_sims_and_bbhs() (internal)  =head3 get_sims_and_bbhs() (internal)
618    
619  This methods retrieves sims and also BBHs and fills the internal data structures.  This methods retrieves sims and also BBHs and fills the internal data structures.
# Line 552  Line 679 
679              display_method => '',              display_method => '',
680              feature_id => '',              feature_id => '',
681              rank => '',              rank => '',
682              supports_annotation => ''              supports_annotation => '',
683                id => '',
684                organism => '',
685                who => ''
686            };            };
687    
688    bless($self, 'Observation');    bless($self, 'Observation');
# Line 571  Line 701 
701    
702    return $self->{feature_id};    return $self->{feature_id};
703  }  }
704    
705    =head3 id (internal)
706    
707    Returns the ID  of the identical sequence
708    
709    =cut
710    
711    sub id {
712        my ($self) = @_;
713    
714        return $self->{id};
715    }
716    
717    =head3 organism (internal)
718    
719    Returns the organism  of the identical sequence
720    
721    =cut
722    
723    sub organism {
724        my ($self) = @_;
725    
726        return $self->{organism};
727    }
728    
729    =head3 database (internal)
730    
731    Returns the database of the identical sequence
732    
733    =cut
734    
735    sub database {
736        my ($self) = @_;
737    
738        return $self->{database};
739    }
740    
741    #package Observation::Identical;
742    #1;
743    #
744    #our @ISA = qw(Observation);  # inherits all the methods from Observation
745    
746    =head3 display_identical()
747    
748    If available use the function specified here to display the "raw" observation.
749    This code will display a table for the identical protein
750    
751    
752    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.
753    
754    =cut
755    
756    sub display_identical {
757        my ($self, $fid, $cgi) = @_;
758    
759        my $content;
760        my $array=Observation->get_objects($fid);
761    
762        my $all_domains = [];
763        my $count_identical = 0;
764        foreach my $thing (@$array) {
765            next if ($thing->class ne "IDENTICAL");
766            my $single_domain = [];
767            push(@$single_domain,$thing->class);
768            my $id = $thing->id;
769            $count_identical++;
770            push(@$single_domain,&HTML::set_prot_links($cgi,$id));
771            push(@$single_domain,$thing->organism);
772            push(@$single_domain,$thing->database);
773            push(@$single_domain,$thing->description);
774            push(@$all_domains,$single_domain);
775        }
776    
777        if ($count_identical >0){
778            my $table_component = $self->application->component('DomainTable');
779    
780            $table_component->columns ([ { 'name' => 'Name', 'filter' => 1 },
781                                         { 'name' => 'ID' },
782                                         { 'name' => 'Organism' },
783                                         { 'name' => 'Database' },
784                                         { 'name' => 'Assignment' }
785                                         ]);
786            $table_component->data($all_domains);
787            $table_component->show_top_browse(1);
788            $table_component->show_bottom_browse(1);
789            $table_component->items_per_page(50);
790            $table_component->show_select_items_per_page(1);
791            $content .= $table_component->output();
792        }
793        else{
794            $content = "<p>This PEG does not have any essentially identical proteins</p>";
795        }
796        return ($content);
797    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3