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

Diff of /FigKernelPackages/FIGO.pm

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

revision 1.5, Thu Feb 22 03:54:53 2007 UTC revision 1.18, Tue Mar 13 02:38:06 2007 UTC
# Line 1  Line 1 
1    ########################################################################
2  #  #
3  # Copyright (c) 2003-2006 University of Chicago and Fellowship  # Copyright (c) 2003-2006 University of Chicago and Fellowship
4  # for Interpretations of Genomes. All Rights Reserved.  # for Interpretations of Genomes. All Rights Reserved.
# Line 14  Line 15 
15  # Genomes at veronika@thefig.info or download a copy from  # Genomes at veronika@thefig.info or download a copy from
16  # http://www.theseed.org/LICENSE.TXT.  # http://www.theseed.org/LICENSE.TXT.
17  #  #
18    ########################################################################
19    
20  package FIGO;  =head1 Overview
21    
22    This module is a set of packages encapsulating the SEED's core methods
23    using an "OOP-like" style.
24    
25    There are several modules clearly related to "individual genomes:"
26    FIGO, GenomeO, ContigO, FeatureO (and I<maybe> AnnotationO).
27    
28    There are also modules that deal with complex relationships between
29    pairs or sets of features in one, two, or more genomes,
30    rather than any particular single genome:
31    BBHO, CouplingO, SubsystemO, FunctionalRoleO, FigFamO.
32    
33    Finally, the methods in "Attribute" might in principle attach
34    "atributes" to any type of object.
35    (Likewise, in principle one might like to attach an "annotation"
36    to any type of object
37    
38    Four of the modules dealing with "genomes" have a reasonable clear
39    "implied heirarchy:"
40    
41    =over 4
42    
43        FIGO > GenomeO > ContigO > FeatureO
44    
45    =back
46    
47    However, inheritance is B<NOT> implemented using the C<@ISA> mechanism,
48    because some methods deal with "pairwise" or "setwise" relations between objects
49    or other more complex relationships that do not naturally fit into any heirarchy ---
50    which would get us into the whole quagmire of "multiple inheritance."
51    
52    We have chosen to in many cases sidestep the entire issue of inheritance
53    via an I<ad hoc> mechanism:
54    If a "child" object needs access to its "ancestors'" methods,
55    we pass it references to its "ancestors" using subroutine arguments.
56    This is admittedly ugly, clumsy, and potentially error-prone ---
57    but it has the advantage that, unlike multiple inheritance,
58    we understand how to do it...
59    
60    MODULE DEPENDENCIES: FIG, FIG_Config, FigFams, SFXlate, SproutFIG, Tracer,
61        gjoparseblast, Data::Dumper.
62    
63    =cut
64    
65    ########################################################################
66    package FIGO;
67    ########################################################################
68  use strict;  use strict;
69  use FIG;  use FIG;
70  use FIG_Config;  use FIG_Config;
# Line 27  Line 75 
75  use FigFams;  use FigFams;
76  use gjoparseblast;  use gjoparseblast;
77    
78  =head1 FIGO Methods  =head1 FIGO
79    
80    The effective "base class" containing a few "top-level" methods.
81    
82    =cut
83    
84    
85  =head3 new  =head3 new
86    
# Line 80  Line 133 
133  C<< my @tax_ids = $figo->genomes( @constraints ); >>  C<< my @tax_ids = $figo->genomes( @constraints ); >>
134    
135  =item @constraints  =item @constraints
136    
137  One or more element of: complete, prokaryotic, eukaryotic, bacterial, archaeal, nmpdr.  One or more element of: complete, prokaryotic, eukaryotic, bacterial, archaeal, nmpdr.
138    
139  =item RETURNS: List of Tax-IDs.  =item RETURNS: List of Tax-IDs.
140    
141  =item EXAMPLE: L<Display all complete, prokaryotic genomes>  =item EXAMPLE:
142    
143    L<Display all complete, prokaryotic genomes>
144    
145  =back  =back
146    
# Line 141  Line 197 
197  =over4  =over4
198    
199  =item RETURNS:  =item RETURNS:
200    
201  List of all subsystems.  List of all subsystems.
202    
203  =item EXAMPLE: L<Accessing Subsystem data>  =item EXAMPLE:
204    
205    L<Accessing Subsystem data>
206    
207  =back  =back
208    
# Line 188  Line 247 
247    
248  =over4  =over4
249    
250  =item USAGE:  C<< foreach $fam ($figO->all_figfams) { #...Do something } >>  =item USAGE:
251    
252    C<< foreach $fam ($figO->all_figfams) { #...Do something } >>
253    
254  =item RETURNS: List of FIGfam Objects  =item RETURNS:
255    
256  =item EXAMPLE: L<Accessing FIGfams>      List of FIGfam Objects
257    
258    =item EXAMPLE:
259    
260    L<Accessing FIGfams>
261    
262  =back  =back
263    
# Line 211  Line 276 
276    
277  =over4  =over4
278    
279  =item USAGE:   C<< my ($fam, $sims) = $figO->family_containing($seq); >>  =item USAGE:
280    
281    C<< my ($fam, $sims) = $figO->family_containing($seq); >>
282    
283    =item $seq:
284    
285  =item $seq:    A protein translation string.      A protein translation string.
286    
287  =item RETURNS:  =item RETURNS:
288    
289        $fam:  A FIGfam Object.        $fam:  A FIGfam Object.
290    
291        $sims: A set of similarity objects.        $sims: A set of similarity objects.
292    
293  =item EXAMPLE: L<Placing a sequence into a FIGfam>  =item EXAMPLE: L<Placing a sequence into a FIGfam>
# Line 241  Line 312 
312      }      }
313  }  }
314    
315    =head3 figfam
316    
317    =over 4
318    
319    =item USAGE:
320    
321    C<< my $fam = $figO->figfam($family_id); >>
322    
323    =item $family_id;
324    
325        A FigFam ID
326    
327    =item RETURNS:
328    
329          $fam:  A FIGfam Object.
330    
331    =back
332    
333    =cut
334    
335    sub figfam {
336        my($self,$fam_id) = @_;
337    
338        return &FigFamO::new('FigFamO',$self,$fam_id);
339    }
340    
341    
342  ########################################################################  ########################################################################
343  package GenomeO;  package GenomeO;
# Line 251  Line 348 
348    
349  =cut  =cut
350    
351    
352  =head3 new  =head3 new
353    
354  Constructor of GenomeO objects.  Constructor of GenomeO objects.
# Line 258  Line 356 
356  =over4  =over4
357    
358  =item USAGE:  =item USAGE:
359    
360  C<< my $org = GenomeO->new($figo, $tax_id); >>  C<< my $org = GenomeO->new($figo, $tax_id); >>
361    
362  =item RETURNS: A new GenomeO object.  =item RETURNS:
363    
364        A new GenomeO object.
365    
366  =back  =back
367    
# Line 281  Line 382 
382    
383  =over4  =over4
384    
385  =item USAGE:   C<< my $tax_id = $org->id(); >>  =item USAGE:
386    
387    C<< my $tax_id = $org->id(); >>
388    
389    =item RETURNS:
390    
391  =item RETURNS: Taxonomy-ID of GenomeO object.      Taxonomy-ID of GenomeO object.
392    
393  =back  =back
394    
# Line 301  Line 406 
406    
407  =over4  =over4
408    
409  =item USAGE:   C<< $gs = $genome->genus_species(); >>  =item USAGE:
410    
411    C<< $gs = $genome->genus_species(); >>
412    
413    =item RETURNS:
414    
415  =item RETURNS: Genus-species-strain string      Genus-species-strain string
416    
417  =back  =back
418    
# Line 321  Line 430 
430    
431  =over4  =over4
432    
433  =item RETURNS: List of C<contig> objects contained in a C<GenomeO> object.  =item RETURNS:
434    
435        List of C<contig> objects contained in a C<GenomeO> object.
436    
437    =item EXAMPLE:
438    
439  =item EXAMPLE: L<Show how to access contigs and extract sequence>  L<Show how to access contigs and extract sequence>
440    
441  =back  =back
442    
# Line 359  Line 472 
472    
473  =over4  =over4
474    
475  =item USAGE:   C<< $genome->display(); >>  =item USAGE:
476    
477    C<< $genome->display(); >>
478    
479    =item RETURNS:
480    
481  =item RETURNS: Null      (Void)
482    
483  =back  =back
484    
# Line 393  Line 510 
510  =over4  =over4
511    
512  =item USAGE:  =item USAGE:
513    
514  C<< $contig = ContigO->new( $figO, $genomeId, $contigId); >>  C<< $contig = ContigO->new( $figO, $genomeId, $contigId); >>
515    
516  =item $figO: A FIGO object.  =item $figO:
517    
518        Parent FIGO object.
519    
520    =item $genomeId:
521    
522  =item $genomeId: Taxon-ID for the genome the contig is from.      Taxon-ID for the genome the contig is from.
523    
524  =item $contigId: Identifier for the contig  =item $contigId:
525    
526        Identifier for the contig
527    
528    =item RETURNS:
529    
530  =item RETURNS: A "ContigO" object.      A "ContigO" object.
531    
532  =back  =back
533    
# Line 423  Line 549 
549    
550  =over4  =over4
551    
552  =item RETURNS: Sequence ID string of "ContigO" object  =item RETURNS:
553    
554        Sequence ID string of "ContigO" object
555    
556  =back  =back
557    
# Line 441  Line 569 
569  =over4  =over4
570    
571  =item USAGE:  =item USAGE:
     C<< my $tax_id = $contig->genome(); >>  
