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

Diff of /FigKernelPackages/gjogenbank.pm

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

revision 1.3, Tue Aug 17 20:13:42 2010 UTC revision 1.4, Tue Aug 17 20:47:29 2010 UTC
# Line 54  Line 54 
54  #  #
55  #  Access functions to parts of structure:  #  Access functions to parts of structure:
56  #  #
57    #     @types = feature_types( $entry );
58    #    \@types = feature_types( $entry );
59    #
60    #     @ftrs = features_of_type( $entry,  @types );
61    #    \@ftrs = features_of_type( $entry,  @types );
62    #     @ftrs = features_of_type( $entry, \@types );
63    #    \@ftrs = features_of_type( $entry, \@types );
64    #
65  #  Sequence of a feature, optionally including information on partial ends.  #  Sequence of a feature, optionally including information on partial ends.
66  #  #
67  #     $seq                           = ftr_dna(  $dna, $ftr )  #     $seq                           = ftr_dna(  $dna, $ftr )
# Line 112  Line 120 
120  our @ISA    = qw( Exporter );  our @ISA    = qw( Exporter );
121  our @EXPORT = qw( parse_genbank  our @EXPORT = qw( parse_genbank
122                    parse_next_genbank                    parse_next_genbank
123                      feature_types
124                      features_of_type
125                  );                  );
126    
127  #===============================================================================  #===============================================================================
# Line 464  Line 474 
474  #===============================================================================  #===============================================================================
475  #  Access methods for some features and feature data  #  Access methods for some features and feature data
476  #===============================================================================  #===============================================================================
477    #
478    #     @types = feature_types( $entry );
479    #    \@types = feature_types( $entry );
480    #
481    #     @ftrs = features_of_type( $entry,  @types );
482    #    \@ftrs = features_of_type( $entry,  @types );
483    #     @ftrs = features_of_type( $entry, \@types );
484    #    \@ftrs = features_of_type( $entry, \@types );
485    #
486    #-------------------------------------------------------------------------------
487    
488    sub feature_types
489    {
490        my $entry = shift;
491        return wantarray ? () : [] if ! ( $entry && ref $entry eq 'HASH' );
492    
493        my $ftrs = $entry->{ FEATURES };
494        return wantarray ? () : [] if ! ( $ftrs && ref $ftrs eq 'HASH' );
495    
496        my @types = sort { lc $a cmp lc $b } keys %$ftrs;
497        wantarray ? @types : \@types;
498    }
499    
500    
501    sub features_of_type
502    {
503        my $entry = shift;
504        return wantarray ? () : [] if ! ( $entry && ref $entry eq 'HASH' );
505    
506        my $ftrs = $entry->{ FEATURES };
507        return wantarray ? () : [] if ! ( $ftrs && ref $ftrs eq 'HASH' );
508    
509        my @types = ( ! $_[0] )              ? sort { lc $a cmp lc $b } keys %$ftrs
510                  : ( ref $_[0] eq 'ARRAY' ) ? @{ $_[0] }
511                  :                            @_;
512    
513        my @ftrs = map { @{ $ftrs->{ $_ } || [] } } @types;
514        wantarray ? @ftrs : \@ftrs;
515    }
516    
517    
518    #-------------------------------------------------------------------------------
519  #  Sequence of a feature.  In list context, include information on partial ends.  #  Sequence of a feature.  In list context, include information on partial ends.
520  #  Can get extract the data from a DNA string, reference to a string, or from  #  Can get extract the data from a DNA string, reference to a string, or from
521  #  the SEQUENCE in an entry.  #  the SEQUENCE in an entry.

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3