Bio::Tools::GFF(3pm)

πŸ“¦
version 1.7.8 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– Bio::Tools::GFF πŸ’–

okay bestie, welcome to Bio::Tools::GFF(3pm) β€” a Bio::SeqAnalysisParserI compliant GFF format parser, straight out of the User Contributed Perl Documentation. yes it's Perl. yes it's bioinformatics. yes it's iconic. sit down, hydrate, let's go 🧚


✨ NAME ✨

Bio::Tools::GFF β€” a Bio::SeqAnalysisParserI compliant GFF format parser. that's the whole vibe. πŸ’…


🌸 SYNOPSIS 🌸

use Bio::Tools::GFF;

# specify input via -fh or -file
my $gffio = Bio::Tools::GFF->new(-fh => \*STDIN, -gff_version => 2);
my $feature;
# loop over the input stream
while($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
}

two whole ways to eat your GFF, bestie. pick your fighter. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

this class is your simple GFF parser and writer. in the SeqAnalysisParser sense, it takes an input file or stream and turns it into SeqFeatureI objects β€” but it's not in any way specific to one particular analysis program or the output that program produces. it's giving ✨versatility✨.

so basically: if you can get your analysis program to spit out GFF, here is your result parser. no cap. πŸŽ€


πŸ“ 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)

