NAME
Bio::ASN1::Sequence - Regular expression-based Perl Parser for ASN.1-formatted NCBI Sequences.
VERSION
version 1.73
SYNOPSIS
use Bio::ASN1::Sequence;my $parser = Bio::ASN1::Sequence->new('file' => "downloaded.asn1");while(my $result = $parser->next_seq){# extract data from $result, or Dumpvalue->new->dumpValue($result);}# a new way to get the $result data hash for a particular sequence id:use Bio::ASN1::Sequence::Indexer;my $inx = Bio::ASN1::Sequence::Indexer->new(-filename => 'seq.idx');my $seq = $inx->fetch_hash('AF093062');# for creation of .idx index files please refer to# Bio::ASN1::Sequence::Indexer perldoc
DESCRIPTION
Bio::ASN1::Sequence is a regular expression-based Perl Parser for ASN.1-formatted NCBI sequences. It parses an ASN.1-formatted sequence record and returns a data structure that contains all data items from the sequence record.
The parser will report error & line number if input data does not conform to the NCBI Sequence annotation file format.
The sequence parser is basically a modified version of the high-performance Bio::ASN1::EntrezGene parser. However, I created a standalone module for sequence since it is more efficient to keep Sequence-specific code out of EntrezGene.pm.
In fact it is possible to provide reading of all NCBI's ASN.1-formatted files through simple variations of the Entrez Gene parser (I need more investigation to be sure, but at least the sequence parser works well).
Since demand for parsing NCBI ASN.1-formatted sequences is much lower than EntrezGene, this module is more like a beta version that works on the examples I checked, but I did not check all available records or data definitions. The error-reporting function of this module has to be useful sometimes. :)
ATTRIBUTES
maxerrstr
Parameters: $maxerrstr (optional) - maximum number of characters afteroffending element, used by error reporting, default is 20Example: $parser->maxerrstr(20);Function: get/set maxerrstr.Returns: maxerrstr.Notes:
input_file
Parameters: $filename for file that contains Sequence record(s)Example: $parser->input_file($filename);Function: Takes in name of a file containing Sequence records.opens the file and stores file handleReturns: none.Notes: Attempts to open file larger than 2 GB even on Perl thatdoes not support 2 GB file (accomplished by calling"cat" and piping output. On OS that does not have "cat"error message will be displayed)
METHODS
new
Parameters: maxerrstr => 20 (optional) - maximum number of characters afteroffending element, used by error reporting, default is 20file or -file => $filename (optional) - name of the file to beparsed. call next_seq to parse!fh or -fh => $filehandle (optional) - handle of the file to beparsed.Example: my $parser = Bio::ASN1::Sequence->new();Function: Instantiate a parser objectReturns: Object referenceNotes: Setting file or fh will reset line numbers etc. that are usedfor error reporting purposes, and seeking on file handle wouldmess up linenumbers!
parse
Parameters: $string that contains Sequence record,$trimopt (optional) that specifies how the data structurereturned should be trimmed. 2 is recommended anddefault$noreset (optional) that species that line number should notbe resetDEPRECATED as external function!!! Do not call this functiondirectly! Call next_seq() insteadExample: my $value = $parser->parse($text); # DEPRECATED as# external function!!! Do not call this function# directly! Call next_seq() insteadFunction: Takes in a string representing Sequence record, parsesthe record and returns a data structure.Returns: A data structure containing all data items from the sequencerecord.Notes: DEPRECATED as external function!!! Do not call this functiondirectly! Call next_seq() instead$string should not contain 'Seq-entry ::= set' at beginning!
next_seq
Parameters: $trimopt (optional) that specifies how the data structurereturned should be trimmed. option 2 is recommended anddefaultExample: my $value = $parser->next_seq();Function: Use the file handle generated by input_file, parses the nextthe record and returns a data structure.Returns: A data structure containing all data items from the sequencerecord.Notes: Must pass in a filename through new() or input_file() first!For details on how to use the $trimopt data trimming optionplease see comment for the trimdata method. An optionof 2 is recommended and defaultThe acceptable values for $trimopt include:1 - trim as much as possible2 (or 0, undef) - trim to an easy-to-use structure3 - no trimming (in version 1.06, prior to version1.06, 0 or undef means no trimming)
trimdata
Parameters: $hashref or $arrayref$trimflag (optional, see Notes)Example: trimdata($datahash); # using the default flagFunction: recursively process all attributes of a hash/arrayhybrid and get rid of any arrayref that points toone-element arrays (trims data structure) depending onthe optional flag.Returns: none - trimming happenes in-placeNotes: This function is useful to compact a data structure produced byBio::ASN1::Sequence::parse.The acceptable values for $trimopt include:1 - trim as much as possible2 (or 0, undef) - trim to an easy-to-use structure3 - no trimming (in version 1.06, prior to version1.06, 0 or undef means no trimming)This function is duplicate to EntrezGene.pm's and code shouldbe compressed in the future (using util module & subclass).
fh
Parameters: $filehandle (optional)Example: trimdata($datahash); # using the default flagFunction: getter/setter for file handleReturns: file handle for current file being parsed.Notes: Use with care!Line number report would not be corresponding to file's linenumber if seek operation is performed on the file handle!
rawdata
Parameters: noneExample: my $data = $parser->rawdata();Function: Get the sequence data file that was just parsedReturns: a string containing the ASN1-formatted sequence recordNotes: Must first parse a record then call this function!Could be useful in interpreting line number value in errorreport (if user did a seek on file handle right before parsingcall)
INTERNAL METHODS
_parse
NCBI's Apr 05, 2005 format change forced much usage of lookahead, which would for sure slows parser down. But can't code efficiently without it.
PREREQUISITE
None.
INSTALLATION
Bio::ASN1::Sequence is part of the Bio::ASN1::EntrezGene package. Bio::ASN1::EntrezGene package can be installed & tested as follows:
perl Makefile.PLmakemake testmake install
SEE ALSO
The parse_sequence_example.pl script included in this package (please see the Bio-ASN1-EntrezGene-x.xx/examples directory) shows the usage.
Please check out perldoc for Bio::ASN1::EntrezGene for more info.
CITATION
Liu, Mingyi, and Andrei Grigoriev. "Fast parsers for Entrez Gene." Bioinformatics 21, no. 14 (2005): 3189-3190.
OPERATION SYSTEMS SUPPORTED
Any OS that Perl runs on.
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 the Bioperl mailing list. Your participation is much appreciated.
[email protected] - General discussionhttp://bioperl.org/Support.html - About the mailing lists
Support
Please direct usage questions or support issues to the mailing list: [email protected]
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 of the bugs and their resolution. Bug reports can be submitted via the web:
https://github.com/bioperl/bio-asn1-entrezgene/issues
AUTHOR
Dr. Mingyi Liu <[email protected]>
COPYRIGHT
This software is copyright (c) 2005 by Mingyi Liu, 2005 by GPC Biotech AG, and 2005 by Altana Research Institute.
This software is available under the same terms as the perl 5 programming language system itself.