Bio::T...Format(3pm)

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

✨ Bio::Tools::GuessSeqFormat πŸ’…

okay bestie, gather round, because this little module is the moment. It lives in the Perl user-contributed docs (manpage name is Bio::T...Format(3pm), iykyk), and its whole job is: look at some sequence data and go "oh I know what you are πŸ¦‹".


🌸 NAME 🌸

Bio::Tools::GuessSeqFormat β€” the module for sniffing out the sequence format of the contents of a file, a string, or through a filehandle. No cap.


πŸŽ€ SYNOPSIS πŸŽ€

# To guess the format of a flat file, given a filename:
my $guesser = Bio::Tools::GuessSeqFormat->new( -file => $filename );
my $format  = $guesser->guess;

# To guess the format from an already open filehandle:
my $guesser = Bio::Tools::GuessSeqFormat->new( -fh => $filehandle );
my $format  = $guesser->guess;
# The filehandle will be returned to its original position. Note that this
# filehandle can be STDIN.

# To guess the format of one or several lines of text (with
# embedded newlines):
my $guesser = Bio::Tools::GuessSeqFormat->new( -text => $linesoftext );
my $format = $guesser->guess;

# To create a Bio::Tools::GuessSeqFormat object and set the
# filename, filehandle, or line to parse afterwards:
my $guesser = Bio::Tools::GuessSeqFormat->new();
$guesser->file($filename);
$guesser->fh($filehandle);
$guesser->text($linesoftext);

# To guess in one go, given e.g. a filename:
my $format = Bio::Tools::GuessSeqFormat->new( -file => $filename )->guess;

πŸ’– DESCRIPTION πŸ’–

Bio::Tools::GuessSeqFormat is out here trying to figure out the format (think "swiss", "pir", "fasta" etc.) of the sequence or MSA inside a file, inside a scalar, or coming through a filehandle. Detective energy fr fr πŸ”.

The guess() method on a Bio::Tools::GuessSeqFormat object reads the data line by line until it hits a line that can only belong to one single format. If it can't make a conclusive guess? It hands you back undef. No vibes, no answer, sorry bestie 😭.

If you hand the object a filehandle, like STDIN, it gets restored to its original position the second guess() returns. Respectful king behavior πŸ‘‘.

🧬 Formats

Right now, tests are implemented for these formats:

  • ACeDB ("ace")
  • Blast ("blast")
  • ClustalW ("clustalw")
  • Codata ("codata")
  • EMBL ("embl")
  • FastA sequence ("fasta")
  • FastQ sequence ("fastq")
  • FastXY/FastA alignment ("fastxy")
  • Game XML ("game")
  • GCG ("gcg")
  • GCG Blast ("gcgblast")
  • GCG FastA ("gcgfasta")
  • GDE ("gde")
  • Genbank ("genbank")
  • Genscan ("genscan")
  • GFF ("gff")
  • HMMER ("hmmer")
  • PAUP/NEXUS ("nexus")
  • Phrap assembly file ("phrap")
  • NBRF/PIR ("pir")
  • Mase ("mase")
  • Mega ("mega")
  • GCG/MSF ("msf")
  • Pfam ("pfam")
  • Phylip ("phylip")
  • Prodom ("prodom")
  • Raw ("raw")
  • RSF ("rsf")
  • Selex ("selex")
  • Stockholm ("stockholm")
  • Swissprot ("swiss")
  • Tab ("tab")
  • Variant Call Format ("vcf")

πŸ“¬ FEEDBACK πŸ“¬

πŸ’Œ Mailing Lists

User feedback is literally a whole pillar of how this module and all the other Bioperl modules evolve. Send your comments and suggestions (preferably) to one of the Bioperl mailing lists. Your participation is so appreciated, bestie 🫢.

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

πŸ†˜ Support

Please send usage questions and support issues to the mailing list:

bioperl-l@bioperl.org

