2 # BioPerl module for Bio::Tools::isPcr
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Sheldon McKay <mckays@cshl.edu>
8 # Copyright Sheldon McKay
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Tools::isPcr - Parse isPcr output and make features
20 # A simple annotation pipeline wrapper for isPcr data
21 # assuming isPcr data is already generated in file seq1.isPcr
22 # and sequence data is in fasta format in file called seq1.fa
24 # Note: this parser is meant for the default fasta output from
25 # isPcr. bed and psl output formats are not supported.
27 use Bio::Tools::IsPcr;
29 my $parser = Bio::Tools::isPcr->new(-file => 'seq1.isPcr');
30 my $seqio = Bio::SeqIO->new(-format => 'fasta', -file => 'seq1.fa');
31 my $seq = $seqio->next_seq || die("cannot get a seq object from SeqIO");
33 while( my $feat = $parser->next_feature ) {
34 # add isPcr annotation to a sequence
35 $seq->add_SeqFeature($feat);
37 my $seqout = Bio::SeqIO->new(-format => 'embl');
38 $seqout->write_seq($seq);
43 This object serves as a parser for isPcr data (in the default fasta
44 format), creating a Bio::SeqFeatureI for each isPcr hit.
45 These can be processed or added as annotation to an existing
46 Bio::SeqI object for the purposes of automated annotation.
48 This module is adapted from the Bio::Tools::EPCR module
49 written by Jason Stajich (jason-at-bioperl.org).
55 User feedback is an integral part of the evolution of this and other
56 Bioperl modules. Send your comments and suggestions preferably to
57 the Bioperl mailing list. Your participation is much appreciated.
59 bioperl-l@bioperl.org - General discussion
60 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
64 Please direct usage questions or support issues to the mailing list:
66 I<bioperl-l@bioperl.org>
68 rather than to the module maintainer directly. Many experienced and
69 reponsive experts will be able look at the problem and quickly
70 address it. Please include a thorough description of the problem
71 with code and data examples if at all possible.
75 Report bugs to the Bioperl bug tracking system to help us keep track
76 of the bugs and their resolution. Bug reports can be submitted via the
79 https://github.com/bioperl/bioperl-live/issues
81 =head1 AUTHOR - Sheldon McKay
87 The rest of the documentation details each of the object methods.
88 Internal methods are usually preceded with a _
93 # Let the code begin...
96 package Bio
::Tools
::isPcr
;
101 use Bio
::SeqFeature
::Generic
;
104 use base
qw(Bio::Root::Root);
110 Usage : my $ispcr = Bio::Tools::isPcr->new( -file => $file,
111 -primary => $fprimary,
113 -groupclass => $fgroupclass);
115 Function: Initializes a new isPcr parser
116 Returns : Bio::Tools::isPcr
117 Args : -fh => filehandle
121 -primary => a string to be used as the common value for
122 each features '-primary' tag. Defaults to
123 the sequence ontology term 'PCR_product'.
124 (This in turn maps to the GFF 'type'
127 -source => a string to be used as the common value for
128 each features '-source' tag. Defaults to
129 'isPcr'. (This in turn maps to the GFF 'source'
132 -groupclass => a string to be used as the name of the tag
133 which will hold the sts marker namefirst
134 attribute. Defaults to 'name'.
140 my($class,@args) = @_;
142 my $self = $class->SUPER::new
(@args);
143 my ($primary,$source,$groupclass) =
144 $self->_rearrange([qw
/PRIMARY SOURCE GROUPCLASS/],@args);
145 $self->primary(defined $primary ?
$primary : 'PCR_product');
146 $self->source(defined $source ?
$source : 'isPcr');
147 $self->groupclass(defined $groupclass ?
$groupclass : 'name');
149 # default output for isPcr is fasta format
150 $self->{io
} = Bio
::SeqIO
->new(-format
=> 'fasta', @args);
158 Usage : $seqfeature = $obj->next_feature();
159 Function: Returns the next feature available in the analysis result, or
160 undef if there are no more features.
162 Returns : A Bio::SeqFeatureI implementing object, or undef if there are no
170 my $result = $self->{io
}->next_seq;
171 return unless defined $result;
173 my ($seqname,$location) = split ':', $result->primary_id;
174 my ($pcrname,$left,$right) = split /\s+/, $result->desc;
175 my ($start,$strand,$end) = $location =~ /^(\d+)([-+])(\d+)$/;
176 my $amplicon = $result->seq;
178 # if there are multiple hits, increment the name for
180 if (++$self->{seen
}->{$pcrname} > 1) {
181 $pcrname .= "\.$self->{seen}->{$pcrname}";
185 $self->groupclass => $pcrname,
186 amplicon
=> $amplicon,
187 left_primer
=> $left,
188 right_primer
=> $right
191 my $markerfeature = Bio
::SeqFeature
::Generic
->new(
194 '-strand' => $strand,
195 '-source' => $self->source,
196 '-primary' => $self->primary,
197 '-seq_id' => $seqname,
201 return $markerfeature;
207 Usage : $obj->source($newval)
210 Returns : value of source (a scalar)
211 Args : on set, new value (a scalar or undef, optional)
218 return $self->{'_source'} = shift if @_;
219 return $self->{'_source'};
225 Usage : $obj->primary($newval)
228 Returns : value of primary (a scalar)
229 Args : on set, new value (a scalar or undef, optional)
236 return $self->{'_primary'} = shift if @_;
237 return $self->{'_primary'};
243 Usage : $obj->groupclass($newval)
246 Returns : value of groupclass (a scalar)
247 Args : on set, new value (a scalar or undef, optional)
255 return $self->{'_groupclass'} = shift if @_;
256 return $self->{'_groupclass'};