.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Bio::AlignIO 3pm" .TH Bio::AlignIO 3pm "2021-08-15" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Bio::AlignIO \- Handler for AlignIO Formats .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Bio::AlignIO; \& \& $inputfilename = "testaln.fasta"; \& $in = Bio::AlignIO\->new(\-file => $inputfilename , \& \-format => \*(Aqfasta\*(Aq); \& $out = Bio::AlignIO\->new(\-file => ">out.aln.pfam" , \& \-format => \*(Aqpfam\*(Aq); \& \& while ( my $aln = $in\->next_aln() ) { \& $out\->write_aln($aln); \& } \& \& # OR \& \& use Bio::AlignIO; \& \& open MYIN, \*(Aq<\*(Aq, \*(Aqtestaln.fasta\*(Aq or die "Could not read file \*(Aqtestaln.fasta\*(Aq: $!\en"; \& $in = Bio::AlignIO\->newFh(\-fh => \e*MYIN, \& \-format => \*(Aqfasta\*(Aq); \& open my $MYOUT, \*(Aq>\*(Aq, \*(Aqtestaln.pfam\*(Aq or die "Could not write file \*(Aqtestaln.pfam\*(Aq: $!\en"; \& $out = Bio::AlignIO\->newFh(\-fh => $MYOUT, \& \-format => \*(Aqpfam\*(Aq); \& \& # World\*(Aqs smallest Fasta<\->pfam format converter: \& print $out $_ while <$in>; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Bio::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. .PP 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. .PP Each object has functions: .PP .Vb 1 \& $stream\->next_aln(); .Ve .PP And: .PP .Vb 1 \& $stream\->write_aln($aln); .Ve .PP Also: .PP .Vb 1 \& $stream\->type() # returns \*(AqINPUT\*(Aq or \*(AqOUTPUT\*(Aq .Ve .PP 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: .PP .Vb 1 \& use Bio::AlignIO; \& \& # read from standard input \& $stream = Bio::AlignIO\->newFh(\-format => \*(AqFasta\*(Aq); \& \& while ( $aln = <$stream> ) { \& # do something with $aln \& } .Ve .PP And: .PP .Vb 1 \& print $stream $aln; # when stream is in output mode .Ve .PP Bio::AlignIO is patterned on the Bio::SeqIO module and shares most of its features. One significant difference is that Bio::AlignIO usually handles \s-1IO\s0 for only a single alignment at a time, whereas Bio::SeqIO handles \s-1IO\s0 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 \&\f(CW\*(C`bl2seq\*(C'\fR which parses results of the \s-1BLAST\s0 \f(CW\*(C`bl2seq\*(C'\fR program and which may produce several alignment pairs. This set of alignment pairs can be read using multiple calls to next_aln. .SH "CONSTRUCTORS" .IX Header "CONSTRUCTORS" .SS "Bio::AlignIO\->\fBnew()\fP" .IX Subsection "Bio::AlignIO->new()" .Vb 4 \& $seqIO = Bio::AlignIO\->new(\-file => \*(Aqfilename\*(Aq, \-format=>$format); \& $seqIO = Bio::AlignIO\->new(\-fh => \e*FILEHANDLE, \-format=>$format); \& $seqIO = Bio::AlignIO\->new(\-format => $format); \& $seqIO = Bio::AlignIO\->new(\-fh => \e*STDOUT, \-format => $format); .Ve .PP 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: .IP "\-file" 4 .IX Item "-file" A file path to be opened for reading or writing. The usual Perl conventions apply: .Sp .Vb 6 \& \*(Aqfile\*(Aq # open file for reading \& \*(Aq>file\*(Aq # open file for writing \& \*(Aq>>file\*(Aq # open file for appending \& \*(Aq+new(\-fh => \e*STDIN); .Ve .Sp Note that you must pass filehandles as references to globs. .Sp If neither a filehandle nor a filename is specified, then the module will read from the \f(CW@ARGV\fR array or \s-1STDIN,\s0 using the familiar <> semantics. .IP "\-format" 4 .IX Item "-format" Specify the format of the file. Supported formats include: .Sp .Vb 10 \& bl2seq Bl2seq Blast output \& clustalw clustalw (.aln) format \& emboss EMBOSS water and needle format \& fasta FASTA format \& maf Multiple Alignment Format \& mase mase (seaview) format \& mega MEGA format \& meme MEME format \& msf msf (GCG) format \& nexus Swofford et al NEXUS format \& pfam Pfam sequence alignment format \& phylip Felsenstein PHYLIP format \& prodom prodom (protein domain) format \& psi PSI\-BLAST format \& selex selex (hmmer) format \& stockholm stockholm format .Ve .Sp Currently only those formats which were implemented in Bio::SimpleAlign have been incorporated into Bio::AlignIO. Specifically, \f(CW\*(C`mase\*(C'\fR, \f(CW\*(C`stockholm\*(C'\fR and \f(CW\*(C`prodom\*(C'\fR have only been implemented for input. See the specific module (e.g. Bio::AlignIO::prodom) for notes on supported versions. .Sp If no format is specified and a filename is given, then the module will attempt to deduce it from the filename suffix. If this is unsuccessful, \&\f(CW\*(C`fasta\*(C'\fR format is assumed. .Sp The format name is case insensitive; \f(CW\*(C`FASTA\*(C'\fR, \f(CW\*(C`Fasta\*(C'\fR and \f(CW\*(C`fasta\*(C'\fR are all treated equivalently. .SS "Bio::AlignIO\->\fBnewFh()\fP" .IX Subsection "Bio::AlignIO->newFh()" .Vb 3 \& $fh = Bio::AlignIO\->newFh(\-fh => \e*FILEHANDLE, \-format=>$format); \& # read from STDIN or use @ARGV: \& $fh = Bio::AlignIO\->newFh(\-format => $format); .Ve .PP 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 \f(CW$_\fR semantics work. For example, you can read all sequence objects into an array like this: .PP .Vb 1 \& @sequences = <$fh>; .Ve .PP Other operations, such as \fBread()\fR, \fBsysread()\fR, \fBwrite()\fR, \fBclose()\fR, and \fBprintf()\fR are not supported. .IP "\-flush" 1 .IX Item "-flush" By default, all files (or filehandles) opened for writing alignments will be flushed after each \fBwrite_aln()\fR 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: .Sp .Vb 6 \& my $clustal = Bio::AlignIO\->new( \-file => " "clustalw" ); \& my $msf = Bio::AlignIO\->new(\-file => ">prot.msf", \& \-format => "msf", \& \-flush => 0 ); # go as fast as we can! \& while($seq = $clustal\->next_aln) { $msf\->write_aln($seq) } .Ve .SH "OBJECT METHODS" .IX Header "OBJECT METHODS" See below for more detailed summaries. The main methods are: .ie n .SS "$alignment = $AlignIO\->\fBnext_aln()\fP" .el .SS "\f(CW$alignment\fP = \f(CW$AlignIO\fP\->\fBnext_aln()\fP" .IX Subsection "$alignment = $AlignIO->next_aln()" Fetch an alignment from a formatted file. .ie n .SS "$AlignIO\->write_aln($aln)" .el .SS "\f(CW$AlignIO\fP\->write_aln($aln)" .IX Subsection "$AlignIO->write_aln($aln)" Write the specified alignment to a file.. .SS "\s-1\fBTIEHANDLE\s0()\fP, \s-1\fBREADLINE\s0()\fP, \s-1\fBPRINT\s0()\fP" .IX Subsection "TIEHANDLE(), READLINE(), PRINT()" These provide the tie interface. See perltie for more details. .SH "FEEDBACK" .IX Header "FEEDBACK" .SS "Mailing Lists" .IX Subsection "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. .PP .Vb 2 \& bioperl\-l@bioperl.org \- General discussion \& http://bioperl.org/wiki/Mailing_lists \- About the mailing lists .Ve .SS "Support" .IX Subsection "Support" Please direct usage questions or support issues to the mailing list: .PP \&\fIbioperl\-l@bioperl.org\fR .PP 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. .SS "Reporting Bugs" .IX Subsection "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 the web: .PP .Vb 1 \& https://github.com/bioperl/bioperl\-live/issues .Ve .SH "AUTHOR \- Peter Schattner" .IX Header "AUTHOR - Peter Schattner" Email: schattner@alum.mit.edu .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" Jason Stajich, jason@bioperl.org .SH "APPENDIX" .IX Header "APPENDIX" The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ .SS "new" .IX Subsection "new" .Vb 12 \& Title : new \& Usage : $stream = Bio::AlignIO\->new(\-file => $filename, \& \-format => \*(AqFormat\*(Aq) \& 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 .Ve .SS "newFh" .IX Subsection "newFh" .Vb 8 \& Title : newFh \& Usage : $fh = Bio::AlignIO\->newFh(\-file=>$filename,\-format=>\*(AqFormat\*(Aq) \& Function: does a new() followed by an fh() \& Example : $fh = Bio::AlignIO\->newFh(\-file=>$filename,\-format=>\*(AqFormat\*(Aq) \& $sequence = <$fh>; # read a sequence object \& print $fh $sequence; # write a sequence object \& Returns : filehandle tied to the Bio::AlignIO::Fh class \& Args : .Ve .SS "fh" .IX Subsection "fh" .Vb 8 \& Title : 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 : .Ve .SS "format" .IX Subsection "format" .Vb 5 \& Title : format \& Usage : $format = $stream\->format() \& Function: Get the alignment format \& Returns : alignment format \& Args : none .Ve .SS "_load_format_module" .IX Subsection "_load_format_module" .Vb 6 \& Title : _load_format_module \& Usage : *INTERNAL AlignIO stuff* \& Function: Loads up (like use) a module at run time on demand \& Example : \& Returns : \& Args : .Ve .SS "next_aln" .IX Subsection "next_aln" .Vb 5 \& Title : next_aln \& Usage : $aln = stream\->next_aln \& Function: reads the next $aln object from the stream \& Returns : a Bio::Align::AlignI compliant object \& Args : .Ve .SS "write_aln" .IX Subsection "write_aln" .Vb 5 \& Title : 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 .Ve .SS "_guess_format" .IX Subsection "_guess_format" .Vb 6 \& Title : _guess_format \& Usage : $obj\->_guess_format($filename) \& Function: \& Example : \& Returns : guessed format of filename (lower case) \& Args : .Ve .SS "force_displayname_flat" .IX Subsection "force_displayname_flat" .Vb 6 \& Title : 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) .Ve .SS "alphabet" .IX Subsection "alphabet" .Vb 6 \& Title : alphabet \& Usage : $obj\->alphabet($newval) \& Function: Get/Set alphabet for purpose of passing to Bio::LocatableSeq creation \& Example : $obj\->alphabet(\*(Aqdna\*(Aq); \& Returns : value of alphabet (a scalar) \& Args : on set, new value (a scalar or undef, optional) .Ve