...and not straight to the module maintainer, okay? There are so many experienced and responsive experts on there who can look at your problem and fix it fast. If it's at all possible, include a thorough description of the problem with code and data examples. The more deets the better πŸ’….

πŸ› Reporting Bugs

Report bugs to the Bioperl bug tracking system so we can keep track of the bugs and their resolutions. Bug reports can be submitted via the web:

https://github.com/bioperl/bioperl-live/issues

πŸ‘‘ AUTHOR πŸ‘‘

Andreas KΓ€hΓ€ri, andreas.kahari@ebi.ac.uk

🌟 CONTRIBUTORS 🌟

Heikki LehvΓ€slaiho, heikki-at-bioperl-dot-org Mark A. Jensen, maj-at-fortinbras-dot-us


πŸ”₯ METHODS πŸ”₯

The methods available to Bio::Tools::GuessSeqFormat objects are described below. Methods whose names start with an underscore are considered internal β€” that's a do not touch unless you know what you're doing situation πŸ™ˆ.

🧚 new

  • Title: new
  • Usage: $guesser = Bio::Tools::GuessSeqFormat->new( ... );
  • Function: creates a brand new object, fresh out the box ✨
  • Example: peep the SYNOPSIS
  • Returns: a new object
  • Arguments:
    • -file β€” the filename of the file whose format is to be guessed, e.g. STDIN, or
    • -fh β€” an already opened filehandle from which a text stream may be read, or
    • -text β€” a scalar containing one or several lines of text with embedded newlines.

If more than one of the above arguments is given, they get tested in the order -text, -file, -fh, and the first available argument is the one that gets used. First come, first served, periodt.

🧚 file

  • Title: file
  • Usage:
$guesser->file($filename);
$filename = $guesser->file;
  • Function: gets or sets the current filename associated with an object.
  • Returns: the new filename.
  • Arguments: the filename of the file whose format is to be guessed.
Heads up: a call to this method will clear the current filehandle and the current lines of text associated with the object. It's giving spring cleaning 🧹.

🧚 fh

  • Title: fh
  • Usage:
$guesser->fh($filehandle);
$filehandle = $guesser->fh;
  • Function: gets or sets the current filehandle associated with an object.
  • Returns: the new filehandle.
  • Arguments: an already opened filehandle from which a text stream may be read.
Heads up: a call to this method will clear the current filename and the current lines of text associated with the object.

🧚 text

  • Title: text
  • Usage:
$guesser->text($linesoftext);
$linesofext = $guesser->text;
  • Function: gets or sets the current text associated with an object.
  • Returns: the new lines of texts.
  • Arguments: a scalar containing one or several lines of text, including embedded newlines.
Heads up: a call to this method will clear the current filename and the current filehandle associated with the object.

🧚 guess

  • Title: guess
  • Usage:
$format = $guesser->guess;
@format = $guesser->guess; # if given a line of text
  • Function: guesses the format of the data associated with the object.
  • Returns: a format string such as "swiss" or "pir". If a format can not be found, undef is returned.
  • Arguments: none.

If the object is associated with a filehandle, the position of the filehandle will be returned to its original position before the method returns. So polite, so considerate πŸ’–.


πŸ› οΈ HELPER SUBROUTINES πŸ› οΈ

Okay so every single one of these helper subroutines works the same way: you give it a line of text plus the line number of that same line, and it returns 1 if that line possibly comes from a file of the type it's testing for.

A zero return value does not mean the line isn't part of a certain type of file β€” it just means the test didn't find any characteristics of that type of file in the line. Read it again, bestie, it matters πŸ“Œ.

πŸ¦‹ _possibly_ace

From bioperl test data, and from "http://www.isrec.isb-sib.ch/DEA/module8/B_Stevenson/Practicals/transcriptome_recon/transcriptome_recon.html".

πŸ¦‹ _possibly_blast

From various blast results.

πŸ¦‹ _possibly_bowtie

Contributed by kortsch.

πŸ¦‹ _possibly_clustalw

