2 # BioPerl module for Bio::Tools::ipcress
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::ipcress - Parse ipcress output and make features
20 # A simple annotation pipeline wrapper for ipcress data
21 # assuming ipcress data is already generated in file seq1.ipcress
22 # and sequence data is in fasta format in file called seq1.fa
24 use Bio::Tools::ipcress;
26 my $parser = Bio::Tools::ipcress->new(-file => 'seq1.ipcress');
27 my $seqio = Bio::SeqIO->new(-format => 'fasta', -file => 'seq1.fa');
28 my $seq = $seqio->next_seq || die("cannot get a seq object from SeqIO");
30 while( my $feat = $parser->next_feature ) {
31 # add ipcress annotation to a sequence
32 $seq->add_SeqFeature($feat);
34 my $seqout = Bio::SeqIO->new(-format => 'embl');
35 $seqout->write_seq($seq);
40 This object serves as a parser for ipcress data, creating a
41 Bio::SeqFeatureI for each ipcress hit. These can be processed or added
42 as annotation to an existing Bio::SeqI object for the purposes of
45 This module is adapted from the Bio::Tools::EPCR module
46 written by Jason Stajich (jason-at-bioperl.org).
48 Ipcress is available through Guy Slater's Exonerate package
49 http://www.ebi.ac.uk/~guy/exonerate/
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
::ipcress
;
99 use Bio
::SeqFeature
::Generic
;
101 use base
qw(Bio::Root::Root);
106 Usage : my $ipcress = Bio::Tools::ipcress->new(-file => $file,
107 -primary => $fprimary,
109 -groupclass => $fgroupclass);
110 Function: Initializes a new ipcress parser
111 Returns : Bio::Tools::ipcress
112 Args : -fh => filehandle
116 -primary => a string to be used as the common value for
117 each features '-primary' tag. Defaults to
118 the sequence ontology term 'PCR_product'.
119 (This in turn maps to the GFF 'type'
122 -source => a string to be used as the common value for
123 each features '-source' tag. Defaults to
124 'ipcress'. (This in turn maps to the GFF 'source'
127 -groupclass => a string to be used as the name of the tag
128 which will hold the sts marker namefirst
129 attribute. Defaults to 'name'.
134 my($class,@args) = @_;
136 my $self = $class->SUPER::new
(@args);
137 my ($primary, $source,
138 $groupclass, $file, $fh) = $self->_rearrange([qw(PRIMARY
142 $self->primary(defined $primary ?
$primary : 'PCR_product');
143 $self->source(defined $source ?
$source : 'ipcress');
144 $self->groupclass(defined $groupclass ?
$groupclass : 'name');
146 local $/ = 'Ipcress result';
150 open my $FH, '<', $file or $self->throw("Could not read file '$file': $!");
158 $self->throw("Bio::Tools::ipcress: no input file");
164 $self->{result
} = \
@result;
172 Usage : $seqfeature = $obj->next_feature();
173 Function: Returns the next feature available in the analysis result, or
174 undef if there are no more features.
176 Returns : A Bio::SeqFeatureI implementing object, or undef if there are no
184 my $result = shift @
{$self->{result
}};
185 return unless defined($result);
188 my @lines = split "\n", $result;
189 my ($ipcress) = grep /ipcress: /, @lines;
191 my (undef,$seqname,$mkrname,$length,undef,$start,$mismatchL,
192 undef,undef,$mismatchR,$desc) = split /\s+/, $ipcress;
194 my $end = $start + $length;
197 my $strand = $desc eq 'forward' ?
'+' : $desc eq 'revcomp' ?
'-' : 0;
199 my ($left) = grep /\# forward/, @lines;
200 $left =~ s/[^A-Z]+//g;
201 my ($right) = grep /\# revcomp/, @lines;
202 $right =~ s/[^A-Z]+//g;
203 $right = reverse $right;
205 # if there are multiple hits, increment the name for
207 if (++$self->{seen
}->{$mkrname} > 1) {
208 $mkrname .= "\.$self->{seen}->{$mkrname}";
212 my $markerfeature = Bio
::SeqFeature
::Generic
->new
213 ( '-start' => $start,
215 '-strand' => $strand,
216 '-source' => $self->source,
217 '-primary' => $self->primary,
218 '-seq_id' => $seqname,
220 $self->groupclass => $mkrname,
224 $markerfeature->add_tag_value('Note' => "bad product: single primer amplification");
227 $markerfeature->add_tag_value('left_primer' => $left);
228 $markerfeature->add_tag_value('right_primer' => $right);
229 $markerfeature->add_tag_value('left_mismatches' => $mismatchL) if $mismatchL;
230 $markerfeature->add_tag_value('right_mismatches' => $mismatchR) if $mismatchR;
232 return $markerfeature;
238 Usage : $obj->source($newval)
241 Returns : value of source (a scalar)
242 Args : on set, new value (a scalar or undef, optional)
249 return $self->{'_source'} = shift if @_;
250 return $self->{'_source'};
256 Usage : $obj->primary($newval)
259 Returns : value of primary (a scalar)
260 Args : on set, new value (a scalar or undef, optional)
267 return $self->{'_primary'} = shift if @_;
268 return $self->{'_primary'};
274 Usage : $obj->groupclass($newval)
277 Returns : value of groupclass (a scalar)
278 Args : on set, new value (a scalar or undef, optional)
286 return $self->{'_groupclass'} = shift if @_;
287 return $self->{'_groupclass'};