572    
573  =item RETURNS: GenomeO object containing the contig object.  C<< my $tax_id = $contig->genome->id(); >>
574    
575    =item RETURNS:
576    
577        Tax-ID of the GenomeO object containing the contig object.
578    
579  =back  =back
580    
# Line 452  Line 583 
583  sub genome {  sub genome {
584      my($self) = @_;      my($self) = @_;
585    
586      return $self->{_genome};      my $figO = $self->{_figO};
587        return new GenomeO($figO,$self->{_genome});
588  }  }
589    
590    
# Line 462  Line 594 
594  =over4  =over4
595    
596  =item USAGE:  =item USAGE:
597    
598      C<< my $len = $contig->contig_length(); >>      C<< my $len = $contig->contig_length(); >>
599    
600  =item RETURNS: Length of contig's DNA sequence.  =item RETURNS:
601    
602        Length of contig's DNA sequence.
603    
604  =back  =back
605    
# Line 474  Line 609 
609      my($self) = @_;      my($self) = @_;
610    
611      my $fig = $self->{_figO}->{_fig};      my $fig = $self->{_figO}->{_fig};
612      my $contig_lengths = $fig->contig_lengths($self->genome);      my $contig_lengths = $fig->contig_lengths($self->genome->id);
613      return $contig_lengths->{$self->id};      return $contig_lengths->{$self->id};
614  }  }
615    
# Line 484  Line 619 
619  =over4  =over4
620    
621  =item USAGE:  =item USAGE:
622    
623      C<< my $seq = $contig->dna_seq(beg, $end); >>      C<< my $seq = $contig->dna_seq(beg, $end); >>
624    
625  =item $beg: Begining point of DNA subsequence  =item $beg:
626    
627        Begining point of DNA subsequence
628    
629  =item $end: End point of DNA subsequence  =item $end:
630    
631  =item RETURNS: string of DNA sequence from $beg to $end      End point of DNA subsequence
632    
633    =item RETURNS:
634    
635        string of DNA sequence running from $beg to $end
636  (NOTE: if $beg > $end, returns reverse complement of DNA subsequence.)  (NOTE: if $beg > $end, returns reverse complement of DNA subsequence.)
637    
638  =back  =back
# Line 506  Line 647 
647      if (($beg && (&FIG::between(1,$beg,$max))) &&      if (($beg && (&FIG::between(1,$beg,$max))) &&
648          ($end && (&FIG::between(1,$end,$max))))          ($end && (&FIG::between(1,$end,$max))))
649      {      {
650          return $fig->dna_seq($self->genome,join("_",($self->id,$beg,$end)));          return $fig->dna_seq($self->genome->id,join("_",($self->id,$beg,$end)));
651      }      }
652      else      else
653      {      {
# Line 527  Line 668 
668    
669  =over4  =over4
670    
671  =item RETURNS: Nil  =item RETURNS:
672    
673        (Void)
674    
675  =back  =back
676    
# Line 536  Line 679 
679  sub display {  sub display {
680      my($self) = @_;      my($self) = @_;
681    
682      print join("ContigO",$self->genome,$self->id,$self->contig_length),"\n";      print join("ContigO",$self->genome->id,$self->id,$self->contig_length),"\n";
683    }
684    
685    sub features_in_region {
686        my($self,$beg,$end) = @_;
687        my $figO = $self->{_figO};
688        my $fig = $figO->{_fig};
689    
690        my($features) = $fig->genes_in_region($self->genome->id,$self->id,$beg,$end);
691        return map { new FeatureO($figO,$_) } @$features;
692  }  }
693    
694    
# Line 548  Line 700 
700    
701  =head1 FeatureO  =head1 FeatureO
702    
703  =cut  Methods for working with features on "ContigO" objects.
704    
705    =cut
706    
707    
708  =head1 new  =head3 new
709    
710  Constructor of "FeatureO" objects  Constructor of "FeatureO" objects
711    
712    =over 4
713    
714    =item USAGE:
715    
716    C<< my $feature = FeatureO->new( $figO, $fid ); >>
717    
718    =item C<$figO>:
719    
720    "Base" FIGO object.
721    
722    =item C<$fid>:
723    
724    Feature-ID for new feature
725    
726    =item RETURNS:
727    
728    A newly created "FeatureO" object.
729    
730    =back
731    
732  =cut  =cut
733    
734  sub new {  sub new {
# Line 569  Line 742 
742  }  }
743    
744    
745    
746  =head3 id  =head3 id
747    
748    =over 4
749    
750    =item USAGE:
751    
752    C<< my $fid = $feature->id(); >>
753    
754    =item RETURNS:
755    
756    The FID (Feature ID) of a "FeatureO" object.
757    
758    =back
759    
760  =cut  =cut
761    
762  sub id {  sub id {
# Line 583  Line 769 
769    
770  =head3 genome  =head3 genome
771    
772    =over 4
773    
774    =item USAGE:
775    
776    C<< my $taxid = $feature->genome(); >>
777    
778    =item RETURNS:
779    
780    The TAxon-ID for the "GenomeO" object containg the feature.
781    
782    =back
783    
784  =cut  =cut
785    
786  sub genome {  sub genome {
787      my($self) = @_;      my($self) = @_;
788        my $figO = $self->{_figO};
789      $self->id =~ /^fig\|(\d+\.\d+)/;      $self->id =~ /^fig\|(\d+\.\d+)/;
790      return $1;      return new GenomeO($figO,$1);
791  }  }
792    
793    
794    
795  =head3 type  =head3 type
796    
797    =over 4
798    
799    =item USAGE:
800    
801    C<< my $feature_type = $feature->type(); >>
802    
803    =item RETURNS:
804    
805    The feature object's "type" (e.g., "peg," "rna," etc.)
806    
807    =back
808    
809  =cut  =cut
810    
811  sub type {  sub type {
# Line 607  Line 817 
817    
818    
819    
   
820  =head3 location  =head3 location
821    
822    =over 4
823    
824    =item USAGE:
825    
826    C<< my $loc = $feature->location(); >>
827    
828    =item RETURNS:
829    
830    A string representing the feature object's location on the genome's DNA,
831    in SEED "tbl format" (i.e., "contig_beging_end").
832    
833    =back
834    
835  =cut  =cut
836    
837  sub location {  sub location {
# Line 620  Line 842 
842  }  }
843    
844    
845    =head3 contig
846    
847    =over 4
848    
849    =item USAGE:
850    
851    C<< my $contig = $feature->contig(); >>
852    
853    =item RETURNS:
854    
855    A "ContigO" object to access the contig data
856    for the contig the feature is on.
857    
858    =back
859    
860    =cut
861    
862    sub contig {
863        my($self) = @_;
864    
865        my $figO = $self->{_figO};
866        my $loc      = $self->location;
867        my $genomeID = $self->genome->id;
868        return ($loc =~ /^(\S+)_\d+_\d+$/) ? new ContigO($figO,$genomeID,$1) : undef;
869    }
870    
871    
872    
873    =head3 begin
874    
875    =over 4
876    
877    =item USAGE:
878    
879    C<< my $beg = $feature->begin(); >>
880    
881    =item RETURNS:
882    
883    The numerical coordinate of the first base of the feature.
884    
885    =back
886    
887    =cut
888    
889    sub begin {
890        my($self) = @_;
891    
892        my $loc = $self->location;
893        return ($loc =~ /^\S+_(\d+)_\d+$/) ? $1 : undef;
894    }
895    
896    
897    
898    =head3 end
899    
900    =over 4
901    
902    =item USAGE:
903    
904    C<< my $end = $feature->end(); >>
905    
906    =item RETURNS:
907    
908    The numerical coordinate of the last base of the feature.
909    
910    =back
911    
912    =cut
913    
914    sub end {
915        my($self) = @_;
916    
917        my $loc = $self->location;
918        return ($loc =~ /^\S+_\d+_(\d+)$/) ? $1 : undef;
919    }
920    
921    
922    
923  =head3 dna_seq  =head3 dna_seq
924    
925    =over 4
926    
927    =item USAGE:
928    
929    C<< my $dna_seq = $feature->dna_seq(); >>
930    
931    =item RETURNS:
932    
933    A string contining the DNA subsequence of the contig
934    running from the first to the last base of the feature.
935    
936    If ($beg > $end), the reverse complement subsequence is returned.
937    
938    =back
939    
940  =cut  =cut
941    
942  sub dna_seq {  sub dna_seq {
# Line 638  Line 952 
952    
953  =head3 prot_seq  =head3 prot_seq
954    
955    =over 4
956    
957    =item USAGE:
958    
959    C<< my $dna_seq = $feature->prot_seq(); >>
960    
961    =item RETURNS:
962    
963    A string contining the protein translation of the feature (if it exists),
964    or the "undef" value if the feature does not exist or is not a PEG.
965    
966    =back
967    
968  =cut  =cut
969    
970  sub prot_seq {  sub prot_seq {
# Line 653  Line 980 
980    
981  =head3 function_of  =head3 function_of
982    
983    =over 4
984    
985    =item USAGE:
986    
987    C<< my $func = $feature->function_of(); >>
988    
989    =item RETURNS:
990    
991    A string containing the function assigned to the feature,
992    or the "undef" value if no function has been assigned.
993    
994    =back
995    
996  =cut  =cut
997    
998  sub function_of {  sub function_of {
# Line 667  Line 1007 
1007    
1008  =head3 coupled_to  =head3 coupled_to
1009    
1010    =over 4
1011    
1012    =item USAGE:
1013    
1014    C<< my @coupled_features = $feature->coupled_to(); >>
1015    
1016    =item RETURNS:
1017    
1018    A list of L<CouplingO> objects describing the evidence for functional coupling
1019    between this feature and other nearby features.
1020    
1021    =back
1022    
1023  =cut  =cut
1024    
1025  sub coupled_to {  sub coupled_to {
1026      my($self) = @_;      my($self) = @_;
1027    
1028      ($self->type eq "peg") || return undef;      ($self->type eq "peg") || return ();
1029      my $figO = $self->{_figO};      my $figO = $self->{_figO};
1030      my $fig  = $figO->{_fig};      my $fig  = $figO->{_fig};
1031      my $peg1 = $self->id;      my $peg1 = $self->id;
# Line 689  Line 1042 
1042    
1043  =head3 annotations  =head3 annotations
1044    
1045    =over 4
1046    
1047    =item USAGE:
1048    
1049    C<< my @annot_list = $feature->annotations(); >>
1050    
1051    =item RETURNS:
1052    
1053    A list of L<AnnotationO> objects allowing access to the annotations for this feature.
1054    
1055    =back
1056    
1057  =cut  =cut
1058    
1059  sub annotations {  sub annotations {
# Line 700  Line 1065 
1065      return map { &AnnotationO::new('AnnotationO',@$_) } $fig->feature_annotations($self->id,1);      return map { &AnnotationO::new('AnnotationO',@$_) } $fig->feature_annotations($self->id,1);
1066  }  }
1067    
1068    
1069    =head3 in_subsystems
1070    
1071    =over 4
1072    
1073    =item USAGE:
1074    
1075    C<< my @subsys_list = $feature->in_subsystems(); >>
1076    
1077    =item RETURNS:
1078    
1079    A list of L<SubsystemO> objects allowing access to the subsystems
1080    that this feature particupates in.
1081    
1082    =back
1083    
1084    =cut
1085    
1086  sub in_subsystems {  sub in_subsystems {
1087      my($self) = @_;      my($self) = @_;
1088      my $figO = $self->{_figO};      my $figO = $self->{_figO};
# Line 711  Line 1094 
1094    
1095  =head3 possibly_truncated  =head3 possibly_truncated
1096    
1097    =over 4
1098    
1099    =item USAGE:
1100    
1101    C<< my $trunc = $feature->possibly_truncated(); >>
1102    
1103    =item RETURNS:
1104    
1105    Boolean C<TRUE> if the feature may be truncated;
1106    boolean C<FALSE> otherwise.
1107    
1108    =back
1109    
1110  =cut  =cut
1111    
1112  sub possibly_truncated {  sub possibly_truncated {
# Line 725  Line 1121 
1121    
1122  =head3 possible_frameshift  =head3 possible_frameshift
1123    
1124    =over 4
1125    
1126    =item USAGE:
1127    
1128    C<< my $fs = $feature->possible_frameshift(); >>
1129    
1130    =item RETURNS:
1131    
1132    Boolean C<TRUE> if the feature may be a frameshifted fragment;
1133    boolean C<FALSE> otherwise.
1134    
1135    (NOTE: This is a crude prototype implementation,
1136    and is mostly as an example of how to code using FIGO.)
1137    
1138    =back
1139    
1140  =cut  =cut
1141    
1142  sub possible_frameshift {  sub possible_frameshift {
# Line 752  Line 1164 
1164                      my $contig = $1;                      my $contig = $1;
1165                      my $beg    = $2;                      my $beg    = $2;
1166                      my $end = $3;                      my $end = $3;
1167                      my $contigO = new ContigO($figO,$self->genome,$contig);                      my $contigO = new ContigO($figO,$self->genome->id,$contig);
1168                      my $begA = &max(1,$beg - $adjL);                      my $begA = &max(1,$beg - $adjL);
1169                      my $endA = &min($end+$adjR,$contigO->contig_length);                      my $endA = &min($end+$adjR,$contigO->contig_length);
1170                      my $dna  = $contigO->dna_seq($begA,$endA);                      my $dna  = $contigO->dna_seq($begA,$endA);
# Line 776  Line 1188 
1188                                       @{$db_seq_out->[6]};                                       @{$db_seq_out->[6]};
1189                      my @prot = map { [$_->[0],$_->[1]] } @hsps;                      my @prot = map { [$_->[0],$_->[1]] } @hsps;
1190                      my @dna  = map { [$_->[2],$_->[3]] } @hsps;                      my @dna  = map { [$_->[2],$_->[3]] } @hsps;
1191                      if (&covers(\@prot,length($prot),3) && &covers(\@dna,3*length($prot),9))                      if (&covers(\@prot,length($prot),3,0) && &covers(\@dna,3*length($prot),9,1))
1192                      {                      {
1193                          return 1;                          return 1;
1194                      }                      }
# Line 791  Line 1203 
1203    
1204  =head3 run  =head3 run
1205    
1206    (Note: This function should be considered "PRIVATE")
1207    
1208    =over 4
1209    
1210    =item FUNCTION:
1211    
1212    Passes a string containing a command to be execture by the "system" shell command.
1213    
1214    =item USAGE:
1215    
1216    C<< $feature->run($cmd); >>
1217    
1218    =item RETURNS:
1219    
1220    Nil if the execution of C<$cmd> was successful;
1221    aborts with traceback if C<$cmd> fails.
1222    
1223    =back
1224    
1225  =cut  =cut
1226    
1227  sub run {  sub run {
# Line 802  Line 1233 
1233    
1234  =head3 max  =head3 max
1235    
1236    (Note: This function should be considered "PRIVATE")
1237    
1238    =over 4
1239    
1240    =item USAGE:
1241    
1242    C<< my $max = $feature->max($x, $y); >>
1243    
1244    =item C<$x>
1245    
1246    Numerical value.
1247    
1248    =item C<$y>
1249    
1250    Numerical value.
1251    
1252    =items RETURNS:
1253    
1254    The larger of the two numerical values C<$x> and C<$y>.
1255    
1256    =back
1257    
1258  =cut  =cut
1259    
1260  sub max {  sub max {
# Line 813  Line 1266 
1266    
1267  =head3 min  =head3 min
1268    
1269    (Note: This function should be considered "PRIVATE")
1270    
1271    =over 4
1272    
1273    =item USAGE:
1274    
1275    C<< my $min = $feature->min($x, $y); >>
1276    
1277    =item C<$x>
1278    
1279    Numerical value.
1280    
1281    =item C<$y>
1282    
1283    Numerical value.
1284    
1285    =item RETURNS:
1286    
1287    The smaller of the two numerical values C<$x> and C<$y>.
1288    
1289    =back
1290    
1291  =cut  =cut
1292    
1293  sub min {  sub min {
# Line 824  Line 1299 
1299    
1300  =head3 covers  =head3 covers
1301    
1302    (Question: Should this function be considered "PRIVATE" ???)
1303    
1304    USAGE:
1305        C<< if (&covers(\@hits, $len, $diff, $must_shift)) { #...Do stuff } >>
1306    
1307    Returns boolean C<TRUE> if a set of BLAST HSPs "cover" more than 90%
1308    of the database sequence(?).
1309    
1310  =cut  =cut
1311    
1312  sub covers {  sub covers {
1313      my($hsps,$ln,$diff) = @_;      my($hsps,$ln,$diff,$must_shift) = @_;
1314    
1315      my $hsp1 = shift @$hsps;      my $hsp1 = shift @$hsps;
1316      my $hsp2;      my $hsp2;
1317      while ($hsp1 && ($hsp2 = shift @$hsps) && ($hsp1 = &merge($hsp1,$hsp2,$diff))) {}      my $merged = 0;
1318      return ($hsp1 && (($hsp1->[1] - $hsp1->[0]) > (0.9 * $ln)));      while ($hsp1 && ($hsp2 = shift @$hsps) &&
1319               ($must_shift ? &diff_frames($hsp1,$hsp2) : 1) &&
1320               ($hsp1 = &merge($hsp1,$hsp2,$diff))) { $merged = 1 }
1321        return ($merged && $hsp1 && (($hsp1->[1] - $hsp1->[0]) > (0.9 * $ln)));
1322    }
1323    
1324    sub diff_frames {
1325        my($hsp1,$hsp2) = @_;
1326        return (($hsp1->[0] % 3) != ($hsp2->[0] % 3));
1327  }  }
1328    
1329    
1330    
1331  =head3 merge  =head3 merge
1332    
1333    Merge two HSPs unless their overlap or separation is too large.
1334    
1335    RETURNS: Merged boundaries if merger succeeds, and C<undef> if merger fails.
1336    
1337  =cut  =cut
1338    
1339  sub merge {  sub merge {
# Line 853  Line 1348 
1348    
1349  =head3 sims  =head3 sims
1350    
1351    =over 4
1352    
1353    =item FUNCTION:
1354    
1355    Returns precomputed "Sim.pm" objects from the SEED.
1356    
1357    =item USAGE:
1358    
1359    C<< my @sims = $pegO->sims( -all, -cutoff => 1.0e-10); >>
1360    
1361    C<< my @sims = $pegO->sims( -max => 50, -cutoff => 1.0e-10); >>
1362    
1363    =item RETURNS: List of sim objects.
1364    
1365    =back
1366    
1367  =cut  =cut
1368    
1369  use Sim;  use Sim;
# Line 873  Line 1384 
1384    
1385  =head3 bbhs  =head3 bbhs
1386    
1387    =over 4
1388    
1389    =item FUNCTION:
1390    
1391    Given a PEG-type "FeatureO" object, returns the list of BBHO objects
1392    corresponding to the pre-computed BBHs for that PEG.
1393    
1394    =item USAGE:
1395    
1396    C<< my @bbhs = $pegO->bbhs(); >>
1397    
1398    =item List of BBHO objects.
1399    
1400    =back
1401    
1402  =cut  =cut
1403    
1404  sub bbhs {  sub bbhs {
# Line 882  Line 1408 
1408      my $fig  = $figO->{_fig};      my $fig  = $figO->{_fig};
1409    
1410      my @bbhs  = $fig->bbhs($self->id);      my @bbhs  = $fig->bbhs($self->id);
1411      return map { my($peg2,$sc,$bs) = @$_; bless({ _peg1 => $self->id,      return map { my($peg2,$sc,$bs) = @$_; bless({ _figO => $figO,
1412                                                      _peg1 => $self->id,
1413                                                    _peg2 => $peg2,                                                    _peg2 => $peg2,
1414                                                    _psc => $sc,                                                    _psc => $sc,
1415                                                    _bit_score => $bs                                                    _bit_score => $bs
# Line 891  Line 1418 
1418    
1419  =head3 display  =head3 display
1420    
1421    Prints info about a "FeatureO" object to STDOUT.
1422    
1423    USAGE:
1424    
1425    C<< $pegO->display(); >>
1426    
1427  =cut  =cut
1428    
1429  sub display {  sub display {
# Line 909  Line 1442 
1442    
1443  =head1 BBHO  =head1 BBHO
1444    
1445    Methods for accessing "Bidirectiona Best Hits" (BBHs).
1446    
1447  =cut  =cut
1448    
1449    
1450  =head3 new  =head3 new
1451    
1452    Constructor of BBHO objects.
1453    
1454    (NOTE: The "average user" should never need to invoke this method.)
1455    
1456  =cut  =cut
1457    
1458  sub new {  sub new {
1459      my($class,$peg1,$peg2,$sc,$normalized_bitscore) = @_;      my($class,$figO,$peg1,$peg2,$sc,$normalized_bitscore) = @_;
1460    
1461      my $self = {};      my $self = {};
1462        $self->{_figO}      = $figO;
1463      $self->{_peg1}      = $peg1;      $self->{_peg1}      = $peg1;
1464      $self->{_peg2}      = $peg2;      $self->{_peg2}      = $peg2;
1465      $self->{_psc}       = $sc;      $self->{_psc}       = $sc;
# Line 928  Line 1468 
1468  }  }
1469    
1470    
1471    
1472  =head3 peg1  =head3 peg1
1473    
1474    =over 4
1475    
1476    =item USAGE:
1477    
1478    C<< my $peg1 = $bbh->peg1(); >>
1479    
1480    =item RETURNS:
1481    
1482    A "FeatureO" object corresponding to the "query" sequence
1483    in a BBH pair.
1484    
1485    =back
1486    
1487  =cut  =cut
1488    
1489  sub peg1 {  sub peg1 {
1490      my($self) = @_;      my($self) = @_;
1491    
1492      return $self->{_peg1};      my $figO = $self->{_figO};
1493        return new FeatureO($figO,$self->{_peg1});
1494  }  }
1495    
1496    =head3 peg2
1497    
1498    =over 4
1499    
1500  =head3 peg1  =item USAGE:
1501    
1502    C<< my $peg2 = $bbh->peg2(); >>
1503    
1504    =item RETURNS:
1505    
1506    A "FeatureO" object corresponding to the "database" sequence
1507    in a BBH pair.
1508    
1509    =back
1510    
1511  =cut  =cut
1512    
1513  sub peg2 {  sub peg2 {
1514      my($self) = @_;      my($self) = @_;
1515    
1516      return $self->{_peg2};      my $figO = $self->{_figO};
1517        return new FeatureO($figO,$self->{_peg2});
1518  }  }
1519    
1520    
1521    
1522  =head3 psc  =head3 psc
1523    
1524    =over 4
1525    
1526    =item USAGE:
1527    
1528    C<< my $psc = $bbh->psc(); >>
1529    
1530    =item RETURNS:
1531    
1532    The numerical value of the BLAST E-value for the pair.
1533    
1534    =back
1535    
1536  =cut  =cut
1537    
1538  sub psc {  sub psc {
# Line 966  Line 1545 
1545    
1546  =head3 norm_bitscore  =head3 norm_bitscore
1547    
1548    
1549    =over 4
1550    
1551    =item USAGE:
1552    
1553    C<< my $bsc = $bbh->norm_bitscore(); >>
1554    
1555    =item RETURNS:
1556    
1557    The "BLAST bit-score per aligned character" for the pair.
1558    
1559    =back
1560    
1561  =cut  =cut
1562    
1563  sub norm_bitscore {  sub norm_bitscore {
# Line 982  Line 1574 
1574    
1575  =head1 AnnotationO  =head1 AnnotationO
1576    
1577    Methods for accessing SEED annotations.
1578    
1579  =cut  =cut
1580    
1581    
# Line 1077  Line 1671 
1671  ########################################################################  ########################################################################
1672  use Data::Dumper;  use Data::Dumper;
1673    
1674    =head1 CouplingO
1675    
1676    Methods for accessing the "Functional coupling scores"
1677    of PEGs in close physical proximity to each other.
1678    
1679    =cut
1680    
1681    
1682    
1683  =head3 new  =head3 new
1684    
1685  =cut  =cut
# Line 1210  Line 1813 
1813    
1814  =head3 usable  =head3 usable
1815    
1816    
1817  =cut  =cut
1818    
1819  sub usable {  sub usable {
# Line 1310  Line 1914 
1914    
1915  =head1 FunctionalRoleO  =head1 FunctionalRoleO
1916    
1917    Methods for accessing the functional roles of features.
1918    
1919  =cut  =cut
1920    
1921    
# Line 1406  Line 2012 
2012      my $famO = $self->{_famO};      my $famO = $self->{_famO};
2013      if (! $famO) { $famO = $self->{_famO} = &FigFam::new('FigFam',$fig,$self->id) }      if (! $famO) { $famO = $self->{_famO} = &FigFam::new('FigFam',$fig,$self->id) }
2014    
2015      return map { &FigFamO::new('FigFamO',$figO,$_) } $famO->list_members;      return map { &FeatureO::new('FeatureO',$figO,$_) } $famO->list_members;
2016  }  }
2017    
   
   
2018  =head3 rep_seqs  =head3 rep_seqs
2019    
2020  =cut  =cut
# Line 1462  Line 2066 
2066  ########################################################################  ########################################################################
2067  =head1 Attribute  =head1 Attribute
2068    
2069    (Note yet implemented.)
2070    
2071  =cut  =cut
2072    
2073  1;  1;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.18

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3