NAME
Bio::Tools::GFF - A Bio::SeqAnalysisParserI compliant GFF format parser
SYNOPSIS
use Bio::Tools::GFF;# specify input via -fh or -filemy $gffio = Bio::Tools::GFF->new(-fh => \*STDIN, -gff_version => 2);my $feature;# loop over the input streamwhile($feature = $gffio->next_feature()) {# do something with feature}$gffio->close();# you can also obtain a GFF parser as a SeqAnalasisParserI in# HT analysis pipelines (see Bio::SeqAnalysisParserI and# Bio::Factory::SeqAnalysisParserFactory)my $factory = Bio::Factory::SeqAnalysisParserFactory->new();my $parser = $factory->get_parser(-input => \*STDIN, -method => "gff");while($feature = $parser->next_feature()) {# do something with feature}
DESCRIPTION
This class provides a simple GFF parser and writer. In the sense of a SeqAnalysisParser, it parses an input file or stream into SeqFeatureI objects, but is not in any way specific to a particular analysis program and the output that program produces.
That is, if you can get your analysis program spit out GFF, here is your result parser.
GFF3 AND SEQUENCE DATA
GFF3 supports sequence data; see
http://www.sequenceontology.org/gff3.shtml
There are a number of ways to deal with this -
If you call
$gffio->ignore_sequence(1)
prior to parsing the sequence data is ignored; this is useful if you just want the features. It avoids the memory overhead in building and caching sequences
Alternatively, you can call either
$gffio->get_seqs()
Or
$gffio->seq_id_by_h()
At the end of parsing to get either a list or hashref of Bio::Seq objects (see the documentation for each of these methods)
Note that these objects will not have the features attached - you have to do this yourself, OR call
$gffio->features_attached_to_seqs(1)
PRIOR to parsing; this will ensure that the Seqs have the features attached; ie you will then be able to call
$seq->get_SeqFeatures();
And use Bio::SeqIO methods
Note that auto-attaching the features to seqs will incur a higher memory overhead as the features must be cached until the sequence data is found
TODO
Make a Bio::SeqIO class specifically for GFF3 with sequence data
FEEDBACK
Mailing Lists
User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated.
[email protected] - General discussionhttp://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support
Please direct usage questions or support issues to the mailing list:
rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.
Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted the web:
https://github.com/bioperl/bioperl-live/issues
AUTHOR - Matthew Pocock
Email mrp-at-sanger.ac.uk
CONTRIBUTORS
Jason Stajich, jason-at-biperl-dot-org Chris Mungall, cjm-at-fruitfly-dot-org Steffen Grossmann [SG], grossman at molgen.mpg.de Malcolm Cook, mec-at-stowers-institute.org
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
new
Title : newUsage : my $parser = Bio::Tools::GFF->new(-gff_version => 2,-file => "filename.gff");ormy $writer = Bio::Tools::GFF->new(-gff_version => 3,-file => ">filename.gff3");Function: Creates a new instance. Recognized named parameters are -file, -fh,and -gff_version.Returns : a new objectArgs : named parameters-gff_version => [1,2,3]
_parse_header
Title : _parse_headerUsage : $gffio->_parse_header()Function: used to turn parse GFF header lines. currentlyproduces Bio::LocatableSeq objects from ##sequence-regionlinesReturns : 1 on successArgs : none
next_segment
Title : next_segmentUsage : my $seq = $gffio->next_segment;Function: Returns a Bio::LocatableSeq object corresponding to aGFF "##sequence-region" header line.Example :Returns : A Bio::LocatableSeq object, or undef ifthere are no more sequences.Args : none
next_feature
Title : next_featureUsage : $seqfeature = $gffio->next_feature();Function: Returns the next feature available in the input file or stream, orundef if there are no more features.Example :Returns : A Bio::SeqFeatureI implementing object, or undef if there are nomore features.Args : none
from_gff_string
Title : from_gff_stringUsage : $gff->from_gff_string($feature, $gff_string);Function: Sets properties of a SeqFeatureI object from a GFF-formattedstring. Interpretation of the string depends on the versionthat has been specified at initialization.This method is used by next_feature(). It actually dispatches toone of the version-specific (private) methods.Example :Returns : voidArgs : A Bio::SeqFeatureI implementing object to be initializedThe GFF-formatted string to initialize it from
_from_gff1_string
Title : _from_gff1_stringUsage :Function:Example :Returns : voidArgs : A Bio::SeqFeatureI implementing object to be initializedThe GFF-formatted string to initialize it from
_from_gff2_string
Title : _from_gff2_stringUsage :Function:Example :Returns : voidArgs : A Bio::SeqFeatureI implementing object to be initializedThe GFF2-formatted string to initialize it from
write_feature
Title : write_featureUsage : $gffio->write_feature($feature);Function: Writes the specified SeqFeatureI object in GFF format to the streamassociated with this instance.Returns : noneArgs : An array of Bio::SeqFeatureI implementing objects to be serialized
gff_string
Title : gff_stringUsage : $gffstr = $gffio->gff_string($feature);Function: Obtain the GFF-formatted representation of a SeqFeatureI object.The formatting depends on the version specified at initialization.This method is used by write_feature(). It actually dispatches toone of the version-specific (private) methods.Example :Returns : A GFF-formatted string representation of the SeqFeatureArgs : A Bio::SeqFeatureI implementing object to be GFF-stringified
_gff1_string
Title : _gff1_stringUsage : $gffstr = $gffio->_gff1_stringFunction:Example :Returns : A GFF1-formatted string representation of the SeqFeatureArgs : A Bio::SeqFeatureI implementing object to be GFF-stringified
_gff2_string
Title : _gff2_stringUsage : $gffstr = $gffio->_gff2_stringFunction:Example :Returns : A GFF2-formatted string representation of the SeqFeatureArgs : A Bio::SeqFeatureI implementing object to be GFF2-stringified
_gff25_string
Title : _gff25_stringUsage : $gffstr = $gffio->_gff2_stringFunction: To get a format of GFF that is peculiar to Gbrowse/Bio::DB::GFFExample :Returns : A GFF2.5-formatted string representation of the SeqFeatureArgs : A Bio::SeqFeatureI implementing object to be GFF2.5-stringified
_gff3_string
Title : _gff3_stringUsage : $gffstr = $gffio->_gff3_stringFunction:Example :Returns : A GFF3-formatted string representation of the SeqFeatureArgs : A Bio::SeqFeatureI implementing object to be GFF3-stringified
gff_version
Title : _gff_versionUsage : $gffversion = $gffio->gff_versionFunction:Example :Returns : The GFF version this parser will accept and emit.Args : none
newFh
Title : newFhUsage : $fh = Bio::Tools::GFF->newFh(-file=>$filename,-format=>'Format')Function: does a new() followed by an fh()Example : $fh = Bio::Tools::GFF->newFh(-file=>$filename,-format=>'Format')$feature = <$fh>; # read a feature objectprint $fh $feature; # write a feature objectReturns : filehandle tied to the Bio::Tools::GFF classArgs :
fh
Title : fhUsage : $obj->fhFunction:Example : $fh = $obj->fh; # make a tied filehandle$feature = <$fh>; # read a feature objectprint $fh $feature; # write a feature objectReturns : filehandle tied to Bio::Tools::GFF classArgs : none
get_seqs
Title : get_seqsUsage :Function: Returns all Bio::Seq objects populated by GFF3 fileExample :Returns :Args :
features_attached_to_seqs
Title : features_attached_to_seqsUsage : $obj->features_attached_to_seqs(1);Function: For use with GFF3 containing sequence onlySetting this B<before> parsing ensures that all Bio::Seq objectcreated will have the appropriate features added to themdefaults to false (off)Note that this mode will incur higher memory usage because featureswill have to be cached until the relevant feature comes alongExample :Returns : value of features_attached_to_seqs (a boolean)Args : on set, new value (a boolean, optional)
ignore_sequence
Title : ignore_sequenceUsage : $obj->ignore_sequence(1);Function: For use with GFF3 containing sequence onlySetting this B<before> parsing means that all sequence data will beignoredExample :Returns : value of ignore_sequence (a boolean)Args : on set, new value (a boolean, optional)