The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bio::GFF3::LowLevel::Parser - a fast, low-level gff3 parser

SYNOPSIS

  my $p = Bio::GFF3::LowLevel::Parser->new( $file_or_fh );

  while( my $i = $p->next_item ) {

      if( exists $i->{seq_id} ) {
          ## $i is a feature in the same format as returned by
          ## Bio::GFF3::LowLevel::gff3_parse_feature.  do something with
          ## it
      }
      elsif( $i->{directive} ) {
          if( $i->{directive} eq 'FASTA' ) {
              my $fasta_filehandle = $i->{filehandle};
              ## parse the FASTA in the filehandle with BioPerl or
              ## however you want.  or ignore it.
          }
          elsif( $i->{directive} eq 'gff-version' ) {
              print "it says it is GFF version $i->{value}\n";
          }
          elsif( $i->{directive} eq 'sequence-region' ) {
              print( "found a sequence-region, sequence $i->{seq_id},",
                     " from $i->{start} to $i->{end}\n"
                   );
          }
      }
      elsif( $i->{comment} ) {
          ## this is a comment in your GFF3 file, in case you want to do
          ## something with it.
          print "that comment said: '$i->{comment}'\n";
      }
      else {
          die 'this should never happen!';
      }

  }

DESCRIPTION

This is a fast, low-level parser for Generic Feature Format, version 3 (GFF3). It is a low-level parser, it only returns dumb hashrefs. It does reconstruct feature hierarchies, however, using features' ID/Parent attributes.

Features

Features are returned in the same format as "gff3_parse_feature" in Bio::GFF3::LowLevel, with an additional child_features key containing an arrayref of child features. Each of those features also have child_features arrayrefs.

For convenience, all features returned by this parser have child_features arrayrefs, which may be empty.

Directives

Directives are returned in the same format as "gff3_parse_directive" in Bio::GFF3::LowLevel.

Comments

Comments are parsed into a hashref of the form:

  { comment => 'text of the comment, not including the hash mark(s) and ending newline' }

FUNCTIONS

new( $file_or_filehandle, ... )

Make a new parser object that will parse the GFF3 in all of the files or filehandles that you give it.

next_item()

Iterate through all of the items (features, directives, and comments) in the file(s) given to the parser. Each item is a returned as a hashref.

AUTHOR

Robert Buels <rmb32@cornell.edu>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Robert Buels.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.