BioPerl
view release on metacpan or search on metacpan
Bio/Assembly/Contig.pm view on Meta::CPAN
sequences, and the method set_seq_coord() automatically changes a
feature's primary tag to this form whenever the feature is added to
the collection by this method. Only two methods in Bio::Assembly::Contig
will not work unless there are features from this class:
change_coord() and get_seq_coord().
Other feature classes will be automatically available only when
Bio::Assembly::Contig objects are created by a specific module. Such
feature classes are (or should be) documented in the documentation of
the module which create them, to which the user should refer.
=head1 FEEDBACK
=head2 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 lists Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
=head2 Support
Please direct usage questions or support issues to the mailing list:
I<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.
=head2 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
=head1 AUTHOR - Robson Francisco de Souza
rfsouza@citri.iq.usp.br
=head1 APPENDIX
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _
=cut
#'
package Bio::Assembly::Contig;
use strict;
use Bio::DB::SeqFeature::Store; # isa Bio::SeqFeature::CollectionI
use Bio::Seq::PrimaryQual; # isa Bio::Seq::QualI
use Scalar::Util qw(weaken);
use base qw(Bio::Root::Root Bio::Align::AlignI);
=head1 Object creator
=head2 new
Title : new
Usage : my $contig = Bio::Assembly::Contig->new();
Function : Creates a new contig object
Returns : Bio::Assembly::Contig
Args : -id => unique contig ID
-source => string for the sequence assembly program used
-collection => Bio::SeqFeature::CollectionI instance
=cut
#-----------
sub new {
#-----------
my ($class, @args) = @_;
my $self = $class->SUPER::new(@args);
my ($src, $id, $collection) = $self->_rearrange([qw(SOURCE ID COLLECTION)], @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...
# for cases where SF::Collection is shared between Bio::Assembly::Contig
if ($collection) {
$self->throw("Collection must implement Bio::SeqFeature::CollectionI") unless $collection->isa('Bio::SeqFeature::CollectionI');
$self->{'_sfc'} = $collection;
} else {
$self->{'_sfc'} = Bio::DB::SeqFeature::Store->new(
-adaptor => 'memory',
-index_subfeatures => 1,
);
}
# Assembly specifics
$self->{'_assembly'} = undef; # Bio::Assembly::Scaffold the contig belongs to
$self->{'_strand'} = 0; # Reverse (-1) or forward (1), if contig is in a scaffold. 0 otherwise
$self->{'_neighbor_start'} = undef; # Neighbor Bio::Assembly::Contig
$self->{'_neighbor_end'} = undef; # Neighbor Bio::Assembly::Contig
return $self; # success - we hope!
}
=head1 Assembly related methods
These methods exist to enable adding information about possible
relations among contigs, e.g. when you already have a scaffold for
your assembly, describing the ordering of contigs in the final
assembly, but no sequences covering the gaps between neighboring
contigs.
=head2 source
Title : source
Usage : $contig->source($program);
Function : Get/Set program used to build this contig
Returns : string
Argument : [optional] string
=cut
sub source {
my $self = shift;
my $source = shift;
$self->{'_source'} = $source if (defined $source);
return $self->{'_source'};
}
=head2 assembly
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
=cut
sub assembly {
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"));
# We create a circular reference to a Scaffold object. It is made weak
# to prevent memory leaks.
$self->{'_assembly'} = $assembly if (defined $assembly);
weaken($self->{'_assembly'});
return $self->{'_assembly'};
}
=head2 strand
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
=cut
sub strand {
my $self = shift;
my $ori = shift;
if (defined $ori) {
$self->throw("Contig strand must be either 1, -1 or 0")
unless $ori == 1 || $ori == 0 || $ori == -1;
$self->{'_strand'} = $ori;
}
return $self->{'_strand'};
}
=head2 upstream_neighbor
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
=cut
sub upstream_neighbor {
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'};
}
=head2 downstream_neighbor
Title : downstream_neighbor
Usage : $contig->downstream_neighbor($num);
Function : Get/Set a contig neighbor for the current contig when
( run in 3.711 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )