3 # BioPerl module for Bio::Assembly::Singlet
5 # Cared for by Chad Matsalla <bioinformatics1 at dieselwurks.com>
7 # Copyright Chad Matsalla
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
15 Bio::Assembly::Singlet - Perl module to hold and manipulate
16 singlets from sequence assembly contigs.
21 use Bio::Assembly::IO;
23 # Assembly loading methods
24 $aio = Bio::Assembly::IO->new( -file => 'test.ace.1',
27 $assembly = $aio->next_assembly;
28 foreach $singlet ($assembly->all_singlets) {
32 # OR, if you want to build the singlet yourself,
34 use Bio::Assembly::Singlet;
35 $singlet = Bio::Assembly::Singlet->new( -seqref => $seq );
39 A singlet is a sequence that phrap was unable to align to any other sequences.
45 User feedback is an integral part of the evolution of this and other
46 Bioperl modules. Send your comments and suggestions preferably to the
47 Bioperl mailing lists Your participation is much appreciated.
49 bioperl-l@bioperl.org - General discussion
50 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
54 Report bugs to the Bioperl bug tracking system to help us keep track
55 the bugs and their resolution. Bug reports can be submitted via the
58 http://bugzilla.open-bio.org/
60 =head1 AUTHOR - Chad S. Matsalla
62 bioinformatics1 at dieselwurks.com
66 The rest of the documentation details each of the object
67 methods. Internal methods are usually preceded with a _
72 package Bio
::Assembly
::Singlet
;
76 use Bio
::SeqFeature
::Collection
;
77 use Bio
::Seq
::PrimaryQual
;
78 use base
qw(Bio::Assembly::Contig Bio::Root::Root Bio::Align::AlignI);
83 Usage : $singlet = $io->new( -seqref => $seq )
84 Function: Create a new singlet object
85 Returns : A Bio::Assembly::Singlet object
86 Args : -seqref => Bio::Seq-compliant sequence object for the singlet
91 my ($class, @args) = @_;
92 my $self = $class->SUPER::new
(@args);
93 my ($seqref) = $self->_rearrange([qw(SEQREF)], @args);
94 $self->{'_seqref'} = undef;
95 if (defined $seqref) {
96 $self->seqref($seqref);
104 Usage : $seqref = $singlet->seqref($seq);
105 Function: Get/set the sequence to which this singlet refers
106 Returns : A Bio::Seq-compliant object
107 Args : A Bio::Seq-compliant object
112 my ($self,$seq) = @_;
113 if (defined $seq) { $self->_seq_to_singlet($seq) };
114 return $self->{'_seqref'};
117 =head2 _seq_to_singlet
119 Title : _seq_to_singlet
120 Usage : $singlet->seqref($seq)
121 Function: Transform a sequence into a singlet
122 Returns : A Bio::Assembly::Singlet object
123 Args : A Bio::Seq-compliant object
127 sub _seq_to_singlet
{
128 my ($self, $seq) = @_;
129 # Object type checking
130 $self->throw("Unable to process non Bio::Seq-compliant object [".ref($seq)."]")
131 unless (defined $seq && ($seq->isa("Bio::Seq") || $seq->isa("Bio::LocatableSeq")) );
133 $self->throw("Unable to have more than one seqref in a singlet")
134 if (defined $self->{'_seqref'});
135 # From sequence to locatable sequence
136 my $seq_id = $seq->id();
137 my $lseq = Bio
::LocatableSeq
->new(
140 -end
=> $seq->length(),
145 $self->add_seq($lseq);
146 # Creating singlet ID, seqref and consensus
148 $self->{'_seqref'} = $seq;
149 $self->set_consensus_sequence($lseq);
150 if ($seq->isa("Bio::Seq::Quality")) {
151 $self->set_consensus_quality($seq);