2 # BioPerl module for Bio::Assembly::Singlet
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Chad Matsalla <bioinformatics1 at dieselwurks.com>
8 # Copyright Chad Matsalla
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Assembly::Singlet - Perl module to hold and manipulate
17 singlets from sequence assembly contigs.
22 use Bio::Assembly::IO;
24 # Assembly loading methods
25 $aio = Bio::Assembly::IO->new( -file => 'test.ace.1',
28 $assembly = $aio->next_assembly;
29 foreach $singlet ($assembly->all_singlets) {
33 # OR, if you want to build the singlet yourself,
35 use Bio::Assembly::Singlet;
36 $singlet = Bio::Assembly::Singlet->new(
43 A singlet is a sequence that phrap was unable to align to any other sequences.
49 User feedback is an integral part of the evolution of this and other
50 Bioperl modules. Send your comments and suggestions preferably to the
51 Bioperl mailing lists Your participation is much appreciated.
53 bioperl-l@bioperl.org - General discussion
54 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
58 Please direct usage questions or support issues to the mailing list:
60 I<bioperl-l@bioperl.org>
62 rather than to the module maintainer directly. Many experienced and
63 reponsive experts will be able look at the problem and quickly
64 address it. Please include a thorough description of the problem
65 with code and data examples if at all possible.
69 Report bugs to the Bioperl bug tracking system to help us keep track
70 the bugs and their resolution. Bug reports can be submitted via the
73 https://redmine.open-bio.org/projects/bioperl/
75 =head1 AUTHOR - Chad S. Matsalla
77 bioinformatics1 at dieselwurks.com
81 The rest of the documentation details each of the object
82 methods. Internal methods are usually preceded with a _
87 package Bio
::Assembly
::Singlet
;
91 use Bio
::SeqFeature
::Collection
;
92 use Bio
::LocatableSeq
;
93 use Bio
::Seq
::PrimaryQual
;
95 use base
qw(Bio::Assembly::Contig Bio::Root::Root Bio::Align::AlignI);
100 Usage : $singlet = $io->new( -seqref => $seq )
101 Function: Create a new singlet object
102 Returns : A Bio::Assembly::Singlet object
103 Args : -seqref => Bio::Seq-compliant sequence object for the singlet
108 my ($class, @args) = @_;
109 my $self = $class->SUPER::new
(@args);
110 my ($seqref) = $self->_rearrange([qw(SEQREF)], @args);
111 $self->{'_seqref'} = undef;
112 if (defined $seqref) {
113 $self->seqref($seqref);
121 Usage : $seqref = $singlet->seqref($seq);
122 Function: Get/set the sequence to which this singlet refers
123 Returns : A Bio::Seq-compliant object
124 Args : A Bio::Seq-compliant or Bio::Seq::Quality object
129 my ($self,$seq) = @_;
130 if (defined $seq) { $self->_seq_to_singlet($seq) };
131 return $self->{'_seqref'};
134 =head2 _seq_to_singlet
136 Title : _seq_to_singlet
137 Usage : $singlet->seqref($seq)
138 Function: Transform a sequence into a singlet
139 Returns : 1 for sucess
140 Args : A Bio::Seq-compliant object
144 sub _seq_to_singlet
{
145 my ($self, $seq) = @_;
146 # Object type checking
147 $self->throw("Unable to process non Bio::Seq-compliant object [".ref($seq)."]")
148 unless ( defined $seq && ($seq->isa('Bio::PrimarySeqI') || $seq->isa('Bio::Seq::Quality')) );
150 $self->throw("Unable to have more than one sequence reference in a singlet")
151 if (defined $self->{'_seqref'});
152 # From sequence to locatable sequence
153 my $lseq = Bio
::LocatableSeq
->new(
156 -strand
=> $seq->isa('Bio::LocatableSeq') ?
$seq->strand : 1,
158 #-end => we let Bio::LocatableSeq calculate it (Seq and LocatableSeq)
160 # Add new sequence and its coordinates to the contig
161 my $lcoord = Bio
::SeqFeature
::Generic
->new( -start
=> $lseq->start,
162 -end
=> $lseq->end );
163 $self->set_seq_coord( $lcoord, $lseq );
164 $self->{'_seqref'} = $lseq;
166 $self->set_consensus_sequence($lseq);
167 if ($seq->isa("Bio::Seq::Quality")) {
168 my $qual = Bio
::Seq
::PrimaryQual
->new( -id
=> $seq->id,
169 -qual
=> $seq->qual );
170 $self->set_consensus_quality($qual);