3 # BioPerl module for Bio::Tools::ipcress
5 # Cared for by Sheldon McKay <mckays@cshl.edu>
7 # Copyright Sheldon McKay
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
15 Bio::Tools::ipcress - Parse ipcress output and make features
19 # A simple annotation pipeline wrapper for ipcress data
20 # assuming ipcress data is already generated in file seq1.ipcress
21 # and sequence data is in fasta format in file called seq1.fa
23 use Bio::Tools::ipcress;
25 my $parser = Bio::Tools::ipcress->new(-file => 'seq1.ipcress');
26 my $seqio = Bio::SeqIO->new(-format => 'fasta', -file => 'seq1.fa');
27 my $seq = $seqio->next_seq || die("cannot get a seq object from SeqIO");
29 while( my $feat = $parser->next_feature ) {
30 # add ipcress annotation to a sequence
31 $seq->add_SeqFeature($feat);
33 my $seqout = Bio::SeqIO->new(-format => 'embl');
34 $seqout->write_seq($seq);
39 This object serves as a parser for ipcress data, creating a
40 Bio::SeqFeatureI for each ipcress hit. These can be processed or added
41 as annotation to an existing Bio::SeqI object for the purposes of
44 This module is adapted from the Bio::Tools::EPCR module
45 written by Jason Stajich (jason-at-bioperl.org).
47 Ipcress is available through Guy Slater's Exonerate package
48 http://www.ebi.ac.uk/~guy/exonerate/
54 User feedback is an integral part of the evolution of this and other
55 Bioperl modules. Send your comments and suggestions preferably to
56 the Bioperl mailing list. Your participation is much appreciated.
58 bioperl-l@bioperl.org - General discussion
59 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
63 Report bugs to the Bioperl bug tracking system to help us keep track
64 of the bugs and their resolution. Bug reports can be submitted via the
67 http://bugzilla.open-bio.org/
69 =head1 AUTHOR - Sheldon McKay
75 The rest of the documentation details each of the object methods.
76 Internal methods are usually preceded with a _
81 # Let the code begin...
84 package Bio
::Tools
::ipcress
;
87 use Bio
::SeqFeature
::Generic
;
89 use base
qw(Bio::Root::Root);
94 Usage : my $ipcress = Bio::Tools::ipcress->new(-file => $file,
95 -primary => $fprimary,
97 -groupclass => $fgroupclass);
98 Function: Initializes a new ipcress parser
99 Returns : Bio::Tools::ipcress
100 Args : -fh => filehandle
104 -primary => a string to be used as the common value for
105 each features '-primary' tag. Defaults to
106 the sequence ontology term 'PCR_product'.
107 (This in turn maps to the GFF 'type'
110 -source => a string to be used as the common value for
111 each features '-source' tag. Defaults to
112 'ipcress'. (This in turn maps to the GFF 'source'
115 -groupclass => a string to be used as the name of the tag
116 which will hold the sts marker namefirst
117 attribute. Defaults to 'name'.
122 my($class,@args) = @_;
124 my $self = $class->SUPER::new
(@args);
125 my ($primary, $source,
126 $groupclass, $file, $fh) = $self->_rearrange([qw(PRIMARY
130 $self->primary(defined $primary ?
$primary : 'PCR_product');
131 $self->source(defined $source ?
$source : 'ipcress');
132 $self->groupclass(defined $groupclass ?
$groupclass : 'name');
134 local $/ = 'Ipcress result';
146 $self->throw("Bio::Tools::ipcress: no input file");
152 $self->{result
} = \
@result;
160 Usage : $seqfeature = $obj->next_feature();
161 Function: Returns the next feature available in the analysis result, or
162 undef if there are no more features.
164 Returns : A Bio::SeqFeatureI implementing object, or undef if there are no
172 my $result = shift @
{$self->{result
}};
173 return unless defined($result);
176 my @lines = split "\n", $result;
177 my ($ipcress) = grep /ipcress: /, @lines;
179 my (undef,$seqname,$mkrname,$length,undef,$start,$mismatchL,
180 undef,undef,$mismatchR,$desc) = split /\s+/, $ipcress;
182 my $end = $start + $length;
185 my $strand = $desc eq 'forward' ?
'+' : $desc eq 'revcomp' ?
'-' : 0;
187 my ($left) = grep /\# forward/, @lines;
188 $left =~ s/[^A-Z]+//g;
189 my ($right) = grep /\# revcomp/, @lines;
190 $right =~ s/[^A-Z]+//g;
191 $right = reverse $right;
193 # if there are multiple hits, increment the name for
195 if (++$self->{seen
}->{$mkrname} > 1) {
196 $mkrname .= "\.$self->{seen}->{$mkrname}";
200 my $markerfeature = Bio
::SeqFeature
::Generic
->new
201 ( '-start' => $start,
203 '-strand' => $strand,
204 '-source' => $self->source,
205 '-primary' => $self->primary,
206 '-seq_id' => $seqname,
208 $self->groupclass => $mkrname,
212 $markerfeature->add_tag_value('Note' => "bad product: single primer amplification");
215 $markerfeature->add_tag_value('left_primer' => $left);
216 $markerfeature->add_tag_value('right_primer' => $right);
217 $markerfeature->add_tag_value('left_mismatches' => $mismatchL) if $mismatchL;
218 $markerfeature->add_tag_value('right_mismatches' => $mismatchR) if $mismatchR;
220 return $markerfeature;
226 Usage : $obj->source($newval)
229 Returns : value of source (a scalar)
230 Args : on set, new value (a scalar or undef, optional)
237 return $self->{'_source'} = shift if @_;
238 return $self->{'_source'};
244 Usage : $obj->primary($newval)
247 Returns : value of primary (a scalar)
248 Args : on set, new value (a scalar or undef, optional)
255 return $self->{'_primary'} = shift if @_;
256 return $self->{'_primary'};
262 Usage : $obj->groupclass($newval)
265 Returns : value of groupclass (a scalar)
266 Args : on set, new value (a scalar or undef, optional)
274 return $self->{'_groupclass'} = shift if @_;
275 return $self->{'_groupclass'};