Bio::SimpleAlign(3pm)
π Bio::SimpleAlign π
okay bestie, so this is the manual page for Bio::SimpleAlign, from the User Contributed Perl Documentation section (that's the 3pm part, iykyk). Buckle up, because this one is LONG and it's giving main character energy. We're doing it in parts, and this is part one. Let's go β¨
πΈ NAME πΈ
Bio::SimpleAlign β multiple alignments, but held as a set of sequences π§¬
β¨ SYNOPSIS β¨
# Use Bio::AlignIO to read in the alignment
$str = Bio::AlignIO->new(-file => 't/data/testaln.pfam');
$aln = $str->next_aln();
# Describe
print $aln->length;
print $aln->num_residues;
print $aln->is_flush;
print $aln->num_sequences;
print $aln->score;
print $aln->percentage_identity;
print $aln->consensus_string(50);
# 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 $pos
foreach $seq ($aln->each_seq) {
$res = $seq->subseq($pos, $pos);
$count{$res}++;
}
foreach $res (keys %count) {
printf "Res: %s Count: %2d\n", $res, $count{$res};
}
# Manipulate
$aln->remove_seq($seq);
$mini_aln = $aln->slice(20,30); # get a block of columns
$mini_aln = $aln->select_noncont(1,3,5,7,11); # select certain sequences
$new_aln = $aln->remove_columns([20,30]); # remove by position
$new_aln = $aln->remove_columns(['mismatch']); # remove by property
# Analyze
$str = $aln->consensus_string($threshold_percent);
$str = $aln->match_line();
$str = $aln->cigar_line();
$id = $aln->percentage_identity;
# See the module documentation for details and more methods.
like, that's the whole vibe right there π«Ά read the module docs for the full tea and more methods.
π DESCRIPTION π
SimpleAlign is an object that handles a multiple sequence alignment, aka an MSA. And the way that it is so chill about types β it does not insist on sequences all being the same length, for example. No cap. Think of it as a set of sequences with a whole series of built-in manipulations plus methods for reading and writing alignments. Iconic, honestly.
SimpleAlign uses Bio::LocatableSeq, which is a subclass of Bio::PrimarySeq, to store its sequences. These are subsequences with a start and end position in the parent reference sequence. Every single sequence in the SimpleAlign object is a Bio::LocatableSeq. periodt.
SimpleAlign expects the combination of name, start, and end for a given sequence to be unique in the alignment, and that's the key for the internal hashes (name, start, end get abbreviated to nse in the code). But lowkey, sometimes people don't want the name/start-end to be displayed at all: either because there are multiple names in an alignment, or because the names are specific to the alignment (ROA1_HUMAN_1, ROA1_HUMAN_2 etc). These names are called displayname, and generally that's what gets used to print out the alignment. They default to name/start-end.
The SimpleAlign Module is derived from the Align module by Ewan Birney. π
π¬ 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. fr fr, they want to hear from you π₯Ή
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
π«Ά Support π«Ά
Please 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. (yes, "reponsive" is exactly what the original says, we don't fix typos here, we honor them π)
π 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:
https://github.com/bioperl/bioperl-live/issues
π AUTHOR π
Ewan Birney, birney@ebi.ac.uk
π CONTRIBUTORS π
Allen Day, allenday-at-ucla.edu, Richard Adams, Richard.Adams-at-ed.ac.uk, David J. Evans, David.Evans-at-vir.gla.ac.uk, Heikki Lehvaslaiho, heikki-at-bioperl-dot-org, Allen Smith, allens-at-cpan.org, Jason Stajich, jason-at-bioperl.org, Anthony Underwood, aunderwood-at-phls.org.uk, Xintao Wei & Giri Narasimhan, giri-at-cs.fiu.edu Brian Osborne, bosborne at alum.mit.edu Weigang Qiu, Weigang at GENECTR-HUNTER-CUNY-EDU Hongyu Zhang, forward at hongyu.org Jay Hannah, jay at jays.net Alexandr Bezginov, albezg at gmail.com
π SEE ALSO π
Bio::LocatableSeq
π APPENDIX π
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ (you know, the sneaky lil underscore, iykyk).
π new π
Title : new
Usage : my $aln = Bio::SimpleAlign->new();
Function : Creates a new simple align object
Returns : Bio::SimpleAlign
Args : -source => string representing the source program
where this alignment came from
-annotation => Bio::AnnotationCollectionI
-seq_annotation => Bio::AnnotationCollectionI for sequences (requires -annotation also be set)
-seqs => array ref containing Bio::LocatableSeq or Bio::Seq::Meta
-consensus => consensus string
-consensus_meta => Bio::Seq::Meta object containing consensus met information (kludge)
bestie, note that -seq_annotation requires -annotation to also be set. and yes, they really call that last one a kludge π
π οΈ Modifier methods π οΈ
These methods modify the MSA by adding, removing or shuffling complete sequences. chaos but make it organized π
β add_seq β
Title : add_seq
Usage : $myalign->add_seq($newseq);
$myalign->add_seq(-SEQ=>$newseq, -ORDER=>5);
Function : Adds another sequence to the alignment. *Does not* align
it - just adds it to the hashes.
If -ORDER is specified, the sequence is inserted at the
the position spec'd by -ORDER, and existing sequences
are pushed down the storage array.
Returns : nothing
Args : A Bio::LocatableSeq object
Positive integer for the sequence position (optional)
β οΈ heads up: it does not align your sequence. it just adds it to the hashes. no aligning happening here, that's on you π«
See Bio::LocatableSeq for more information.
β remove_seq β
Title : remove_seq
Usage : $aln->remove_seq($seq);
Function : Removes a single sequence from an alignment
Returns :
Argument : a Bio::LocatableSeq object
π§Ή purge π§Ή
Title : purge
Usage : $aln->purge(0.7);
Function: Removes sequences above given sequence similarity
This function will grind on large alignments. Beware!
Example :
Returns : An array of the removed sequences
Args : float, threshold for similarity
π¨ beware bestie β this function will grind on large alignments. it's giving slow. plan accordingly π
π€ sort_alphabetically π€
Title : sort_alphabetically
Usage : $ali->sort_alphabetically
Function : Changes the order of the alignment to alphabetical on name
followed by numerical by number.
Returns :
Argument :
π sort_by_list π
Title : sort_by_list
Usage : $aln_ordered=$aln->sort_by_list($list_file)
Function : Arbitrarily order sequences in an alignment
Returns : A new Bio::SimpleAlign object
Argument : a file listing sequence names in intended order (one name per line)
π set_new_reference π
Title : set_new_reference
Usage : $aln->set_new_reference(3 or 'B31'): Select the 3rd sequence, or
the sequence whoes name is "B31" (full, exact, and case-sensitive),
as the reference (1st) sequence
Function : Change/Set a new reference (i.e., the first) sequence
Returns : a new Bio::SimpleAlign object.
Throws an exception if designated sequence not found
Argument : a positive integer of sequence order, or a sequence name
in the original alignment
π important: the name match is full, exact, and case-sensitive. no fuzzy matching, no lowercase rescue. and if it can't find your sequence? exception. thrown. bye.
π¦ uniq_seq π¦
Title : uniq_seq
Usage : $aln->uniq_seq(): Remove identical sequences in
in the alignment. Ambiguous base ("N", "n") and
leading and ending gaps ("-") are NOT counted as
differences.
Function : Make a new alignment of unique sequence types (STs)
Returns : 1a. if called in a scalar context,
a new Bio::SimpleAlign object (all sequences renamed as "ST")
1b. if called in an array context,
a new Bio::SimpleAlign object, and a hashref whose keys
are sequence types, and whose values are arrayrefs to
lists of sequence ids within the corresponding sequence type
2. if $aln->verbose > 0, ST of each sequence is sent to
STDERR (in a tabular format)
Argument : None
okay so this one is kinda the moment π β ambiguous bases ("N", "n") and leading/ending gaps ("-") are NOT counted as differences, so it won't be dramatic about them. and the return value literally changes based on context: scalar context gets you a shiny new Bio::SimpleAlign object with everything renamed as "ST", array context gets you that plus a hashref mapping sequence types to arrayrefs of sequence ids. and if $aln->verbose > 0? every sequence's ST gets dumped to STDERR in a tabular format. multi-purpose king π
part 1 done, bestie β more coming, don't go anywhere π
π¦ Sequence selection methods π¦
Bestie, these are the ones that hand you back sequence objects β one at a time, or in a cute little alphabetized parade, or by name, or by position. Pick your fighter. π
β¨ each_seq β¨
- Title β
each_seq - Usage β
foreach $seq ( $align->each_seq() ) - Function β hands you a Seq object pulled straight out of the alignment
- Returns β a Seq object
- Argument β (nothing, she's low maintenance)
πΈ each_alphabetically πΈ
- Title β
each_alphabetically - Usage β
foreach $seq ( $ali->each_alphabetically() ) - Function β gives you back a sequence object, but the objects come out in alphabetically sorted order. And no, she does not change the order of the alignment itself β the alignment stays exactly as it was, no cap.
- Returns β a Seq object
- Argument β (nada)
π each_seq_with_id π
- Title β
each_seq_with_id - Usage β
foreach $seq ( $align->each_seq_with_id() ) - Function β grabs Seq objects from the alignment, and the contents are those sequences that match the given name. Heads up bestie: there may be more than one π
- Returns β a Seq object
- Argument β a seq name
π get_seq_by_pos π
- Title β
get_seq_by_pos - Usage β
$seq = $aln->get_seq_by_pos(3) # third sequence from the alignment - Function β gets a sequence based on where it sits in the alignment. Numbering starts from
1. And if you ask for a position larger thannum_sequences()? Yeah, that throws an error. Don't do that. π - Returns β a
Bio::LocatableSeqobject - Args β a positive integer for the sequence position
π«Ά get_seq_by_id π«Ά
- Title β
get_seq_by_id - Usage β
$seq = $aln->get_seq_by_id($name) # seq named $name - Function β gets a sequence based on its name. If the sequence doesn't exist, she'll
warnand hand you backundefβ no drama, just a gentle heads up. - Returns β a
Bio::LocatableSeqobject - Args β a string for the sequence name
π₯ seq_with_features π₯
- Title β
seq_with_features - Usage β
$seq = $aln->seq_with_features(-pos => 1,
-consensus => 60
-mask =>
sub { my $consensus = shift;
for my $i (1..5){
my $n = 'N' x $i;
my $q = '\?' x $i;
while($consensus =~ /[^?]$q[^?]/){
$consensus =~ s/([^?])$q([^?])/$1$n$2/;
}
}
return $consensus;
}
);
- Function β produces a
Bio::Seqobject by first splicing gaps from-pos(which it does via asplice_by_seq_pos()call), then building features out of the non-?chars (via aconsensus_string()call, using the stringency from-consensus). - Returns β a
Bio::Seqobject - Args β
-posβ required. the sequence you're building theBio::Seqobject from-consensusβ optional, defaults toconsensus_string()'s own default cutoff value-maskβ optional, a coderef that gets applied toconsensus_string()'s output before the features get built. this is genuinely useful for closing gaps of 1 bp by masking over them withN, for instance. iconic behavior honestly β¨
π Create new alignments π
The result of these methods are horizontal or vertical subsets of the current MSA. Basically: cropping, but make it fashion. π¦
π select π
- Title β
select - Usage β
$aln2 = $aln->select(1, 3) # three first sequences - Function β creates a brand new alignment from a continuous subset of sequences. Numbering starts from
1. Sequence positions larger thannum_sequences()will throw an error. - Returns β a
Bio::SimpleAlignobject - Args β
- positive integer for the first sequence
- positive integer for the last sequence to include (optional)
π select_noncont π
- Title β
select_noncont - Usage β
# 1st and 3rd sequences, sorted
$aln2 = $aln->select_noncont(1, 3)
# 1st and 3rd sequences, sorted (same as first)
$aln2 = $aln->select_noncont(3, 1)
# 1st and 3rd sequences, unsorted
$aln2 = $aln->select_noncont('nosort',3, 1)
- Function β creates a new alignment from a subset of sequences. Numbering starts from
1. Sequence positions larger thannum_sequences()will throw an error. By default it sorts the order things get added to the new alignment β so if you wanna stop that from happening, pass'nosort'as the first argument in the list. - Returns β a
Bio::SimpleAlignobject - Args β an array of integers for the sequences. If the string
'nosort'is passed as the first argument, the sequences will not be sorted in the new alignment, and instead will appear in the order you listed them. periodt.
π§ select_noncont_by_name π§
- Title β
select_noncont_by_name - Usage β
my $aln2 = $aln->select_noncont_by_name('A123', 'B456'); - Function β creates a new alignment from a subset of sequences that are selected by name (sequence ID).
- Returns β a
Bio::SimpleAlignobject - Args β an array of names (i.e., identifiers) for the sequences.
πΈ slice πΈ
- Title β
slice - Usage β
$aln2 = $aln->slice(20,30) - Function β creates a slice from the alignment, inclusive of start and end columns, and the first column in the alignment is denoted
1. Sequences with no residues in the slice get excluded from the new alignment and a warning is printed. And ngl, slicing beyond the length of the sequence does not do padding β so don't expect her to stretch. π - Returns β a
Bio::SimpleAlignobject - Args β positive integer for start column, positive integer for end column, optional boolean which if true will keep gap-only columns in the newly created slice. Example:
$aln2 = $aln->slice(20,30,1)
π remove_columns π
- Title β
remove_columns - Usage β
$aln2 = $aln->remove_columns(['mismatch','weak']) or
$aln2 = $aln->remove_columns([0,0],[6,8])
- Function β creates an alignment with columns removed, either corresponding to the specified type or by specifying the columns by number.
- Returns β a
Bio::SimpleAlignobject - Args β array ref of types (
'match'|'weak'|'strong'|'mismatch'|'gaps'|'all_gaps_columns') or an array ref where the referenced array contains a pair of integers that specify a range. And remember bestie: the first column is0. π
π remove_gaps π
- Title β
remove_gaps - Usage β
$aln2 = $aln->remove_gaps - Function β creates an alignment with gaps removed
- Returns β a
Bio::SimpleAlignobject - Args β
- a gap character (optional) β if none specified, it's taken from
$self->gap_char, - (optional)
$all_gaps_columnsflag (1 or 0, default is0) β indicates that only all-gaps columns should be deleted
- a gap character (optional) β if none specified, it's taken from
Mostly used from the method remove_columns. Set the gap character using gap_char().
π¦ Change sequences within the MSA π¦
These methods affect characters in all sequences without changing the alignment. So the vibe shifts, but the shape stays. π
β splice_by_seq_pos β
- Title β
splice_by_seq_pos - Usage β
$status = splice_by_seq_pos(1); - Function β splices all aligned sequences where the specified sequence has gaps.
- Example β
- Returns β
1on success - Args β position of sequence to splice by
π₯ map_chars π₯
- Title β
map_chars - Usage β
$ali->map_chars('\.','-') - Function β does a
s/$arg1/$arg2/on the sequences. Super useful for gap characters.
Careful bestie! Note that the first argument is interpreted as a regexp, so be careful and escape any wild card characters (e.g. do $ali->map_chars('\.','-') to replace periods with dashes).
- Returns β
1on success - Argument β a regexp and a string
π«Ά uppercase π«Ά
- Title β
uppercase() - Usage β
$ali->uppercase() - Function β sets all the sequences to UPPERCASE. Yelling, but in a cute way.
- Returns β
1on success - Argument β (none)
π cigar_line π
- Title β
cigar_line() - Usage β
%cigars = $align->cigar_line() - Function β generates a "cigar" (Compact Idiosyncratic Gapped Alignment Report) line for each sequence in the alignment. Examples are
"1,60"or"5,10:12,58", where the numbers refer to conserved positions within the alignment. The keys of the hash are the NSEs (name/start/end) assigned to each sequence. iykyk β¨ - Args β threshold (optional, defaults to
100) - Returns β Hash of strings (cigar lines)
π match_line π
- Title β
match_line() - Usage β
$line = $align->match_line() - Function β generates a match line β much like a consensus string, except that it's a line indicating the
'*'for a match. - Args β
- (optional) Match line characters (
'*'by default) - (optional) Strong match char (
':'by default) - (optional) Weak match char (
'.'by default)
- (optional) Match line characters (
- Returns β String
πΈ gap_line πΈ
- Title β
gap_line() - Usage β
$line = $align->gap_line() - Function β generates a gap line β much like a consensus string, except that it's a line where
'-'represents a gap. - Args β (optional) gap line characters (
'-'by default) - Returns β string
π§ all_gap_line π§
- Title β
all_gap_line() - Usage β
$line = $align->all_gap_line() - Function β generates a gap line β much like a consensus string, except that it's a line where
'-'represents an all-gap column. - Args β (optional) gap line characters (
'-'by default) - Returns β string
π gap_col_matrix π
- Title β
gap_col_matrix() - Usage β
my $cols = $align->gap_col_matrix() - Function β generates an array where each element in the array is a hash reference with a key of the sequence name and a value of
1if the sequence has a gap at that column. - Returns β Reference to an array
- Args β Optional: gap line character (
$aln->gap_charor'-'by default)
π match π
- Title β
match() - Usage β
$ali->match() - Function β goes through all columns and changes residues that are identical to the residue in the first sequence to the match
'.'character. Setsmatch_char.
USE WITH CARE: Most MSA formats do not support match characters in sequences, so this is mostly for output only. NEXUS format (Bio::AlignIO::nexus) can handle it. So like, know before you go, bestie. π
- Returns β
1on success - Argument β a match character, optional, defaults to
'.'
π unmatch π
- Title β
unmatch() - Usage β
$ali->unmatch() - Function β undoes the effect of method
match. Unsetsmatch_char. - Returns β
1on success - Argument β a match character, optional, defaults to
'.'
See match and match_char.
β¨ MSA attributes β¨
okay bestie, these are the methods for setting and reading the MSA attributes. π
Note: the methods defining character semantics depend on you to set them sensibly. They are needed only by certain input/output methods. Unset them by setting to an empty string (''). no cap.
id
- Title:
id - Usage:
$myalign->id("Ig") - Function: Gets/sets the id field of the alignment
- Returns: An id string
- Argument: An id string (optional)
accession
- Title:
accession - Usage:
$myalign->accession("PF00244") - Function: Gets/sets the accession field of the alignment
- Returns: An acc string
- Argument: An acc string (optional)
description
- Title:
description - Usage:
$myalign->description("14-3-3 proteins") - Function: Gets/sets the description field of the alignment
- Returns: An description string
- Argument: An description string (optional)
missing_char
- Title:
missing_char - Usage:
$myalign->missing_char("?") - Function: Gets/sets the missing_char attribute of the alignment. It 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_char - Usage:
$myalign->match_char('.') - Function: Gets/sets the match_char attribute of the alignment
- Returns: An match_char string,
- Argument: An match_char string (optional)
gap_char
- Title:
gap_char - Usage:
$myalign->gap_char('-') - Function: Gets/sets the gap_char attribute of the alignment
- Returns: An gap_char string, defaults to '-'
- Argument: An gap_char string (optional)
symbol_chars
- Title:
symbol_chars - Usage:
my @symbolchars = $aln->symbol_chars; - Function: Returns all the seen symbols (other than gaps)
- Returns: array of characters that are the seen symbols
- Args: boolean to include the gap/missing/match characters
Alignment descriptors
These read only methods describe the MSA in various ways. π
score
- Title:
score - Usage:
$str = $ali->score() - Function: get/set a score of the alignment
- Returns: a score for the alignment
- Argument: an optional score to set
consensus_string
- Title:
consensus_string - Usage:
$str = $ali->consensus_string($threshold_percent) - Function: Makes a strict consensus
- Returns: Consensus string
- Argument: 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_conservation
- Title:
consensus_conservation - Usage:
@conservation = $ali->consensus_conservation(); - Function: Conservation (as a percent) of each position of alignment
- Returns: Array of percentages [0-100]. Gap columns are 0% conserved.
- Argument: (none)
consensus_iupac
- Title:
consensus_iupac - Usage:
$str = $ali->consensus_iupac() - Function: Makes a consensus using IUPAC ambiguity codes from DNA and RNA. The output is in upper case except when gaps in a column force output to be in lower case.
- Returns: consensus string
- Argument: none
- Throws: on protein sequences
Note: if your alignment sequences contain a lot of IUPAC ambiquity codes you often have to manually set alphabet. Bio::PrimarySeq::_guess_type thinks they indicate a protein sequence.
consensus_meta
- Title:
consensus_meta - Usage:
$seqmeta = $ali->consensus_meta() - Function: Returns a Bio::Seq::Meta object containing the consensus strings derived from meta data analysis.
- Returns:
Bio::Seq::Meta - Argument:
Bio::Seq::Meta - Throws: non-MetaI object
is_flush
- Title:
is_flush - Usage:
if ( $ali->is_flush() ) - Function: Tells you whether the alignment is flush, i.e. all of the same length
- Returns: 1 or 0
- Argument: (none)
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_flush - Returns: Integer
- Argument: (none)
maxdisplayname_length
- Title:
maxdisplayname_length - Usage:
$ali->maxdisplayname_length() - Function: Gets the maximum length of the displayname in the alignment. Used in writing out various MSA formats.
- Returns: integer
- Argument: (none)
max_metaname_length
- Title:
max_metaname_length - Usage:
$ali->max_metaname_length() - Function: Gets the maximum length of the meta name tags in the alignment for the sequences and for the alignment. Used in writing out various MSA formats.
- Returns: integer
- Argument: None
num_residues
- Title:
num_residues - Usage:
$no = $ali->num_residues - Function: number of residues in total in the alignment
- Returns: integer
- Argument: (none)
- Note: replaces
no_residues()
num_sequences
- Title:
num_sequences - Usage:
$depth = $ali->num_sequences - Function: number of sequence in the sequence alignment
- Returns: integer
- Argument: none
- Note: replaces
no_sequences()
average_percentage_identity
- Title:
average_percentage_identity - Usage:
$id = $align->average_percentage_identity - Function: The function uses a fast method to calculate the average percentage identity of the alignment
- Returns: The average percentage identity of the alignment
- Args: None
- Notes: This method implemented by Kevin Howe calculates a figure that is designed to be similar to the average pairwise identity of the alignment (identical in the absence of gaps), without having to explicitly calculate pairwise identities proposed by Richard Durbin. Validated by Ewan Birney ad Alex Bateman.
percentage_identity
- Title:
percentage_identity - Usage:
$id = $align->percentage_identity - Function: The function calculates the average percentage identity (aliased to
average_percentage_identity) - Returns: The average percentage identity
- Args: None
overall_percentage_identity
Title: overall_percentage_identity
Usage:
$id = $align->overall_percentage_identity
$id = $align->overall_percentage_identity('short')
Function: The function calculates the percentage identity of the conserved columns
Returns: The percentage identity of the conserved columns
Args: length value to use, optional defaults to alignment length. possible values: 'align', 'short', 'long'
The argument values 'short' and 'long' refer to shortest and longest sequence in the alignment. Method modification code by Hongyu Zhang.
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 object
my $loc = $seq->location_from_column(5);
column_from_residue_number
Title: column_from_residue_number
Usage: $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 the sequence with the given name. For example, for the alignment
Seq1/91-97 AC..DEF.GH.
Seq2/24-30 ACGG.RTY...
Seq3/43-51 AC.DDEF.GHI
column_from_residue_number( "Seq1", 94 ) returns 6. column_from_residue_number( "Seq2", 25 ) returns 2. column_from_residue_number( "Seq3", 50 ) returns 10.
An exception is thrown if the residue number would lie outside the length of the aligment (e.g. column_from_residue_number( "Seq2", 22 )
Note: If the the parent sequence is represented by more than one alignment sequence and the residue number is present in them, this method finds only the first one.
Returns: A column number for the position in the alignment of the given 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 that segment of it in the alignment)
π Sequence names π
okay so these methods are all about the display name, bestie. The default name is based on the sequence id and subsequence positions, but you can override that in various ways. iconic, honestly. β¨
displayname
- Title β
displayname - Usage β
$myalign->displayname("Ig", "IgA") - Function β Gets/sets the display name of a sequence in the alignment
- Returns β A display name string
- Argument β
- name of the sequence
- displayname of the sequence (optional)
set_displayname_count
- Title β
set_displayname_count - Usage β
$ali->set_displayname_count - Function β Sets the names to be
name_#where#is the number of times this name has been used. - Returns β
1, on success - Argument β (none)
set_displayname_flat
- Title β
set_displayname_flat - Usage β
$ali->set_displayname_flat() - Function β Makes all the sequences be displayed as just their name, not
name/start-end(NSE) - Returns β
1 - Argument β (none)
set_displayname_normal
- Title β
set_displayname_normal - Usage β
$ali->set_displayname_normal() - Function β Makes all the sequences be displayed as
name/start-end(NSE) - Returns β
1, on success - Argument β (none)
source
- Title β
source - Usage β
$obj->source($newval) - Function β sets the Alignment source program
- Example β (none)
- Returns β value of
source - Args β
newvalue(optional)
set_displayname_safe
- Title β
set_displayname_safe - Usage β
($new_aln, $ref_name)=$ali->set_displayname_safe(4) - Function β Assign machine-generated serial names to sequences in input order. Designed to protect names during PHYLIP runs. Assign 10-char string in the form of
"S000000001"to"S999999999". Restore the original names using"restore_displayname". - Returns β
- a new
$alnwith system names; - a hash ref for restoring names
- a new
- Argument β Number for id length (default
10)
restore_displayname
- Title β
restore_displayname - Usage β
$aln_name_restored=$ali->restore_displayname($hash_ref) - Function β Restore original sequence names (after running
$ali->set_displayname_safe) - Returns β a new
$alnwith names restored. - Argument β a hash reference of names from
"set_displayname_safe".
sort_by_start
- Title β
sort_by_start - Usage β
$ali->sort_by_start - Function β Changes the order of the alignment to the start position of each subalignment
- Returns β
1on success - Argument β (none)
bracket_string
- Title β
bracket_string - Usage β
my @params = (-refseq => 'testseq',
-allele1 => 'allele1',
-allele2 => 'allele2',
-delimiters => '{}',
-separator => '/');
$str = $aln->bracket_string(@params)
- Function β When supplied with a list of parameters (see below), returns a string in BIC format. This is used for allelic comparisons. Briefly, if either allele contains a base change when compared to the refseq, the base or gap for each allele is represented in brackets in the order present in the
'alleles'parameter.
For the following data:
>testseq
GGATCCATTGCTACT
>allele1
GGATCCATTCCTACT
>allele2
GGAT--ATTCCTCCT
the returned string with parameters 'refseq => testseq' and 'alleles => [qw(allele1 allele2)]' would be:
GGAT[C/-][C/-]ATT[C/C]CT[A/C]CT
- Returns β BIC-formatted string
- Argument β
- Required args
refseqβ string (ID) of the reference sequence used as basis for comparisonallele1β string (ID) of the first alleleallele2β string (ID) of the second allele
- Optional args
delimitersβ two symbol string of left and right delimiters. Only the first two symbols are used. default ='[]'separatorβ string used as a separator. Only the first symbol is used. default ='/'
- Required args
- Throws β On no refseq/alleles, or invalid refseq/alleles.
𧬠methods implementing Bio::FeatureHolderI π§¬
FeatureHolderI implementation to support labeled character sets like one would get from NEXUS represented data. no cap. π«Ά
get_SeqFeatures
- Usage β
@features = $aln->get_SeqFeatures - Function β Get the feature objects held by this feature holder.
- Example β (none)
- Returns β an array of
Bio::SeqFeatureIimplementing objects - Args β optional filter coderef, taking a
Bio::SeqFeatureIas argument, returning TRUE if wanted, FALSE if unwanted
add_SeqFeature
- Usage β
$aln->add_SeqFeature($subfeat); - Function β Adds a
SeqFeatureinto theSeqFeaturearray. The'EXPAND'qualifier (seeBio::FeatureHolderI) is supported, but has no effect. - Example β (none)
- Returns β
1on success - Args β a
Bio::SeqFeatureIobject
remove_SeqFeatures
- Usage β
$obj->remove_SeqFeatures - Function β Removes all
SeqFeatures. If you want to remove only a subset, remove that subset from the returned array, and add back the rest. - Returns β The array of
Bio::SeqFeatureIfeatures that was deleted from this alignment. - Args β none
feature_count
- Title β
feature_count - Usage β
$obj->feature_count() - Function β Return the number of
SeqFeaturesattached to the alignment - Returns β integer representing the number of
SeqFeatures - Args β None
get_all_SeqFeatures
- Title β
get_all_SeqFeatures - Usage β (none)
- Function β Get all
SeqFeatures. - Example β (none)
- Returns β an array of
Bio::SeqFeatureIimplementing objects - Args β none
- Note β Falls through to
Bio::FeatureHolderIimplementation.
π¦ methods for Bio::AnnotatableI π¦
AnnotatableI implementation to support sequence alignments which contain annotation (NEXUS, Stockholm). the way that just makes sense π
annotation
- Title β
annotation - Usage β
$ann = $aln->annotationor$aln->annotation($ann) - Function β Gets or sets the annotation
- Returns β
Bio::AnnotationCollectionIobject - Args β None or
Bio::AnnotationCollectionIobject
See Bio::AnnotationCollectionI and Bio::Annotation::Collection for more information. π
π Deprecated methods π
ngl, this one's giving legacy energy. still here, still documented. π
mask_columns
- Title β
mask_columns - Usage β
$aln2 = $aln->mask_columns(20,30) - Function β Masks a slice of the alignment inclusive of start and end columns, and the first column in the alignment is denoted
1. Mask beyond the length of the sequence does not do padding. - Returns β A
Bio::SimpleAlignobject - Args β Positive integer for start column, positive integer for end column, optional string value use for the mask. Example:
$aln2 = $aln->mask_columns(20,30,'?')
- Note β Masking must use a character that is not used for gaps or frameshifts. These can be adjusted using the relevant global variables, but be aware these may be (uncontrollably) modified elsewhere within BioPerl (see bug 2715)
π and that's the whole Bio::SimpleAlign(3pm) page, bestie. This one's from perl v5.32.1, dated 2021-08-15. go off, and may your alignments always be slay. periodt. β¨
π¦ where this page comes from
- debian bookworm: libbio-perl-perl 1.7.8-1 Β· Perl
- debian trixie: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu jammy: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu noble: libbio-perl-perl 1.7.8-1 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms