| Summary | Included libraries | Package variables | Description | General documentation | Methods |
=========================================================
Name | Referenced sequence
---------------------------------------------------------
"gapped consensus" | Contig (with gaps)
"ungapped consensus" | Contig (without gaps)
"aligned $seqID" | sequence $seqID (with gaps)
"unaligned $seqID" | sequence $seqID (without gaps)
=========================================================
"gapped consensus" refers to positions in the aligned consensus| new | code | next | Top |
Title : new
Usage : my $contig = new Bio::Assembly::Contig();
Function : Creates a new contig object
Returns : Bio::Assembly::Contig
Args : -source => string representing the source
program where this contig came
from
-id => contig unique ID |
| source | code | prev | next | Top |
Title : source Usage : $contig->source($program); Function : Get/Set program used to build this contig Returns : string Argument : [optional] string |
| assembly | code | prev | next | Top |
Title : assembly Usage : $contig->assembly($assembly); Function : Get/Set assembly object for this contig Returns : a Bio::Assembly::Scaffold object Argument : a Bio::Assembly::Scaffold object |
| strand | code | prev | next | Top |
Title : strand
Usage : $contig->strand($num);
Function : Get/Set contig orientation in a scaffold/assembly.
Its equivalent to the strand property of sequence
objects and sets whether the contig consensus should
be reversed and complemented before being added to a
scaffold or assembly.
Returns : integer
Argument : 1 if orientaion is forward, -1 if reverse and
0 if none |
| upstream_neighbor | code | prev | next | Top |
Title : upstream_neighbor
Usage : $contig->upstream_neighbor($contig);
Function : Get/Set a contig neighbor for the current contig when
building a scaffold. The upstream neighbor is
located before $contig first base
Returns : nothing
Argument : Bio::Assembly::Contig |
| downstream_neighbor | code | prev | next | Top |
Title : downstream_neighbor
Usage : $contig->downstream_neighbor($num);
Function : Get/Set a contig neighbor for the current contig when
building a scaffold. The downstream neighbor is
located after $contig last base
Returns : nothing
Argument : Bio::Assembly::Contig |
| add_features | code | prev | next | Top |
Title : add_features
Usage : $contig->add_features($feat,$flag)
Function :
Add an array of features to the contig feature
collection. The consensus sequence may be attached to the
added feature, if $flag is set to 1. If $flag is 0 and
the feature attached to one of the contig aligned
sequences, the feature is registered as an aligned
sequence feature. If $flag is 0 and the feature is not
attched to any sequence in the contig, the feature is
simply added to the feature collection and no attachment
or registration is made.
Note: You must attach aligned sequences to their features
prior to calling add_features, otherwise you won't be
able to access the feature through get_seq_feat_by_tag()
method.
Returns : number of features added.
Argument :
$feat : A reference to an array of Bio::SeqFeatureI
$flag : boolean - true if consensus sequence object
should be attached to this feature, false if
no consensus attachment should be made.
Default: false. |
| remove_features | code | prev | next | Top |
Title : remove_features Usage : $contig->remove_features(@feat) Function : Remove an array of contig features Returns : number of features removed. Argument : An array of Bio::SeqFeatureI |
| get_features_collection | code | prev | next | Top |
Title : get_features_collection Usage : $contig->get_features_collection() Function : Get the collection of all contig features Returns : Bio::SeqFeature::Collection Argument : none |
| change_coord | code | prev | next | Top |
Title : change_coord
Usage : $contig->change_coord($in,$out,$query)
Function :
Change coordinate system for $query. This method
transforms locations between coordinate systems described
in section "Coordinate Systems" of this document.
Note: this method will throw an exception when changing
coordinates between "ungapped consensus" and other
systems if consensus sequence was not set. It will also
throw exceptions when changing coordinates among aligned
sequence, either with or without gaps, and other systems
if sequence locations were not set with set_seq_coord().
Returns : integer
Argument :
$in : [string] input coordinate system
$out : [string] output coordinate system
$query : [integer] a position in a sequence |
| get_seq_coord | code | prev | next | Top |
Title : get_seq_coord
Usage : $contig->get_seq_coord($seq);
Function : Get "gapped consensus" location for aligned sequence
Returns : Bio::SeqFeature::Generic for coordinates or undef.
A warning is printed if sequence coordinates were not set.
Argument : Bio::LocatabaleSeq object |
| set_seq_coord | code | prev | next | Top |
Title : set_seq_coord
Usage : $contig->set_seq_coord($feat,$seq);
Function :
Set "gapped consensus" location for an aligned
sequence. If the sequence was previously added using
add_seq, its coordinates are changed/set. Otherwise,
add_seq is called and the sequence is added to the
contig.
Returns : Bio::SeqFeature::Generic for old coordinates or undef.
Argument :
$feat : a Bio::SeqFeature::Generic object
representing a location for the
aligned sequence, in "gapped
consensus" coordinates.
Note: the original feature primary tag will
be lost.
$seq : a Bio::LocatabaleSeq object |
| set_consensus_sequence | code | prev | next | Top |
Title : set_consensus_sequence Usage : $contig->set_consensus_sequence($seq) Function : Set the consensus sequence object for this contig Returns : consensus length Argument : Bio::LocatableSeq |
| set_consensus_quality | code | prev | next | Top |
Title : set_consensus_quality Usage : $contig->set_consensus_quality($qual) Function : Set the quality object for consensus sequence Returns : nothing Argument : Bio::Seq::QualI object |
| get_consensus_length | code | prev | next | Top |
Title : get_consensus_length Usage : $contig->get_consensus_length() Function : Get consensus sequence length Returns : integer Argument : none |
| get_consensus_sequence | code | prev | next | Top |
Title : get_consensus_sequence
Usage : $contig->get_consensus_sequence()
Function : Get a reference to the consensus sequence object
for this contig
Returns : Bio::SeqI object
Argument : none |
| get_consensus_quality | code | prev | next | Top |
Title : get_consensus_quality
Usage : $contig->get_consensus_quality()
Function : Get a reference to the consensus quality object
for this contig.
Returns : A Bio::QualI object
Argument : none |
| set_seq_qual | code | prev | next | Top |
Title : set_seq_qual
Usage : $contig->set_seq_qual($seq,$qual);
Function : Adds quality to an aligned sequence.
Returns : nothing
Argument : a Bio::LocatableSeq object and
a Bio::Seq::QualI object
See Bio::LocatableSeq for more information. |
| get_seq_ids | code | prev | next | Top |
Title : get_seq_ids
Usage : $contig->get_seq_ids(-start=>$start,
-end=>$end,
-type=>"gapped A0QR67B08.b");
Function : Get list of sequence IDs overlapping inteval [$start, $end]
The default interval is [1,$contig->length]
Default coordinate system is "gapped contig"
Returns : An array
Argument : A hash with optional elements:
-start : consensus subsequence start
-end : consensus subsequence end
-type : the coordinate system type for $start and $end arguments
Coordinate system avaliable are:
"gapped consensus" : consensus coordinates with gaps
"ungapped consensus" : consensus coordinates without gaps
"aligned $ReadID" : read $ReadID coordinates with gaps
"unaligned $ReadID" : read $ReadID coordinates without gaps |
| get_seq_feat_by_tag | code | prev | next | Top |
Title : get_seq_feat_by_tag
Usage : $seq = $contig->get_seq_feat_by_tag($seq,"_aligned_coord:$seqID")
Function :
Get a sequence feature based on its primary_tag.
When you add
Returns : a Bio::SeqFeature object
Argument : a Bio::LocatableSeq and a string (feature primary tag) |
| get_seq_by_name | code | prev | next | Top |
Title : get_seq_by_name
Usage : $seq = $contig->get_seq_by_name('Seq1')
Function : Gets a sequence based on its id.
Returns : a Bio::LocatableSeq object
undef if name is not found
Argument : string |
| get_qual_by_name | code | prev | next | Top |
Title : get_qual_by_name
Usage : $seq = $contig->get_qual_by_name('Seq1')
Function :
Gets Bio::Seq::QualI object for a sequence
through its id ( as given by $qual->id() ).
Returns : a Bio::Seq::QualI object.
undef if name is not found
Argument : string |
| add_seq | code | prev | next | Top |
Title : add_seq
Usage : $contig->add_seq($newseq);
Function :
Adds a sequence to the contig. *Does*
*not* align it - just adds it to the
hashes.
Returns : nothing
Argument : a Bio::LocatableSeq object
See Bio::LocatableSeq for more information. |
| remove_seq | code | prev | next | Top |
Title : remove_seq Usage : $contig->remove_seq($seq); Function : Removes a single sequence from an alignment Returns : 1 on success, 0 otherwise Argument : a Bio::LocatableSeq object |
| purge | code | prev | next | Top |
Title : purge
Usage : $contig->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 sequences
Argument: |
| sort_alphabetically | code | prev | next | Top |
Title : sort_alphabetically
Usage : $contig->sort_alphabetically
Function :
Changes the order of the alignemnt to alphabetical on name
followed by numerical by number.
Returns :
Argument : |
| each_seq | code | prev | next | Top |
Title : each_seq Usage : foreach $seq ( $contig->each_seq() ) Function : Gets an array of Seq objects from the alignment Returns : an array Argument : |
| each_alphabetically | code | prev | next | Top |
Title : each_alphabetically
Usage : foreach $seq ( $contig->each_alphabetically() )
Function :
Returns an array of sequence object sorted alphabetically
by name and then by start point.
Does not change the order of the alignment
Returns :
Argument : |
| each_seq_with_id | code | prev | next | Top |
Title : each_seq_with_id
Usage : foreach $seq ( $contig->each_seq_with_id() )
Function :
Gets an array of Seq objects from the
alignment, the contents being those sequences
with the given name (there may be more than one)
Returns : an array
Argument : a seq name |
| get_seq_by_pos | code | prev | next | Top |
Title : get_seq_by_pos
Usage : $seq = $contig->get_seq_by_pos(3)
Function :
Gets a sequence based on its position in the alignment.
Numbering starts from 1. Sequence positions larger than
no_sequences() will thow an error.
Returns : a Bio::LocatableSeq object
Argument : positive integer for the sequence osition |
| select | code | prev | next | Top |
Title : select
Usage : $contig2 = $contig->select(1, 3) # three first sequences
Function :
Creates a new alignment from a continuous subset of
sequences. Numbering starts from 1. Sequence positions
larger than no_sequences() will thow an error.
Returns : a Bio::Assembly::Contig object
Argument : positive integer for the first sequence
positive integer for the last sequence to include (optional) |
| select_noncont | code | prev | next | Top |
Title : select_noncont
Usage : $contig2 = $contig->select_noncont(1, 3) # first and 3rd sequences
Function :
Creates a new alignment from a subset of
sequences. Numbering starts from 1. Sequence positions
larger than no_sequences() will thow an error.
Returns : a Bio::Assembly::Contig object
Args : array of integers for the sequences |
| slice | code | prev | next | Top |
Title : slice
Usage : $contig2 = $contig->slice(20, 30)
Function :
Creates a slice from the alignment inclusive of start and
end columns. Sequences with no residues in the slice are
excluded from the new alignment and a warning is printed.
Slice beyond the length of the sequence does not do
padding.
Returns : a Bio::Assembly::Contig object
Argument : positive integer for start column
positive integer for end column |
| map_chars | code | prev | next | Top |
Title : map_chars
Usage : $contig->map_chars('\.','-')
Function :
Does a s/$arg1/$arg2/ on the sequences. Useful for gap
characters
Notice that the from (arg1) is interpretted as a regex,
so be careful about quoting meta characters (eg
$contig->map_chars('.','-') wont do what you want)
Returns :
Argument : 'from' rexexp
'to' string |
| uppercase | code | prev | next | Top |
Title : uppercase() Usage : $contig->uppercase() Function : Sets all the sequences to uppercase Returns : Argument : |
| match_line | code | prev | next | Top |
Title : match_line()
Usage : $contig->match_line()
Function : Generates a match line - much like consensus string
except 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 | code | prev | next | Top |
Title : match()
Usage : $contig->match()
Function :
Goes through all columns and changes residues that are
identical to residue in first sequence to match '.'
character. Sets match_char.
USE WITH CARE: Most MSE formats do not support match
characters in sequences, so this is mostly for output
only. NEXUS format (Bio::AlignIO::nexus) can handle
it.
Returns : 1
Argument : a match character, optional, defaults to '.' |
| unmatch | code | prev | next | Top |
Title : unmatch()
Usage : $contig->unmatch()
Function :
Undoes the effect of method match. Unsets match_char.
Returns : 1
Argument : a match character, optional, defaults to '.' |
| id | code | prev | next | Top |
Title : id
Usage : $contig->id("Ig")
Function : Gets/sets the id field of the alignment
Returns : An id string
Argument : An id string (optional) |
| missing_char | code | prev | next | Top |
Title : missing_char
Usage : $contig->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 | code | prev | next | Top |
Title : match_char
Usage : $contig->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 | code | prev | next | Top |
Title : gap_char
Usage : $contig->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 | code | prev | next | Top |
Title : symbol_chars Usage : my @symbolchars = $contig->symbol_chars; Function: Returns all the seen symbols (other than gaps) Returns : array of characters that are the seen symbols Argument: boolean to include the gap/missing/match characters |
| consensus_string | code | prev | next | Top |
Title : consensus_string
Usage : $str = $contig->consensus_string($threshold_percent)
Function : Makes a strict consensus
Returns :
Argument : Optional treshold 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 | code | prev | next | Top |
Title : consensus_iupac
Usage : $str = $contig->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.
Note that 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.
Returns : consensus string
Argument : none
Throws : on protein sequences |
| is_flush | code | prev | next | Top |
Title : is_flush
Usage : if( $contig->is_flush() )
:
:
Function : Tells you whether the alignment
: is flush, ie all of the same length
:
:
Returns : 1 or 0
Argument : |
| length | code | prev | next | Top |
Title : length()
Usage : $len = $contig->length()
Function : Returns the maximum length of the alignment.
To be sure the alignment is a block, use is_flush
Returns :
Argument : |
| no_residues | code | prev | next | Top |
Title : no_residues Usage : $no = $contig->no_residues Function : number of residues in total in the alignment Returns : integer Argument : |
| no_sequences | code | prev | next | Top |
Title : no_sequences Usage : $depth = $contig->no_sequences Function : number of sequence in the sequence alignment Returns : integer Argument : None |
| percentage_identity | code | prev | next | Top |
Title : percentage_identity Usage : $id = $contig->percentage_identity Function: The function calculates the percentage identity of the alignment Returns : The percentage identity of the alignment (as defined by the implementation) Argument: None |
| overall_percentage_identity | code | prev | next | Top |
Title : percentage_identity
Usage : $id = $contig->percentage_identity
Function: The function calculates the percentage identity of
the conserved columns
Returns : The percentage identity of the conserved columns
Args : None |
| average_percentage_identity | code | prev | next | Top |
Title : average_percentage_identity
Usage : $id = $contig->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 |
| column_from_residue_number | code | prev | next | Top |
Title : column_from_residue_number
Usage : $col = $contig->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.DDEFGHI
column_from_residue_number( "Seq1", 94 ) returns 5.
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 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) |
| displayname | code | prev | next | Top |
Title : displayname
Usage : $contig->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 | code | prev | next | Top |
Title : set_displayname_count
Usage : $contig->set_displayname_count
Function :
Sets the names to be name_# where # is the number of
times this name has been used.
Returns : None
Argument : None |
| set_displayname_flat | code | prev | next | Top |
Title : set_displayname_flat
Usage : $contig->set_displayname_flat()
Function : Makes all the sequences be displayed as just their name,
not name/start-end
Returns : 1
Argument : None |
| set_displayname_normal | code | prev | next | Top |
Title : set_displayname_normal Usage : $contig->set_displayname_normal() Function : Makes all the sequences be displayed as name/start-end Returns : None Argument : None |
| _binary_search | code | prev | next | Top |
Title : _binary_search
Usage : _binary_search($list,$query)
Function :
Find a number in a sorted list of numbers. Return values
may be on or two integers. One positive integer or zero
(>=0) is the index of the element that stores the queried
value. Two positive integers (or zero and another
number) are the indexes of elements among which the
queried value should be placed. Negative single values
mean:
-1: $query is smaller than smallest element in list
-2: $query is greater than greatest element in list
Returns : array of integers
Argument :
$list : array reference
$query : integer |
| _compare | code | prev | next | Top |
Title : _compare
Usage : _compare($arg1,$arg2)
Function: Perform numeric or string comparisons
Returns : integer (0, 1 or -1)
Args : values to be compared |
| _nof_gaps | code | prev | next | Top |
Title : _nof_gaps
Usage : _nof_gaps($array_ref, $query)
Function: number of gaps found before position $query
Returns : integer
Args :
$array_ref : gap registry reference
$query : [integer] a position in a sequence |
| _padded_unpadded | code | prev | next | Top |
Title : _padded_unpadded
Usage : _padded_unpadded($array_ref, $query)
Function:
Returns a coordinate corresponding to
position $query after gaps were
removed from a sequence.
Returns : integer
Args :
$array_ref : reference to this gap registry
$query : [integer] coordionate to change |
| _unpadded_padded | code | prev | next | Top |
Title : _unpadded_padded
Usage : _unpadded_padded($array_ref, $query)
Function:
Returns the value corresponding to
ungapped position $query when gaps are
counted as valid sites in a sequence
Returns :
Args : $array_ref = a reference to this sequence's gap registry
$query = [integer] location to change |
| _register_gaps | code | prev | next | Top |
Title : _register_gaps
Usage : $self->_register_gaps($seq, $array_ref)
Function: stores gap locations for a sequence
Returns : number of gaps found
Args :
$seq : sequence string
$array_ref : a reference to an array,
where gap locations will
be stored |
| new | description | prev | next | Top |
#-----------}
my ($class,@args) = @_; my $self = $class->SUPER::new(@args); my ($src, $id) = $self->_rearrange([qw(SOURCE ID)], @args); $src && $self->source($src); ($id && $self->id($id)) || ($self->{'_id'} = 'NoName'); # Alignment (contig) name
($id && $self->id($id)) || ($self->{'_source'} = 'Unknown'); # Program used to build the contig
# we need to set up internal hashes first!
# Bio::SimpleAlign derived fields (check which ones are needed for AlignI compatibility)
$self->{'_elem'} = {}; # contig elements: aligned sequence objects (keyed by ID)
$self->{'_order'} = {}; # store sequence order
# $self->{'start_end_lists'} = {}; # References to entries in {'_seq'}. Keyed by seq ids.
# $self->{'_dis_name'} = {}; # Display names for each sequence
$self->{'_symbols'} = {}; # List of symbols
#Contig specific slots
$self->{'_consensus_sequence'} = undef; $self->{'_consensus_quality'} = undef; $self->{'_nof_residues'} = 0; $self->{'_nof_seqs'} = 0; # $self->{'_nof_segments'} = 0; # Let's not make it heavier than needed by now...
$self->{'_sfc'} = Bio::SeqFeature::Collection->new(); # Assembly specifcs
$self->{'_assembly'} = undef; # Reference to a Bio::Assembly::Scaffold object, if contig belongs to one.
$self->{'_strand'} = 0; # Reverse (-1) or forward (1), if contig is in a scaffold. 0 otherwise
$self->{'_neighbor_start'} = undef; # Will hold a reference to another contig
$self->{'_neighbor_end'} = undef; # Will hold a reference to another contig
return $self; # success - we hope!
| source | description | prev | next | Top |
my $self = shift; my $source = shift; $self->{'_source'} = $source if (defined $source); return $self->{'_source'};}
| assembly | description | prev | next | Top |
my $self = shift; my $assembly = shift; $self->throw("Using non Bio::Assembly::Scaffold object when assign contig to assembly") if (defined $assembly && ! $assembly->isa("Bio::Assembly::Scaffold")); $self->{'_assembly'} = $assembly if (defined $assembly); return $self->{'_assembly'};}
| strand | description | prev | next | Top |
my $self = shift; my $ori = shift; $self->throw("Contig strand must be either 1, -1 or 0") unless (defined $ori && ($ori == 1 || $ori == 0 || $ori == -1)); $self->{'_strand'} = $ori; return $self->{'_strand'};}
| upstream_neighbor | description | prev | next | Top |
my $self = shift; my $ref = shift; $self->throw("Trying to assign a non Bio::Assembly::Contig object to upstream contig") if (defined $ref && ! $ref->isa("Bio::Assembly::Contig")); $self->{'_neighbor_start'} = $ref if (defined $ref); return $self->{'_neighbor_start'};}
| downstream_neighbor | description | prev | next | Top |
my $self = shift; my $ref = shift; $self->throw("Trying to assign a non Bio::Assembly::Contig object to downstream contig") if (defined $ref && ! $ref->isa("Bio::Assembly::Contig")); $self->{'_neighbor_end'} = $ref if (defined $ref); return $self->{'_neighbor_end'};}
| add_features | description | prev | next | Top |
my ($self, $args, $flag) = @_; # Adding shortcuts for aligned sequence features}
$flag = 0 unless (defined $flag); if ($flag && defined $self->{'_consensus_sequence'}) { foreach my $feat (@$args) { next if (defined $feat->seq); $feat->attach_seq($self->{'_consensus_sequence'}); } } elsif (!$flag) { # Register aligned sequence features
foreach my $feat (@$args) { if (my $seq = $feat->entire_seq()) { my $seqID = $seq->id() || $seq->display_id || $seq->primary_id; $self->warn("Adding contig feature attached to unknown sequence $seqID!") unless (exists $self->{'_elem'}{$seqID}); my $tag = $feat->primary_tag; $self->{'_elem'}{$seqID}{'_feat'}{$tag} = $feat; } } } # Add feature to feature collection
my $nof_added = $self->{'_sfc'}->add_features($args); return $nof_added;
| remove_features | description | prev | next | Top |
my ($self, @args) = @_; # Removing shortcuts for aligned sequence features}
foreach my $feat (@args) { if (my $seq = $feat->entire_seq()) { my $seqID = $seq->id() || $seq->display_id || $seq->primary_id; my $tag = $feat->primary_tag; $tag =~ s/:$seqID$/$1/g; delete( $self->{'_elem'}{$seqID}{'_feat'}{$tag} ) if (exists $self->{'_elem'}{$seqID}{'_feat'}{$tag} && $self->{'_elem'}{$seqID}{'_feat'}{$tag} eq $feat); } } return $self->{'_sfc'}->remove_features(\@args);
| get_features_collection | description | prev | next | Top |
my $self = shift; return $self->{'_sfc'};}
| change_coord | description | prev | next | Top |
my $self = shift; my $type_in = shift; my $type_out = shift; my $query = shift; # Parsing arguments}
# Loading read objects (these calls will throw exceptions whether $read_in or
# $read_out is not found
my ($read_in,$read_out) = (undef,undef); my $in_ID = ( split(' ',$type_in) )[1]; my $out_ID = ( split(' ',$type_out) )[1]; if ($in_ID ne 'consensus') { $read_in = $self->get_seq_coord( $self->get_seq_by_name($in_ID) ); $self->throw("Can't change coordinates without sequence location for $in_ID") unless (defined $read_in); } if ($out_ID ne 'consensus') { $read_out = $self->get_seq_coord( $self->get_seq_by_name($out_ID) ); $self->throw("Can't change coordinates without sequence location for $out_ID") unless (defined $read_out); } # Performing transformation between coordinates
SWITCH1: { # Transformations between contig padded and contig unpadded
(($type_in eq 'gapped consensus') && ($type_out eq 'ungapped consensus')) && do { $self->throw("Can't use ungapped consensus coordinates without a consensus sequence") unless (defined $self->{'_consensus_sequence'}); $query = &_padded_unpadded($self->{'_consensus_gaps'}, $query); last SWITCH1; }; (($type_in eq 'ungapped consensus') && ($type_out eq 'gapped consensus')) && do { $self->throw("Can't use ungapped consensus coordinates without a consensus sequence") unless (defined $self->{'_consensus_sequence'}); $query = &_unpadded_padded($self->{'_consensus_gaps'},$query); last SWITCH1; }; # Transformations between contig (padded) and read (padded)
(($type_in eq 'gapped consensus') && ($type_out =~ /^aligned /) && defined($read_out)) && do { $query = $query - $read_out->start() + 1; last SWITCH1; }; (($type_in =~ /^aligned /) && defined($read_in) && ($type_out eq 'gapped consensus')) && do { $query = $query + $read_in->start() - 1; last SWITCH1; }; # Transformations between contig (unpadded) and read (padded)
(($type_in eq 'ungapped consensus') && ($type_out =~ /^aligned /) && defined($read_out)) && do { $query = $self->change_coord('ungapped consensus','gapped consensus',$query); $query = $self->change_coord('gapped consensus',"aligned $out_ID",$query); last SWITCH1; }; (($type_in =~ /^aligned /) && defined($read_in) && ($type_out eq 'ungapped consensus')) && do { $query = $self->change_coord("aligned $in_ID",'gapped consensus',$query); $query = $self->change_coord('gapped consensus','ungapped consensus',$query); last SWITCH1; }; # Transformations between seq $read_in padded and seq $read_out padded
(defined($read_in) && ($type_in =~ /^aligned /) && defined($read_out) && ($type_out =~ /^aligned /)) && do { $query = $self->change_coord("aligned $in_ID",'gapped consensus',$query); $query = $self->change_coord('gapped consensus',"aligned $out_ID",$query); last SWITCH1; }; # Transformations between seq $read_in padded and seq $read_out unpadded
(defined($read_in) && ($type_in =~ /^aligned /) && defined($read_out) && ($type_out =~ /^unaligned /)) && do { if ($read_in ne $read_out) { $query = $self->change_coord("aligned $in_ID",'gapped consensus',$query); $query = $self->change_coord('gapped consensus',"aligned $out_ID",$query); } my $list_out = $self->{'_elem'}{$out_ID}{'_gaps'}; $query = &_padded_unpadded($list_out,$query); # Changing read orientation if read was reverse complemented when aligned
if ($read_out->strand == -1) { my ($length) = $read_out->length(); $length = $length - &_nof_gaps($list_out,$length); $query = $length - $query + 1; } last SWITCH1; }; (defined($read_in) && ($type_in =~ /^unaligned /) && defined($read_out) && ($type_out =~ /^aligned /)) && do { my $list_in = $self->{'_elem'}{$in_ID}{'_gaps'}; # Changing read orientation if read was reverse complemented when aligned
if ($read_in->strand == -1) { my ($length) = $read_in->length(); $length = $length - &_nof_gaps($list_in,$length); $query = $length - $query + 1; } $query = &_unpadded_padded($list_in,$query); if ($read_in ne $read_out) { $query = $self->change_coord("aligned $in_ID",'gapped consensus',$query); $query = $self->change_coord('gapped consensus',"aligned $out_ID",$query); } last SWITCH1; }; # Transformations between seq $read_in unpadded and seq $read_out unpadded
(defined($read_in) && ($type_in =~ /^unaligned /) && defined($read_out) && ($type_out =~ /^unaligned /)) && do { $query = $self->change_coord("unaligned $in_ID","aligned $out_ID",$query); $query = $self->change_coord("aligned $out_ID","unaligned $out_ID",$query); last SWITCH1; }; # Transformations between contig (padded) and read (unpadded)
(($type_in eq 'gapped consensus') && ($type_out =~ /^unaligned /) && defined($read_out)) && do { $query = $self->change_coord('gapped consensus',"aligned $out_ID",$query); $query = $self->change_coord("aligned $out_ID","unaligned $out_ID",$query); last SWITCH1; }; (($type_in =~ /^unaligned /) && defined($read_in) && ($type_out eq 'gapped consensus')) && do { $query = $self->change_coord("unaligned $in_ID","aligned $in_ID",$query); $query = $self->change_coord("aligned $in_ID",'gapped consensus',$query); last SWITCH1; }; # Transformations between contig (unpadded) and read (unpadded)
(($type_in eq 'ungapped consensus') && ($type_out =~ /^unaligned /) && defined($read_out)) && do { $query = $self->change_coord('ungapped consensus','gapped consensus',$query); $query = $self->change_coord('gapped consensus',"unaligned $out_ID",$query); last SWITCH1; }; (($type_in =~ /^unaligned /) && defined($read_in) && ($type_out eq 'ungapped consensus')) && do { $query = $self->change_coord("unaligned $in_ID",'gapped consensus',$query); $query = $self->change_coord('gapped consensus','ungapped consensus',$query); last SWITCH1; }; $self->throw("Unknow coordinate system. Args: $type_in, $type_out."); $query = undef; # If a coordinate systems just requested is unknown
} return $query;
| get_seq_coord | description | prev | next | Top |
my ($self,$seq) = @_; if( !ref $seq || ! $seq->isa('Bio::LocatableSeq') ) { $self->throw("$seq is not a Bio::LocatableSeq"); } my $seqID = $seq->id() || $seq->display_id || $seq->primary_id; unless (exists( $self->{'_elem'}{$seqID} )) { $self->warn("No such sequence ($seqID) in contig ".$self->id); return undef; } unless (exists( $self->{'_elem'}{$seqID}{'_feat'}{"_aligned_coord:$seqID"} )) { $self->warn("Location not set for sequence ($seqID) in contig ".$self->id); return undef; } return $self->{'_elem'}{$seqID}{'_feat'}{"_aligned_coord:$seqID"};}
| set_seq_coord | description | prev | next | Top |
my ($self,$feat,$seq) = @_; if( !ref $seq || ! $seq->isa('Bio::LocatableSeq') ) { $self->throw("Unable to process non locatable sequences [".ref($seq)."]"); } # Complaining about inadequate feature object}
$self->throw("Coordinates must be a Bio::SeqFeature::Generic object!") unless ( $feat->isa("Bio::SeqFeature::Generic") ); $self->throw("Sequence coordinates must have an end!") unless (defined $feat->end); $self->throw("Sequence coordinates must have a start!") unless (defined $feat->start); my $seqID = $seq->id() || $seq->display_id || $seq->primary_id; if (exists( $self->{'_elem'}{$seqID} ) && exists( $self->{'_elem'}{$seqID}{'_seq'} ) && defined( $self->{'_elem'}{$seqID}{'_seq'} ) && ($seq ne $self->{'_elem'}{$seqID}{'_seq'}) ) { $self->warn("Replacing sequence $seqID\n"); $self->remove_seq($self->{'_elem'}{$seqID}{'_seq'}); } $self->add_seq($seq); # Remove previous coordinates, if any
$self->remove_features($feat); # Add new Bio::Generic::SeqFeature
$feat->add_tag_value('contig',$self->id) unless ( $feat->has_tag('contig') ); $feat->primary_tag("_aligned_coord:$seqID"); $feat->attach_seq($seq); $self->{'_elem'}{$seqID}{'_feat'}{"_aligned_coord:$seqID"} = $feat; $self->add_features([ $feat ]);
| set_consensus_sequence | description | prev | next | Top |
my $self = shift; my $seq = shift; $self->throw("Consensus sequence must be a Bio::LocatableSeq!") unless ($seq->isa("Bio::LocatableSeq")); my $con_len = $seq->length; $seq->start(1); $seq->end($con_len); $self->{