From "http://www.ebi.ac.uk/help/formats.html".

πŸ¦‹ _possibly_codata

From "http://www.ebi.ac.uk/help/formats.html".

πŸ¦‹ _possibly_embl

From "http://www.ebi.ac.uk/embl/Documentation/User_manual/usrman.html#3.3".

πŸ¦‹ _possibly_fasta

From "http://www.ebi.ac.uk/help/formats.html".

πŸ¦‹ _possibly_fastq

From bioperl test data.

πŸ¦‹ _possibly_fastxy

From bioperl test data.

πŸ¦‹ _possibly_game

From bioperl testdata.

πŸ¦‹ _possibly_gcg

From bioperl, Bio::SeqIO::gcg.

πŸ¦‹ _possibly_gcgblast

From bioperl testdata.

πŸ¦‹ _possibly_gcgfasta

From bioperl testdata.

πŸ¦‹ _possibly_gde

From "http://www.ebi.ac.uk/help/formats.html".

πŸ¦‹ _possibly_genbank

From "http://www.ebi.ac.uk/help/formats.html". Format of [apparantly optional] file header from "http://www.umdnj.edu/rcompweb/PA/Notes/GenbankFF.htm". (TODO: dead link)

πŸ¦‹ _possibly_genscan

From bioperl test data.

πŸ¦‹ _possibly_gff

From bioperl test data.

πŸ¦‹ _possibly_hmmer

From bioperl test data.

πŸ¦‹ _possibly_nexus

From "http://paup.csit.fsu.edu/nfiles.html".

πŸ¦‹ _possibly_mase

From bioperl test data. More detail from "http://www.umdnj.edu/rcompweb/PA/Notes/GenbankFF.htm" (TODO: dead link)

πŸ¦‹ _possibly_mega

From the ensembl broswer (AlignView data export).

πŸ¦‹ _possibly_msf

From "http://www.ebi.ac.uk/help/formats.html".

πŸ¦‹ _possibly_phrap

From "http://biodata.ccgb.umn.edu/docs/contigimage.html". (TODO: dead link) From "http://genetics.gene.cwru.edu/gene508/Lec6.htm". (TODO: dead link) From bioperl test data ("*.ace.1" files).

πŸ¦‹ _possibly_pir

From "http://www.ebi.ac.uk/help/formats.html". The ".,()" spotted in bioperl test data.

πŸ¦‹ _possibly_pfam

From bioperl test data.

πŸ¦‹ _possibly_phylip

From "http://www.ebi.ac.uk/help/formats.html". Initial space allowed on first line (spotted in ensembl AlignView exported data).

πŸ¦‹ _possibly_prodom

From "http://prodom.prabi.fr/prodom/current/documentation/data.php".

πŸ¦‹ _possibly_raw

From "http://www.ebi.ac.uk/help/formats.html".

πŸ¦‹ _possibly_rsf

From "http://www.ebi.ac.uk/help/formats.html".

πŸ¦‹ _possibly_selex

From "http://www.ebc.ee/WWW/hmmer2-html/node27.html".

Assuming presence of Selex file header. Data exported by Bioperl on Pfam and Selex formats are identical, but Pfam file only holds one alignment.

πŸ¦‹ _possibly_stockholm

From bioperl test data.

πŸ¦‹ _possibly_swiss

From "http://ca.expasy.org/sprot/userman.html#entrystruc".

πŸ¦‹ _possibly_tab

Contributed by Heikki.

πŸ¦‹ _possibly_vcf

From "http://www.1000genomes.org/wiki/analysis/vcf4.0".

Assumptions made about sanity β€” format and date lines are line 1 and 2 respectively. This is not specified in the format document.


and that's the whole page, bestie πŸ’œ this shipped as perl v5.32.1, dated 2021-08-15 β€” so yeah, go forth and guess some formats, you absolute icon πŸŽ€βœ¨

πŸ“¦ where this page comes from