A file path to be opened for reading or writing. The usual Perl
You may use new() with a opened filehandle, provided as a glob reference. For
example, to read from STDIN:
A string filehandle is handy if you want to modify the output in the memory, before printing it out. The following program reads in EMBL formatted entries from a file and prints them out in fasta format with some HTML tags:
A string to read the sequences from. For example:
Specify the format of the file. Supported formats include fasta,
genbank, embl, swiss (SwissProt), Entrez Gene and tracefile formats
such as abi (ABI) and scf. There are many more, for a complete listing
see the SeqIO HOWTO (<http://bioperl.open-bio.org/wiki/HOWTO:SeqIO>).
If no format is specified and a filename is given then the module will attempt to deduce the format from the filename suffix. If there is no suffix that Bioperl understands then it will attempt to guess the format based on file content. If this is unsuccessful then SeqIO will throw a fatal error.
The format name is case-insensitive: FASTA, Fasta and fasta are all valid.
Currently, the tracefile formats (except for SCF) require installation of the external Staden io_lib package, as well as the Bio::SeqIO::staden::read package available from the bioperl-ext repository.
|-alphabet||Sets the alphabet (dna, rna, or protein). When the alphabet is set then Bioperl will not attempt to guess what the alphabet is. This may be important because Bioperl does not always guess correctly.|
By default, all files (or filehandles) opened for writing sequences
will be flushed after each write_seq() (making the file immediately
usable). If you do not need this facility and would like to marginally
improve the efficiency of writing multiple sequences to the same file
(or filehandle), pass the -flush option 0 or any other value that
evaluates as defined but false:
|-seqfactory||Provide a Bio::Factory::SequenceFactoryI object. See the sequence_factory() method.|
|-locfactory||Provide a Bio::Factory::LocationFactoryI object. See the location_factory() method.|
|-objbuilder||Provide a Bio::Factory::ObjectBuilderI object. See the object_builder() method.|
$fh = Bio::SeqIO->newFh(-fh => \*FILEHANDLE, -format=>$format); $fh = Bio::SeqIO->newFh(-format => $format); # etc.
This constructor behaves like new(), but returns a tied filehandle rather than a Bio::SeqIO object. You can read sequences from this object using the familiar <> operator, and write to it using print(). The usual array and $_ semantics work. For example, you can read all sequence objects into an array like this:
@sequences = <$fh>;
Other operations, such as read(), sysread(), write(), close(), and printf() are not supported.
See below for more detailed summaries. The main methods are:
CW$sequence = CW$seqIO->next_seq()Fetch the next sequence from the stream, or nothing if no more.
CW$seqIO->write_seq($sequence [,$another_sequence,...])Write the specified sequence(s) to the stream.
TIEHANDLE(), READLINE(), PRINT()These provide the tie interface. See perltie for more details.
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.
Please direct usage questions or support issues to the mailing list:
rather than to the module maintainer directly. Many experienced and responsive 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.
Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web:
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
Title : new Usage : $stream = Bio::SeqIO->new(-file => sequences.fasta, -format => fasta); Function: Returns a new sequence stream Returns : A Bio::SeqIO stream initialised with the appropriate format Args : Named parameters indicating where to read the sequences from or to write them to: -file => filename, OR -fh => filehandle to attach to, OR -string => string Additional arguments, all with reasonable defaults: -format => format of the sequences, usually auto-detected -alphabet => dna, rna, or protein -flush => 0 or 1 (default: flush filehandles after each write) -seqfactory => sequence factory -locfactory => location factory -objbuilder => object builder
Title : newFh Usage : $fh = Bio::SeqIO->newFh(-file=>$filename,-format=>Format) Function: Does a new() followed by an fh() Example : $fh = Bio::SeqIO->newFh(-file=>$filename,-format=>Format) $sequence = <$fh>; # read a sequence object print $fh $sequence; # write a sequence object Returns : filehandle tied to the Bio::SeqIO::Fh class Args :
Title : fh Usage : $obj->fh Function: Get or set the IO filehandle Example : $fh = $obj->fh; # make a tied filehandle $sequence = <$fh>; # read a sequence object print $fh $sequence; # write a sequence object Returns : filehandle tied to Bio::SeqIO class Args : none
Title : next_seq Usage : $seq = stream->next_seq Function: Reads the next sequence object from the stream and returns it. Certain driver modules may encounter entries in the stream that are either misformatted or that use syntax not yet understood by the driver. If such an incident is recoverable, e.g., by dismissing a feature of a feature table or some other non-mandatory part of an entry, the driver will issue a warning. In the case of a non-recoverable situation an exception will be thrown. Do not assume that you can resume parsing the same stream after catching the exception. Note that you can always turn recoverable errors into exceptions by calling $stream->verbose(2). Returns : a Bio::Seq sequence object, or nothing if no more sequences are available Args : none
Title : write_seq Usage : $stream->write_seq($seq) Function: writes the $seq object into the stream Returns : 1 for success and 0 for error Args : Bio::Seq object
Title : format Usage : $format = $stream->format() Function: Get the sequence format Returns : sequence format, e.g. fasta, fastq Args : none
Title : alphabet Usage : $self->alphabet($newval) Function: Set/get the molecule type for the Seq objects to be created. Example : $seqio->alphabet(protein) Returns : value of alphabet: dna, rna, or protein Args : newvalue (optional) Throws : Exception if the argument is not one of dna, rna, or protein
Title : _load_format_module Usage : *INTERNAL SeqIO stuff* Function: Loads up (like use) a module at run time on demand Example : Returns : Args :
Title : _concatenate_lines Usage : $s = _concatenate_lines($line, $continuation_line) Function: Private. Concatenates two strings assuming that the second stems from a continuation line of the first. Adds a space between both unless the first ends with a dash. Takes care of either arg being empty. Example : Returns : A string. Args :
Title : _filehandle Usage : $obj->_filehandle($newval) Function: This method is deprecated. Call _fh() instead. Example : Returns : value of _filehandle Args : newvalue (optional)
Title : _guess_format Usage : $obj->_guess_format($filename) Function: guess format based on file suffix Example : Returns : guessed format of filename (lower case) Args : Notes : formats that _filehandle() will guess include fasta, genbank, scf, pir, embl, raw, gcg, ace, bsml, swissprot, fastq and phd/phred
Title : sequence_factory Usage : $seqio->sequence_factory($seqfactory) Function: Get/Set the Bio::Factory::SequenceFactoryI Returns : Bio::Factory::SequenceFactoryI Args : [optional] Bio::Factory::SequenceFactoryI
Title : object_factory Usage : $obj->object_factory($newval) Function: This is an alias to sequence_factory with a more generic name. Example : Returns : value of object_factory (a scalar) Args : on set, new value (a scalar or undef, optional)
Title : sequence_builder Usage : $seqio->sequence_builder($seqfactory) Function: Get/Set the Bio::Factory::ObjectBuilderI used to build sequence objects. This applies to rich sequence formats only, e.g. genbank but not fasta. If you do not set the sequence object builder yourself, it will in fact be an instance of L<Bio::Seq::SeqBuilder>, and you may use all methods documented there to configure it. Returns : a Bio::Factory::ObjectBuilderI compliant object Args : [optional] a Bio::Factory::ObjectBuilderI compliant object
Title : location_factory Usage : $seqio->location_factory($locfactory) Function: Get/Set the Bio::Factory::LocationFactoryI object to be used for location string parsing Returns : a Bio::Factory::LocationFactoryI implementing object Args : [optional] on set, a Bio::Factory::LocationFactoryI implementing object.
|perl v5.20.3||BIO::SEQIO (3)||2016-04-05|