NAME
Bio::Align::AlignI - An interface for describing sequence alignments.
SYNOPSIS
# get a Bio::Align::AlignI somehow - typically using Bio::AlignIO system# some descriptorsprint $aln->length, "\n";print $aln->num_residues, "\n";print $aln->is_flush, "\n";print $aln->num_sequences, "\n";print $aln->percentage_identity, "\n";print $aln->consensus_string(50), "\n";# find the position in the alignment for a sequence location$pos = $aln->column_from_residue_number('1433_LYCES', 14); # = 6;# extract sequences and check values for the alignment column $posforeach $seq ($aln->each_seq) {$res = $seq->subseq($pos, $pos);$count{$res}++;}foreach $res (keys %count) {printf "Res: %s Count: %2d\n", $res, $count{$res};}
DESCRIPTION
This interface describes the basis for alignment objects.
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/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 of the bugs and their resolution. Bug reports can be submitted via the web:
https://github.com/bioperl/bioperl-live/issues
AUTHOR - Jason Stajich
Email [email protected]
CONTRIBUTORS
Ewan Birney, [email protected] Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
Modifier methods
These methods modify the MSE by adding, removing or shuffling complete sequences.
add_seq
Title : add_seqUsage : $myalign->add_seq($newseq);Function : Adds another sequence to the alignment. *Does not* alignit - just adds it to the hashes.Returns : NoneArgument : a Bio::LocatableSeq objectorder (optional)
See Bio::LocatableSeq for more information.
remove_seq
Title : remove_seqUsage : $aln->remove_seq($seq);Function : Removes a single sequence from an alignmentReturns :Argument : a Bio::LocatableSeq object
purge
Title : purgeUsage : $aln->purge(0.7);Function:Removes sequences above whatever %id.This function will grind on large alignments. Beware!(perhaps not ideally implemented)Example :Returns : An array of the removed sequencesArgument:
sort_alphabetically
Title : sort_alphabeticallyUsage : $ali->sort_alphabeticallyFunction :Changes the order of the alignment to alphabetical on namefollowed by numerical by number.Returns : an arrayArgument :
Sequence selection methods
Methods returning one or more sequences objects.
each_seq
Title : each_seqUsage : foreach $seq ( $align->each_seq() )Function : Gets an array of Seq objects from the alignmentReturns : an arrayArgument :
each_alphabetically
Title : each_alphabeticallyUsage : foreach $seq ( $ali->each_alphabetically() )Function :Returns an array of sequence object sorted alphabeticallyby name and then by start point.Does not change the order of the alignmentReturns :Argument :
each_seq_with_id
Title : each_seq_with_idUsage : foreach $seq ( $align->each_seq_with_id() )Function :Gets an array of Seq objects from thealignment, the contents being those sequenceswith the given name (there may be more than one)Returns : an arrayArgument : a seq name
get_seq_by_pos
Title : get_seq_by_posUsage : $seq = $aln->get_seq_by_pos(3) # third sequence from the alignmentFunction :Gets a sequence based on its position in the alignment.Numbering starts from 1. Sequence positions larger thannum_sequences() will throw an error.Returns : a Bio::LocatableSeq objectArgument : positive integer for the sequence position
Create new alignments
The result of these methods are horizontal or vertical subsets of the current MSE.
select
Title : selectUsage : $aln2 = $aln->select(1, 3) # three first sequencesFunction :Creates a new alignment from a continuous subset ofsequences. Numbering starts from 1. Sequence positionslarger than num_sequences() will throw an error.Returns : a Bio::SimpleAlign objectArgument : positive integer for the first sequencepositive integer for the last sequence to include (optional)
select_noncont
Title : select_noncontUsage : $aln2 = $aln->select_noncont(1, 3) # first and 3rd sequencesFunction :Creates a new alignment from a subset ofsequences. Numbering starts from 1. Sequence positionslarger than num_sequences() will throw an error.Returns : a Bio::SimpleAlign objectArgs : array of integers for the sequences
slice
Title : sliceUsage : $aln2 = $aln->slice(20, 30)Function :Creates a slice from the alignment inclusive of start andend columns. Sequences with no residues in the slice areexcluded from the new alignment and a warning is printed.Slice beyond the length of the sequence does not dopadding.Returns : a Bio::SimpleAlign objectArgument : positive integer for start columnpositive integer for end column
Change sequences within the MSE
These methods affect characters in all sequences without changing the alignment.
map_chars
Title : map_charsUsage : $ali->map_chars('\.','-')Function :Does a s/$arg1/$arg2/ on the sequences. Useful for gapcharactersNotice that the "from" (arg1) is interpreted as a regex,so be careful about quoting meta characters (e.g.$ali->map_chars('.', '-') won't do what you want)Returns : NoneArgument : 'from' rexexp'to' string
uppercase
Title : uppercase()Usage : $ali->uppercase()Function : Sets all the sequences to uppercaseReturns :Argument :
match_line
Title : match_line()Usage : $align->match_line()Function : Generates a match line - much like consensus stringexcept that a line indicating the '*' for a match.Argument : (optional) Match line characters ('*' by default)(optional) Strong match char (':' by default)(optional) Weak match char ('.' by default)
match
Title : match()Usage : $ali->match()Function :Goes through all columns and changes residues that areidentical to residue in first sequence to match '.'character. Sets match_char.USE WITH CARE: Most MSE formats do not support matchcharacters in sequences, so this is mostly for outputonly. NEXUS format (Bio::AlignIO::nexus) can handleit.Returns : 1Argument : a match character, optional, defaults to '.'
unmatch
Title : unmatch()Usage : $ali->unmatch()Function :Undoes the effect of method match. Unsets match_char.Returns : 1Argument : a match character, optional, defaults to '.'
MSE attibutes
Methods for setting and reading the MSE attributes.
Note that the methods defining character semantics depend on the user to set them sensibly. They are needed only by certain input/output methods. Unset them by setting to an empty string ('').
id
Title : idUsage : $myalign->id("Ig")Function : Gets/sets the id field of the alignmentReturns : An id stringArgument : An id string (optional)
missing_char
Title : missing_charUsage : $myalign->missing_char("?")Function : Gets/sets the missing_char attribute of the alignmentIt is generally recommended to set it to 'n' or 'N'for nucleotides and to 'X' for protein.Returns : An missing_char string,Argument : An missing_char string (optional)
match_char
Title : match_charUsage : $myalign->match_char('.')Function : Gets/sets the match_char attribute of the alignmentReturns : An match_char string,Argument : An match_char string (optional)
gap_char
Title : gap_charUsage : $myalign->gap_char('-')Function : Gets/sets the gap_char attribute of the alignmentReturns : An gap_char string, defaults to '-'Argument : An gap_char string (optional)
symbol_chars
Title : symbol_charsUsage : my @symbolchars = $aln->symbol_chars;Function: Returns all the seen symbols (other than gaps)Returns : array of characters that are the seen symbolsArgument: boolean to include the gap/missing/match characters
Alignment descriptors
These read only methods describe the MSE in various ways.
consensus_string
Title : consensus_stringUsage : $str = $ali->consensus_string($threshold_percent)Function : Makes a strict consensusReturns : consensus stringArgument : Optional threshold ranging from 0 to 100.The consensus residue has to appear at least threshold %of the sequences at a given location, otherwise a '?'character will be placed at that location.(Default value = 0%)
consensus_iupac
Title : consensus_iupacUsage : $str = $ali->consensus_iupac()Function :Makes a consensus using IUPAC ambiguity codes from DNAand RNA. The output is in upper case except when gaps ina column force output to be in lower case.Note that if your alignment sequences contain a lot ofIUPAC ambiquity codes you often have to manually setalphabet. Bio::PrimarySeq::_guess_type thinks theyindicate a protein sequence.Returns : consensus stringArgument : noneThrows : on protein sequences
is_flush
Title : is_flushUsage : if( $ali->is_flush() )::Function : Tells you whether the alignment: is flush, ie all of the same length::Returns : 1 or 0Argument :
length
Title : length()Usage : $len = $ali->length()Function : Returns the maximum length of the alignment.To be sure the alignment is a block, use is_flushReturns : integerArgument :
maxname_length
Title : maxname_lengthUsage : $ali->maxname_length()Function :Gets the maximum length of the displayname in thealignment. Used in writing out various MSE formats.Returns : integerArgument :
num_residues
Title : num_residuesUsage : $no = $ali->num_residuesFunction : number of residues in total in the alignmentReturns : integerArgument :Note : replaces no_residues
num_sequences
Title : num_sequencesUsage : $depth = $ali->num_sequencesFunction : number of sequence in the sequence alignmentReturns : integerArgument : NoneNote : replaces no_sequences
percentage_identity
Title : percentage_identityUsage : $id = $align->percentage_identityFunction: The function calculates the percentage identity of the alignmentReturns : The percentage identity of the alignment (as defined by theimplementation)Argument: None
overall_percentage_identity
Title : overall_percentage_identityUsage : $id = $align->overall_percentage_identityFunction: The function calculates the percentage identity ofthe conserved columnsReturns : The percentage identity of the conserved columnsArgs : None
average_percentage_identity
Title : average_percentage_identityUsage : $id = $align->average_percentage_identityFunction: The function uses a fast method to calculate the averagepercentage identity of the alignmentReturns : The average percentage identity of the alignmentArgs : None
Alignment positions
Methods to map a sequence position into an alignment column and back. column_from_residue_number() does the former. The latter is really a property of the sequence object and can done using Bio::LocatableSeq::location_from_column:
# select somehow a sequence from the alignment, e.g.my $seq = $aln->get_seq_by_pos(1);#$loc is undef or Bio::LocationI objectmy $loc = $seq->location_from_column(5);
column_from_residue_number
Title : column_from_residue_numberUsage : $col = $ali->column_from_residue_number( $seqname, $resnumber)Function:This function gives the position in the alignment(i.e. column number) of the given residue number in thesequence with the given name. For example, for thealignmentSeq1/91-97 AC..DEF.GHSeq2/24-30 ACGG.RTY..Seq3/43-51 AC.DDEFGHIcolumn_from_residue_number( "Seq1", 94 ) returns 6.column_from_residue_number( "Seq2", 25 ) returns 2.column_from_residue_number( "Seq3", 50 ) returns 9.An exception is thrown if the residue number would lieoutside the length of the alignment(e.g. column_from_residue_number( "Seq2", 22 )Note: If the parent sequence is represented by more than onealignment sequence and the residue number is present inthem, this method finds only the first one.Returns : A column number for the position in the alignment of thegiven residue in the given sequence (1 = first column)Args : A sequence id/name (not a name/start-end)A residue number in the whole sequence (not just thatsegment of it in the alignment)
Sequence names
Methods to manipulate the display name. The default name based on the sequence id and subsequence positions can be overridden in various ways.
displayname
Title : displaynameUsage : $myalign->displayname("Ig", "IgA")Function : Gets/sets the display name of a sequence in the alignment:Returns : A display name stringArgument : name of the sequencedisplayname of the sequence (optional)
set_displayname_count
Title : set_displayname_countUsage : $ali->set_displayname_countFunction :Sets the names to be name_# where # is the number oftimes this name has been used.Returns : NoneArgument : None
set_displayname_flat
Title : set_displayname_flatUsage : $ali->set_displayname_flat()Function : Makes all the sequences be displayed as just their name,not name/start-endReturns : 1Argument : None
set_displayname_normal
Title : set_displayname_normalUsage : $ali->set_displayname_normal()Function : Makes all the sequences be displayed as name/start-endReturns : NoneArgument : None