|
NAMEBio::AlignIO - Handler for AlignIO FormatsSYNOPSISuse Bio::AlignIO; $inputfilename = "testaln.fasta"; $in = Bio::AlignIO->new(-file => $inputfilename , -format => 'fasta'); $out = Bio::AlignIO->new(-file => ">out.aln.pfam" , -format => 'pfam'); while ( my $aln = $in->next_aln() ) { $out->write_aln($aln); } # OR use Bio::AlignIO; open MYIN, '<', 'testaln.fasta' or die "Could not read file 'testaln.fasta': $!\n"; $in = Bio::AlignIO->newFh(-fh => \*MYIN, -format => 'fasta'); open my $MYOUT, '>', 'testaln.pfam' or die "Could not write file 'testaln.pfam': $!\n"; $out = Bio::AlignIO->newFh(-fh => $MYOUT, -format => 'pfam'); # World's smallest Fasta<->pfam format converter: print $out $_ while <$in>; DESCRIPTIONBio::AlignIO is a handler module for the formats in the AlignIO set, for example, Bio::AlignIO::fasta. It is the officially sanctioned way of getting at the alignment objects. The resulting alignment is a Bio::Align::AlignI-compliant object.The idea is that you request an object for a particular format. All the objects have a notion of an internal file that is read from or written to. A particular AlignIO object instance is configured for either input or output, you can think of it as a stream object. Each object has functions: $stream->next_aln(); And: $stream->write_aln($aln); Also: $stream->type() # returns 'INPUT' or 'OUTPUT' As an added bonus, you can recover a filehandle that is tied to the AlignIO object, allowing you to use the standard <> and print operations to read and write alignment objects: use Bio::AlignIO; # read from standard input $stream = Bio::AlignIO->newFh(-format => 'Fasta'); while ( $aln = <$stream> ) { # do something with $aln } And: print $stream $aln; # when stream is in output mode Bio::AlignIO is patterned on the Bio::SeqIO module and shares most of its features. One significant difference is that Bio::AlignIO usually handles IO for only a single alignment at a time, whereas Bio::SeqIO handles IO for multiple sequences in a single stream. The principal reason for this is that whereas simultaneously handling multiple sequences is a common requirement, simultaneous handling of multiple alignments is not. The only current exception is format "bl2seq" which parses results of the BLAST "bl2seq" program and which may produce several alignment pairs. This set of alignment pairs can be read using multiple calls to next_aln. CONSTRUCTORSBio::AlignIO->new()$seqIO = Bio::AlignIO->new(-file => 'filename', -format=>$format); $seqIO = Bio::AlignIO->new(-fh => \*FILEHANDLE, -format=>$format); $seqIO = Bio::AlignIO->new(-format => $format); $seqIO = Bio::AlignIO->new(-fh => \*STDOUT, -format => $format); The new class method constructs a new Bio::AlignIO object. The returned object can be used to retrieve or print alignment objects. new accepts the following parameters:
Bio::AlignIO->newFh()$fh = Bio::AlignIO->newFh(-fh => \*FILEHANDLE, -format=>$format); # read from STDIN or use @ARGV: $fh = Bio::AlignIO->newFh(-format => $format); This constructor behaves like new, but returns a tied filehandle rather than a Bio::AlignIO 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.
OBJECT METHODSSee below for more detailed summaries. The main methods are:$alignment = $AlignIO->next_aln()Fetch an alignment from a formatted file.$AlignIO->write_aln($aln)Write the specified alignment to a file..TIEHANDLE(), READLINE(), PRINT()These provide the tie interface. See perltie for more details.FEEDBACKMailing ListsUser 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.bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists SupportPlease 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. Reporting BugsReport 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:https://github.com/bioperl/bioperl-live/issues AUTHOR - Peter SchattnerEmail: schattner@alum.mit.eduCONTRIBUTORSJason Stajich, jason@bioperl.orgAPPENDIXThe rest of the documentation details each of the object methods. Internal methods are usually preceded with a _newTitle : new Usage : $stream = Bio::AlignIO->new(-file => $filename, -format => 'Format') Function: Returns a new seqstream Returns : A Bio::AlignIO::Handler initialised with the appropriate format Args : -file => $filename -format => format -fh => filehandle to attach to -displayname_flat => 1 [optional] to force the displayname to not show start/end information newFhTitle : newFh Usage : $fh = Bio::AlignIO->newFh(-file=>$filename,-format=>'Format') Function: does a new() followed by an fh() Example : $fh = Bio::AlignIO->newFh(-file=>$filename,-format=>'Format') $sequence = <$fh>; # read a sequence object print $fh $sequence; # write a sequence object Returns : filehandle tied to the Bio::AlignIO::Fh class Args : fhTitle : fh Usage : $obj->fh Function: 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 the Bio::AlignIO::Fh class Args : formatTitle : format Usage : $format = $stream->format() Function: Get the alignment format Returns : alignment format Args : none _load_format_moduleTitle : _load_format_module Usage : *INTERNAL AlignIO stuff* Function: Loads up (like use) a module at run time on demand Example : Returns : Args : next_alnTitle : next_aln Usage : $aln = stream->next_aln Function: reads the next $aln object from the stream Returns : a Bio::Align::AlignI compliant object Args : write_alnTitle : write_aln Usage : $stream->write_aln($aln) Function: writes the $aln object into the stream Returns : 1 for success and 0 for error Args : Bio::Seq object _guess_formatTitle : _guess_format Usage : $obj->_guess_format($filename) Function: Example : Returns : guessed format of filename (lower case) Args : force_displayname_flatTitle : force_displayname_flat Usage : $obj->force_displayname_flat($newval) Function: Example : Returns : value of force_displayname_flat (a scalar) Args : on set, new value (a scalar or undef, optional) alphabetTitle : alphabet Usage : $obj->alphabet($newval) Function: Get/Set alphabet for purpose of passing to Bio::LocatableSeq creation Example : $obj->alphabet('dna'); Returns : value of alphabet (a scalar) Args : on set, new value (a scalar or undef, optional)
Visit the GSP FreeBSD Man Page Interface. |