~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to examples/tools/run_primer3.pl

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
# $Id: run_primer3.pl,v 1.3.4.1 2006/10/02 23:10:38 sendu Exp $
 
3
 
 
4
=head1 NAME
 
5
 
 
6
run_primer3.pl - run primer3 and parse its output
 
7
 
 
8
=head1 SYNOPSIS
 
9
 
 
10
  ./run_primer3.pl -i test.fa
 
11
 
 
12
  #or
 
13
 
 
14
  ./run_primer3.pl --input=test.fa
 
15
 
 
16
=head1 DESCRIPTION
 
17
 
 
18
Example of how to run primer3 and parse its output, essentially taken from an
 
19
email written by Paul Wiersma to bioperl-l.
 
20
 
 
21
=head1 FEEDBACK
 
22
 
 
23
User feedback is an integral part of the evolution of this and other
 
24
Bioperl scripts. Send your comments and suggestions to the Bioperl 
 
25
mailing list.  Your participation is much appreciated.
 
26
 
 
27
  bioperl-l@bioperl.org                  - General discussion
 
28
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
 
29
 
 
30
=head2 Reporting Bugs
 
31
 
 
32
Report bugs to the Bioperl bug tracking system to help us keep track
 
33
of the bugs and their resolution. Bug reports can be submitted via the
 
34
web:
 
35
 
 
36
  http://bugzilla.open-bio.org/
 
37
 
 
38
=head1 AUTHOR
 
39
 
 
40
Brian Osborne, bosborne at alum.mit.edu
 
41
 
 
42
=cut
 
43
 
 
44
use strict;
 
45
use Getopt::Long;
 
46
use Bio::Tools::Run::Primer3;
 
47
use Bio::SeqIO;
 
48
 
 
49
my $in_file;
 
50
 
 
51
GetOptions("i|input:s" => \$in_file );
 
52
 
 
53
usage() unless $in_file;
 
54
 
 
55
my $seqio = Bio::SeqIO->new(-file => $in_file);
 
56
 
 
57
while (my $seq = $seqio->next_seq) {
 
58
        my $primer3 = Bio::Tools::Run::Primer3->new(-seq => $seq);
 
59
        $primer3->program_name('primer3_core') unless $primer3->executable;
 
60
 
 
61
        $primer3->add_targets('PRIMER_MIN_TM' => 56, 'PRIMER_MAX_TM' => 90);
 
62
 
 
63
        my $results = $primer3->run;
 
64
 
 
65
        unless ($results->number_of_results) {
 
66
                print "No results for ",$seq->display_id;
 
67
                next;
 
68
        }
 
69
 
 
70
        my @out_keys_part = qw(START
 
71
                                                                    LENGTH
 
72
                                                                    TM
 
73
                                                                         GC_PERCENT
 
74
                                                                         SELF_ANY
 
75
                                                                         SELF_END
 
76
                                                                         SEQUENCE );
 
77
 
 
78
        print "\n", $seq->display_id, "\n";
 
79
 
 
80
        for (my $i = 0 ; $i < $results->number_of_results ; $i++){
 
81
                my $result = $results->primer_results($i);
 
82
 
 
83
                print "\n", $i + 1;     
 
84
                for my $key qw(PRIMER_LEFT PRIMER_RIGHT){       
 
85
                        my ($start, $length) = split /,/, $result->{$key};
 
86
                        $result->{$key . "_START"} = $start;
 
87
                        $result->{$key . "_LENGTH"} = $length;
 
88
                        foreach my $partkey (@out_keys_part) {
 
89
                                print "\t", $result->{$key . "_" . $partkey};
 
90
                        } 
 
91
                        print "\n";
 
92
                }
 
93
                print "\tPRODUCT SIZE: ", $result->{'PRIMER_PRODUCT_SIZE'}, ", PAIR ANY COMPL: ",
 
94
                  $result->{'PRIMER_PAIR_COMPL_ANY'};
 
95
                print ", PAIR 3\' COMPL: ", $result->{'PRIMER_PAIR_COMPL_END'}, "\n";
 
96
        }
 
97
}
 
98
 
 
99
sub usage {
 
100
   exec('perldoc',$0);
 
101
   exit(0);
 
102
}
 
103
 
 
104
__END__