NAME
Bio::SeqIO::table - sequence input/output stream from a delimited table
SYNOPSIS
# Do not to use this object directly, use Bio::SeqIO, for example:$in = Bio::SeqIO->new(-file => $filename, -format => 'table');while ( my $seq = $in->next_seq() ) {# do something with $seq}
DESCRIPTION
This class transforms records in a table-formatted text file into Bio::Seq objects.
A table-formatted text file of sequence records for the purposes of this module is defined as a text file with each row corresponding to a sequence, and the attributes of the sequence being in different columns. Columns are delimited by a common delimiter, for instance tab or comma.
The module permits specifying which columns hold which type of annotation. The semantics of certain attributes, if present, are pre-defined, e.g., accession number and sequence. Additional attributes may be added to the annotation bundle.
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 via email or the web:
https://github.com/bioperl/bioperl-live/issues
AUTHOR - Hilmar Lapp
Email hlapp at gmx.net
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
new
Title : newUsage : $stream = Bio::SeqIO->new(-file => $filename, -format => 'table')Function: Returns a new seqstreamReturns : A Bio::SeqIO stream for a table formatArgs : Named parameters:-file Name of file to read-fh Filehandle to attach to-comment Leading character(s) introducing a comment line-header the number of header lines to skip; the firstnon-comment header line will be used to obtaincolumn names; column names will be used as thedefault tags for attaching annotation.-delim The delimiter for columns as a regular expression;consecutive occurrences of the delimiter willnot be collapsed.-display_id The one-based index of the column containingthe display ID of the sequence-accession_number The one-based index of the columncontaining the accession number of the sequence-seq The one-based index of the column containingthe sequence string of the sequence-desc The one-based index of the column containingthe description of the sequence-species The one-based index of the column containing thespecies for the sequence record; if not anumber, will be used as the static speciescommon to all records-annotation If provided and a scalar (but see below), aflag whether or not all additional columns areto be preserved as annotation, the tags usedwill either be 'colX' if there is no columnheader and where X is the one-based columnindex, and otherwise the column headers will beused as tags;If a reference to an array, or a squarebracket-enclosed string of comma-delimitedvalues, only those columns (one-based index)will be preserved as annotation, tags as before;If a reference to a hash, or a curlybraces-enclosed string of comma-delimited keyand value pairs in alternating order, the keysare one-based column indexes to be preserved,and the values are the tags under which theannotation is to be attached; if not provided orsupplied as undef, no additional annotation willbe preserved.-colnames A reference to an array of column labels, or astring of comma-delimited labels, denoting thecolumns to be converted into annotation; this isan alternative to -annotation and will beignored if -annotation is also supplied with avalid value.-trim Flag determining whether or not all values shouldbe trimmed of leading and trailing white spaceand double quotesAdditional arguments may be used to e.g. set factories andbuilders involved in the sequence object creation (see thePOD of Bio::SeqIO).
next_seq
Title : next_seqUsage : $seq = $stream->next_seq()Function: returns the next sequence in the streamReturns : Bio::Seq::RichSeq objectArgs :
comment_char
Title : comment_charUsage : $obj->comment_char($newval)Function: Get/set the leading character(s) designating a line asa comment-line.Example :Returns : value of comment_char (a scalar)Args : on set, new value (a scalar or undef, optional)
header
Title : headerUsage : $obj->header($newval)Function: Get/set the number of header lines to skip before therows containing actual sequence records.If set to zero or undef, means that there is no header andtherefore also no column headers.Example :Returns : value of header (a scalar)Args : on set, new value (a scalar or undef, optional)
delimiter
Title : delimiterUsage : $obj->delimiter($newval)Function: Get/set the column delimiter. This will in fact betreated as a regular expression. Consecutive occurrenceswill not be collapsed to a single one.Example :Returns : value of delimiter (a scalar)Args : on set, new value (a scalar or undef, optional)
attribute_map
Title : attribute_mapUsage : $obj->attribute_map($newval)Function: Get/set the map of sequence object initializationattributes (keys) to one-based column index.Attributes will usually need to be prefixed by a dash, justas if they were passed to the new() method of the sequenceclass.Example :Returns : value of attribute_map (a reference to a hash)Args : on set, new value (a reference to a hash or undef, optional)
annotation_map
Title : annotation_mapUsage : $obj->annotation_map($newval)Function: Get/set the mapping between one-based column indexes(keys) and annotation tags (values).Note that the map returned by this method may change afterthe first next_seq() call if the file contains a columnheader and no annotation keys have been predefined in themap, because upon reading the column header line the tagnames will be set automatically.Note also that the map may reference columns that are usedas well in the sequence attribute map.Example :Returns : value of annotation_map (a reference to a hash)Args : on set, new value (a reference to a hash or undef, optional)
keep_annotation
Title : keep_annotationUsage : $obj->keep_annotation($newval)Function: Get/set flag whether or not to keep values fromadditional columns as annotation.Additional columns are all those columns in the input filethat aren't referenced in the attribute map.Example :Returns : value of keep_annotation (a scalar)Args : on set, new value (a scalar or undef, optional)
annotation_columns
Title : annotation_columnsUsage : $obj->annotation_columns($newval)Function: Get/set the names (labels) of the columns to be used forannotation.This is an alternative to using annotation_map. In order tohave any effect, it must be set before the first call ofnext_seq(), and obviously there must be a header line (orrow) too giving the column labels.Example :Returns : value of annotation_columns (a reference to an array)Args : on set, new value (a reference to an array of undef, optional)
trim_values
Title : trim_valuesUsage : $obj->trim_values($newval)Function: Get/set whether or not to trim leading and trailingwhitespace off all column values.Example :Returns : value of trim_values (a scalar)Args : on set, new value (a scalar or undef, optional)
write_seq
Title: write_seqUsage: write_seq() is not implemented for table format output.
Internal methods
All methods with a leading underscore are not meant to be part of the 'official' API. They are for use by this module only, consider them private unless you are a developer trying to modify this module.
_attribute_map
Title : _attribute_mapUsage : $obj->_attribute_map($newval)Function: Get only. Same as attribute_map, but zero-based indexes.Note that any changes made to the returned map will changethe map used by this instance. You should know what you aredoing if you modify the returned value (or if you call thismethod in the first place).Example :Returns : value of _attribute_map (a reference to a hash)Args : none
_annotation_map
Title : _annotation_mapUsage : $obj->_annotation_map($newval)Function: Get only. Same as annotation_map, but with zero-based indexes.Note that any changes made to the returned map will changethe map used by this instance. You should know what you aredoing if you modify the returned value (or if you call thismethod in the first place).Example :Returns : value of _annotation_map (a reference to a hash)Args : none
_header_skipped
Title : _header_skippedUsage : $obj->_header_skipped($newval)Function: Get/set the flag whether the header was alreadyread (and skipped) or not.Example :Returns : value of _header_skipped (a scalar)Args : on set, new value (a scalar or undef, optional)
_next_record
Title : _next_recordUsage :Function: Navigates the underlying file to the next record.For row-based records in delimited text files, this willskip all empty lines and lines with a leading commentcharacter.This method is here is to serve as a hook for other formatsthat conceptually also represent tables but aren'tformatted as row-based text files.Example :Returns : TRUE if the navigation was successful and FALSEotherwise. Unsuccessful navigation will usually be treatedas an end-of-file condition.Args :
_parse_header
Title : _parse_headerUsage :Function: Parse the table header and navigate past it.This method is called if the number of header rows has beenspecified equal to or greater than one, and positioned atthe first header line (row). By default the first headerline (row) is used for setting column names, but additionallines (rows) may be skipped too. Empty lines and commentlines do not count as header lines (rows).This method will call _next_record() to navigate to thenext header line (row), if there is more than one headerline (row). Upon return, the file is presumed to bepositioned at the first record after the header.This method is here is to serve as a hook for other formatsthat conceptually also represent tables but aren'tformatted as row-based text files.Note however that the only methods used to access filecontent or navigate the position are _get_row_values() and_next_record(), so it should usually suffice to overridethose.Example :Returns : TRUE if navigation past the header was successful and FALSEotherwise. Unsuccessful navigation will usually be treatedas an end-of-file condition.Args :
_get_row_values
Title : _get_row_valuesUsage :Function: Get the values for the current line (or row) as an array inthe order of columns.This method is here is to serve as a hook for other formatsthat conceptually also represent tables but aren'tformatted as row-based text files.Example :Returns : An array of column values for the current row.Args :