[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.8, Thu Feb 22 14:28:32 2007 UTC revision 1.12, Tue Feb 27 08:31:50 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 sidestep the entire issue of inheritance via an I<ad hoc> mechanism:
53    If a "child" object needs access to its "ancestors'" methods,
54    we pass it references to its "ancestors" using subroutine arguments.
55    This is admittedly ugly, clumsy, and potentially error-prone ---
56    but it has the advantage that, unlike multiple inheritance,
57    we understand how to do it...
58    
59    MODULE DEPENDENCIES: FIG, FIG_Config, FigFams, SFXlate, SproutFIG, Tracer,
60        gjoparseblast, Data::Dumper.
61    
62    =cut
63    
64    ########################################################################
65    package FIGO;
66    ########################################################################
67  use strict;  use strict;
68  use FIG;  use FIG;
69  use FIG_Config;  use FIG_Config;
# Line 27  Line 74 
74  use FigFams;  use FigFams;
75  use gjoparseblast;  use gjoparseblast;
76    
77  =head1 FIGO Methods  =head1 FIGO
78    
79    The effective "base class" containing a few "top-level" methods.
80    
81    =cut
82    
83    
84  =head3 new  =head3 new
85    
# Line 80  Line 132 
132  C<< my @tax_ids = $figo->genomes( @constraints ); >>  C<< my @tax_ids = $figo->genomes( @constraints ); >>
133    
134  =item @constraints  =item @constraints
135    
136  One or more element of: complete, prokaryotic, eukaryotic, bacterial, archaeal, nmpdr.  One or more element of: complete, prokaryotic, eukaryotic, bacterial, archaeal, nmpdr.
137    
138  =item RETURNS: List of Tax-IDs.  =item RETURNS: List of Tax-IDs.
139    
140  =item EXAMPLE: L<Display all complete, prokaryotic genomes>  =item EXAMPLE:
141    
142        L<Display all complete, prokaryotic genomes>
143    
144  =back  =back
145    
# Line 141  Line 196 
196  =over4  =over4
197    
198  =item RETURNS:  =item RETURNS:
199    
200  List of all subsystems.  List of all subsystems.
201    
202  =item EXAMPLE: L<Accessing Subsystem data>  =item EXAMPLE:
203    
204        L<Accessing Subsystem data>
205    
206  =back  =back
207    
# Line 188  Line 246 
246    
247  =over4  =over4
248    
249  =item USAGE:  C<< foreach $fam ($figO->all_figfams) { #...Do something } >>  =item USAGE:
250    
251        C<< foreach $fam ($figO->all_figfams) { #...Do something } >>
252    
253  =item RETURNS: List of FIGfam Objects  =item RETURNS:
254    
255  =item EXAMPLE: L<Accessing FIGfams>      List of FIGfam Objects
256    
257    =item EXAMPLE:
258    
259        L<Accessing FIGfams>
260    
261  =back  =back
262    
# Line 211  Line 275 
275    
276  =over4  =over4
277    
278  =item USAGE:   C<< my ($fam, $sims) = $figO->family_containing($seq); >>  =item USAGE:
279    
280        C<< my ($fam, $sims) = $figO->family_containing($seq); >>
281    
282    =item $seq:
283    
284  =item $seq:    A protein translation string.      A protein translation string.
285    
286  =item RETURNS:  =item RETURNS:
287    
288        $fam:  A FIGfam Object.        $fam:  A FIGfam Object.
289    
290        $sims: A set of similarity objects.        $sims: A set of similarity objects.
291    
292  =item EXAMPLE: L<Placing a sequence into a FIGfam>  =item EXAMPLE: L<Placing a sequence into a FIGfam>
# Line 258  Line 328 
328  =over4  =over4
329    
330  =item USAGE:  =item USAGE:
331    
332  C<< my $org = GenomeO->new($figo, $tax_id); >>  C<< my $org = GenomeO->new($figo, $tax_id); >>
333    
334  =item RETURNS: A new GenomeO object.  =item RETURNS:
335    
336        A new GenomeO object.
337    
338  =back  =back
339    
# Line 281  Line 354 
354    
355  =over4  =over4
356    
357  =item USAGE:   C<< my $tax_id = $org->id(); >>  =item USAGE:
358    
359        C<< my $tax_id = $org->id(); >>
360    
361    =item RETURNS:
362    
363  =item RETURNS: Taxonomy-ID of GenomeO object.      Taxonomy-ID of GenomeO object.
364    
365  =back  =back
366    
# Line 301  Line 378 
378    
379  =over4  =over4
380    
381  =item USAGE:   C<< $gs = $genome->genus_species(); >>  =item USAGE:
382    
383        C<< $gs = $genome->genus_species(); >>
384    
385    =item RETURNS:
386    
387  =item RETURNS: Genus-species-strain string      Genus-species-strain string
388    
389  =back  =back
390    
# Line 321  Line 402 
402    
403  =over4  =over4
404    
405  =item RETURNS: List of C<contig> objects contained in a C<GenomeO> object.  =item RETURNS:
406    
407        List of C<contig> objects contained in a C<GenomeO> object.
408    
409  =item EXAMPLE: L<Show how to access contigs and extract sequence>  =item EXAMPLE:
410    
411        L<Show how to access contigs and extract sequence>
412    
413  =back  =back
414    
# Line 359  Line 444 
444    
445  =over4  =over4
446    
447  =item USAGE:   C<< $genome->display(); >>  =item USAGE:
448    
449        C<< $genome->display(); >>
450    
451  =item RETURNS: Null  =item RETURNS:
452    
453        (Void)
454    
455  =back  =back
456    
# Line 393  Line 482 
482  =over4  =over4
483    
484  =item USAGE:  =item USAGE:
485    
486  C<< $contig = ContigO->new( $figO, $genomeId, $contigId); >>  C<< $contig = ContigO->new( $figO, $genomeId, $contigId); >>
487    
488  =item $figO: A FIGO object.  =item $figO:
489    
490        Parent FIGO object.
491    
492  =item $genomeId: Taxon-ID for the genome the contig is from.  =item $genomeId:
493    
494  =item $contigId: Identifier for the contig      Taxon-ID for the genome the contig is from.
495    
496    =item $contigId:
497    
498        Identifier for the contig
499    
500    =item RETURNS:
501    
502  =item RETURNS: A "ContigO" object.      A "ContigO" object.
503    
504  =back  =back
505    
# Line 423  Line 521 
521    
522  =over4  =over4
523    
524  =item RETURNS: Sequence ID string of "ContigO" object  =item RETURNS:
525    
526        Sequence ID string of "ContigO" object
527    
528  =back  =back
529    
# Line 441  Line 541 
541  =over4  =over4
542    
543  =item USAGE:  =item USAGE:
     C<< my $tax_id = $contig->genome(); >>  
544    
545  =item RETURNS: GenomeO object containing the contig object.      C<< my $tax_id = $contig->genome->id(); >>
546    
547    =item RETURNS:
548    
549        Tax-ID of the GenomeO object containing the contig object.
550    
551  =back  =back
552    
# Line 452  Line 555 
555  sub genome {  sub genome {
556      my($self) = @_;      my($self) = @_;
557    
558      return $self->{_genome};      my $figO = $self->{_figO};
559        return new GenomeO($figO,$self->{_genome});
560  }  }
561    
562    
# Line 462  Line 566 
566  =over4  =over4
567    
568  =item USAGE:  =item USAGE:
569    
570      C<< my $len = $contig->contig_length(); >>      C<< my $len = $contig->contig_length(); >>
571    
572  =item RETURNS: Length of contig's DNA sequence.  =item RETURNS:
573    
574        Length of contig's DNA sequence.
575    
576  =back  =back
577    
# Line 474  Line 581 
581      my($self) = @_;      my($self) = @_;
582    
583      my $fig = $self->{_figO}->{_fig};      my $fig = $self->{_figO}->{_fig};
584      my $contig_lengths = $fig->contig_lengths($self->genome);      my $contig_lengths = $fig->contig_lengths($self->genome->id);
585      return $contig_lengths->{$self->id};      return $contig_lengths->{$self->id};
586  }  }
587    
# Line 484  Line 591 
591  =over4  =over4
592    
593  =item USAGE:  =item USAGE:
594    
595      C<< my $seq = $contig->dna_seq(beg, $end); >>      C<< my $seq = $contig->dna_seq(beg, $end); >>
596    
597  =item $beg: Begining point of DNA subsequence  =item $beg:
598    
599        Begining point of DNA subsequence
600    
601  =item $end: End point of DNA subsequence  =item $end:
602    
603  =item RETURNS: string of DNA sequence from $beg to $end      End point of DNA subsequence
604    
605    =item RETURNS:
606    
607        string of DNA sequence running from $beg to $end
608  (NOTE: if $beg > $end, returns reverse complement of DNA subsequence.)  (NOTE: if $beg > $end, returns reverse complement of DNA subsequence.)
609    
610  =back  =back
# Line 506  Line 619 
619      if (($beg && (&FIG::between(1,$beg,$max))) &&      if (($beg && (&FIG::between(1,$beg,$max))) &&
620          ($end && (&FIG::between(1,$end,$max))))          ($end && (&FIG::between(1,$end,$max))))
621      {      {
622          return $fig->dna_seq($self->genome,join("_",($self->id,$beg,$end)));          return $fig->dna_seq($self->genome->id,join("_",($self->id,$beg,$end)));
623      }      }
624      else      else
625      {      {
# Line 527  Line 640 
640    
641  =over4  =over4
642    
643  =item RETURNS: Nil  =item RETURNS:
644    
645        (Void)
646    
647  =back  =back
648    
# Line 536  Line 651 
651  sub display {  sub display {
652      my($self) = @_;      my($self) = @_;
653    
654      print join("ContigO",$self->genome,$self->id,$self->contig_length),"\n";      print join("ContigO",$self->genome->id,$self->id,$self->contig_length),"\n";
655  }  }
656    
657    sub features_in_region {
658        my($self,$beg,$end) = @_;
659        my $figO = $self->{_figO};
660        my $fig = $figO->{_fig};
661    
662        my($features) = $fig->genes_in_region($self->genome->id,$self->id,$beg,$end);
663        return map { new FeatureO($figO,$_) } @$features;
664    }
665    
666  ########################################################################  ########################################################################
667  package FeatureO;  package FeatureO;
# Line 548  Line 670 
670    
671  =head1 FeatureO  =head1 FeatureO
672    
673  =cut  Methods for working with features on "ContigO" objects.
   
674    
675    =cut
676    
677  =head1 new  =head3 new
678    
679  Constructor of "FeatureO" objects  Constructor of "FeatureO" objects
680    
# Line 587  Line 709 
709    
710  sub genome {  sub genome {
711      my($self) = @_;      my($self) = @_;
712        my $figO = $self->{_figO};
713      $self->id =~ /^fig\|(\d+\.\d+)/;      $self->id =~ /^fig\|(\d+\.\d+)/;
714      return $1;      return new GenomeO($figO,$1);
715  }  }
716    
717    
# Line 619  Line 741 
741      return scalar $fig->feature_location($self->id);      return scalar $fig->feature_location($self->id);
742  }  }
743    
744    sub contig {
745        my($self) = @_;
746    
747        my $figO = $self->{_figO};
748        my $loc      = $self->location;
749        my $genomeID = $self->genome->id;
750        return ($loc =~ /^(\S+)_\d+_\d+$/) ? new ContigO($figO,$genomeID,$1) : undef;
751    }
752    
753    sub begin {
754        my($self) = @_;
755    
756        my $loc = $self->location;
757        return ($loc =~ /^\S+_(\d+)_\d+$/) ? $1 : undef;
758    }
759    
760    sub end {
761        my($self) = @_;
762    
763        my $loc = $self->location;
764        return ($loc =~ /^\S+_\d+_(\d+)$/) ? $1 : undef;
765    }
766    
767  =head3 dna_seq  =head3 dna_seq
768    
# Line 752  Line 895 
895                      my $contig = $1;                      my $contig = $1;
896                      my $beg    = $2;                      my $beg    = $2;
897                      my $end = $3;                      my $end = $3;
898                      my $contigO = new ContigO($figO,$self->genome,$contig);                      my $contigO = new ContigO($figO,$self->genome->id,$contig);
899                      my $begA = &max(1,$beg - $adjL);                      my $begA = &max(1,$beg - $adjL);
900                      my $endA = &min($end+$adjR,$contigO->contig_length);                      my $endA = &min($end+$adjR,$contigO->contig_length);
901                      my $dna  = $contigO->dna_seq($begA,$endA);                      my $dna  = $contigO->dna_seq($begA,$endA);
# Line 791  Line 934 
934    
935  =head3 run  =head3 run
936    
937  =cut  =sub
938    
939  sub run {  cut run {
940      my($cmd) = @_;      my($cmd) = @_;
941      (system($cmd) == 0) || Confess("FAILED: $cmd");      (system($cmd) == 0) || Confess("FAILED: $cmd");
942  }  }
# Line 1234  Line 1377 
1377      my $figO = $self->{_figO};      my $figO = $self->{_figO};
1378      my $subO = $self->{_subO};      my $subO = $self->{_subO};
1379      if (! $subO) { $subO = $self->{_subO} = new Subsystem($self->{_id},$figO->{_fig}); }      if (! $subO) { $subO = $self->{_subO} = new Subsystem($self->{_id},$figO->{_fig}); }
     if (! defined($subO)) { return undef }  
1380    
1381      return map { &GenomeO::new('GenomeO',$figO,$_) } $subO->get_genomes;      return map { &GenomeO::new('GenomeO',$figO,$_) } $subO->get_genomes;
1382  }  }
1383    
1384    
1385    
1386  =head3 roles  =head3 roles
1387    
1388  =cut  =cut
# Line 1249  Line 1393 
1393      my $figO = $self->{_figO};      my $figO = $self->{_figO};
1394      my $subO = $self->{_subO};      my $subO = $self->{_subO};
1395      if (! $subO) { $subO = $self->{_subO} = new Subsystem($self->{_id},$figO->{_fig}); }      if (! $subO) { $subO = $self->{_subO} = new Subsystem($self->{_id},$figO->{_fig}); }
1396      if (! defined($subO)) { return undef }  
1397      return map { &FunctionalRoleO::new('FunctionalRoleO',$figO,$_) }  $subO->get_roles($self->id);      return map { &FunctionalRoleO::new('FunctionalRoleO',$figO,$_) }  $subO->get_roles($self->id);
1398  }  }
1399    
1400    
1401    
1402  =head3 curator  =head3 curator
1403    
1404  =cut  =cut
# Line 1263  Line 1409 
1409      my $figO = $self->{_figO};      my $figO = $self->{_figO};
1410      my $subO = $self->{_subO};      my $subO = $self->{_subO};
1411      if (! $subO) { $subO = $self->{_subO} = new Subsystem($self->{_id},$figO->{_fig}); }      if (! $subO) { $subO = $self->{_subO} = new Subsystem($self->{_id},$figO->{_fig}); }
1412      return defined($subO) ? $subO->get_curator : undef;  
1413        return $subO->get_curator;
1414  }  }
1415    
1416    
# Line 1279  Line 1426 
1426      my $figO = $self->{_figO};      my $figO = $self->{_figO};
1427      my $subO = $self->{_subO};      my $subO = $self->{_subO};
1428      if (! $subO) { $subO = $self->{_subO} = new Subsystem($self->{_id},$figO->{_fig}); }      if (! $subO) { $subO = $self->{_subO} = new Subsystem($self->{_id},$figO->{_fig}); }
     if (! defined($subO)) { return undef }  
1429    
1430      return $subO->get_variant_code_for_genome($genome->id);      return $subO->get_variant_code_for_genome($genome->id);
1431  }  }
# Line 1296  Line 1442 
1442      my $figO = $self->{_figO};      my $figO = $self->{_figO};
1443      my $subO = $self->{_subO};      my $subO = $self->{_subO};
1444      if (! $subO) { $subO = $self->{_subO} = new Subsystem($self->{_id},$figO->{_fig}); }      if (! $subO) { $subO = $self->{_subO} = new Subsystem($self->{_id},$figO->{_fig}); }
     if (! defined($subO)) { return undef }  
1445    
1446      return $subO->get_pegs_from_cell($genome->id,$role->id);      return $subO->get_pegs_from_cell($genome->id,$role->id);
1447  }  }
# Line 1310  Line 1455 
1455    
1456  =head1 FunctionalRoleO  =head1 FunctionalRoleO
1457    
1458    Methods for accessing the functional roles of features.
1459    
1460  =cut  =cut
1461    
1462    
# Line 1462  Line 1609 
1609  ########################################################################  ########################################################################
1610  =head1 Attribute  =head1 Attribute
1611    
1612    (Note yet implemented.)
1613    
1614  =cut  =cut
1615    
1616  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3