pior to parsing the sequence data is ignored. this is useful if you just want the features. it avoids the memory overhead of building and caching sequences. lowkey the frugal option. πŸ’€

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 a hashref of Bio::Seq objects (see the documentation for each of these methods, bestie, i'm not gonna retype it all).

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; i.e. 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, because the features must be cached until the sequence data is found. your RAM has been warned. 😭

πŸ‘‘ TODO πŸ‘‘

make a Bio::SeqIO class specifically for GFF3 with sequence data. it's on the list. it's been on the list. someday. πŸ•―οΈ


πŸ’œ 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, fr fr. 🫢

bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/wiki/Mailing_lists  - About the mailing lists

πŸ’– Support πŸ’–

please direct usage questions or support issues to the mailing list:

bioperl-l@bioperl.org

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. receipts help everybody. πŸ“

πŸŽ€ 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

the whole squad showed up. πŸ‘‘βœ¨


🧚 APPENDIX 🧚

the rest of the documentation details each of the object methods. internal methods are usually preceded with a _ β€” that underscore is like the VIP rope, don't touch unless you know. πŸ’…

πŸ’« new πŸ’«

  • Title β€” new
  • Usage β€”
my $parser = Bio::Tools::GFF->new(-gff_version => 2,
                                  -file        => "filename.gff");
or
my $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 object
  • Args β€” named parameters, -gff_version => [1,2,3]

πŸ’« _parse_header πŸ’«

  • Title β€” _parse_header
  • Usage β€” $gffio->_parse_header()
  • Function β€” used to turn parse GFF header lines. currently produces Bio::LocatableSeq objects from ##sequence-region lines
  • Returns β€” 1 on success
  • Args β€” none

πŸ’« next_segment πŸ’«

  • Title β€” next_segment
  • Usage β€” my $seq = $gffio->next_segment;
  • Function β€” returns a Bio::LocatableSeq object corresponding to a GFF ##sequence-region header line.
  • Example β€” (none given)
  • Returns β€” a Bio::LocatableSeq object, or undef if there are no more sequences.
  • Args β€” none

πŸ’« next_feature πŸ’«

  • Title β€” next_feature
  • Usage β€” $seqfeature = $gffio->next_feature();
  • Function β€” returns the next feature available in the input file or stream, or undef if there are no more features.
  • Example β€” (none given)
  • Returns β€” a Bio::SeqFeatureI implementing object, or undef if there are no more features.
  • Args β€” none

πŸ’« from_gff_string πŸ’«

  • Title β€” from_gff_string
  • Usage β€” $gff->from_gff_string($feature, $gff_string);
  • Function β€” sets properties of a SeqFeatureI object from a GFF-formatted string. interpretation of the string depends on the version that has been specified at initialization.

this method is used by next_feature(). it actually dispatches to one of the version-specific (private) methods.

  • Example β€” (none given)
  • Returns β€” void
  • Args β€” a Bio::SeqFeatureI implementing object to be initialized; the GFF-formatted string to initialize it from

πŸ’« _from_gff1_string πŸ’«

  • Title β€” _from_gff1_string
  • Usage β€” (blank)
  • Function β€” (blank)
  • Example β€” (blank)
  • Returns β€” void
  • Args β€” a Bio::SeqFeatureI implementing object to be initialized; the GFF-formatted string to initialize it from

πŸ’« _from_gff2_string πŸ’«

  • Title β€” _from_gff2_string
  • Usage β€” (blank)
  • Function β€” (blank)
  • Example β€” (blank)
  • Returns β€” void
  • Args β€” a Bio::SeqFeatureI implementing object to be initialized; the GFF2-formatted string to initialize it from

πŸ’« write_feature πŸ’«

  • Title β€” write_feature
  • Usage β€” $gffio->write_feature($feature);
  • Function β€” writes the specified SeqFeatureI object in GFF format to the stream associated with this instance.
  • Returns β€” none
  • Args β€” an array of Bio::SeqFeatureI implementing objects to be serialized

πŸ’« gff_string πŸ’«

  • Title β€” gff_string
  • Usage β€” $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 to one of the version-specific (private) methods.

  • Example β€” (none given)
  • Returns β€” a GFF-formatted string representation of the SeqFeature
  • Args β€” a Bio::SeqFeatureI implementing object to be GFF-stringified

πŸ’« _gff1_string πŸ’«

  • Title β€” _gff1_string
  • Usage β€” $gffstr = $gffio->_gff1_string
  • Function β€” (blank)
  • Example β€” (blank)
  • Returns β€” a GFF1-formatted string representation of the SeqFeature
  • Args β€” a Bio::SeqFeatureI implementing object to be GFF-stringified

πŸ’« _gff2_string πŸ’«

  • Title β€” _gff2_string
  • Usage β€” $gffstr = $gffio->_gff2_string
  • Function β€” (blank)
  • Example β€” (blank)
  • Returns β€” a GFF2-formatted string representation of the SeqFeature
  • Args β€” a Bio::SeqFeatureI implementing object to be GFF2-stringified

πŸ’« _gff25_string πŸ’«

  • Title β€” _gff25_string
  • Usage β€” $gffstr = $gffio->_gff2_string
  • Function β€” to get a format of GFF that is peculiar to Gbrowse/Bio::DB::GFF
  • Example β€” (blank)
  • Returns β€” a GFF2.5-formatted string representation of the SeqFeature
  • Args β€” a Bio::SeqFeatureI implementing object to be GFF2.5-stringified

πŸ’« _gff3_string πŸ’«

  • Title β€” _gff3_string
  • Usage β€” $gffstr = $gffio->_gff3_string
  • Function β€” (blank)
  • Example β€” (blank)
  • Returns β€” a GFF3-formatted string representation of the SeqFeature
  • Args β€” a Bio::SeqFeatureI implementing object to be GFF3-stringified

πŸ’« gff_version πŸ’«

  • Title β€” _gff_version
  • Usage β€” $gffversion = $gffio->gff_version
  • Function β€” (blank)
  • Example β€” (blank)
  • Returns β€” the GFF version this parser will accept and emit.
  • Args β€” none

πŸ’« newFh πŸ’«

  • Title β€” newFh
  • Usage β€” $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 object
print $fh $feature;          # write a feature object
  • Returns β€” filehandle tied to the Bio::Tools::GFF class
  • Args β€” (blank)

πŸ’« fh πŸ’«

  • Title β€” fh
  • Usage β€” $obj->fh
  • Function β€” (blank)
  • Example β€”
$fh = $obj->fh;      # make a tied filehandle
$feature = <$fh>;    # read a feature object
print $fh $feature;  # write a feature object
  • Returns β€” filehandle tied to Bio::Tools::GFF class
  • Args β€” none

πŸ’« get_seqs πŸ’«

  • Title β€” get_seqs
  • Usage β€” (blank)
  • Function β€” returns all Bio::Seq objects populated by GFF3 file
  • Example β€” (blank)
  • Returns β€” (blank)
  • Args β€” (blank)

πŸ’« features_attached_to_seqs πŸ’«

  • Title β€” features_attached_to_seqs
  • Usage β€” $obj->features_attached_to_seqs(1);
  • Function β€” for use with GFF3 containing sequence only

setting this before parsing ensures that all Bio::Seq object created will have the appropriate features added to them

defaults to false (off)

note that this mode will incur higher memory usage because features will have to be cached until the relevant feature comes along. πŸ’€
  • Example β€” (blank)
  • Returns β€” value of features_attached_to_seqs (a boolean)
  • Args β€” on set, new value (a boolean, optional)

πŸ’« ignore_sequence πŸ’«

  • Title β€” ignore_sequence
  • Usage β€” $obj->ignore_sequence(1);
  • Function β€” for use with GFF3 containing sequence only

setting this before parsing means that all sequence data will be ignored

  • Example β€” (blank)
  • Returns β€” value of ignore_sequence (a boolean)
  • Args β€” on set, new value (a boolean, optional)

and that's the whole page, bestie. mwah. 🫢✨

this little number came to you courtesy of perl v5.32.1, dated 2021-08-15 β€” go forth, parse some GFF, and stay hydrated. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from