script/primer_designer.pl untested

filter: Statementstmt 0.0% 0 / 61 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 16 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 93 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl
2  
3 =head1 NAME
4  
5 primer_designer.pl -- command-line interface Bio::PrimerDesigner
6  
7 =head1 SYNOPSIS
8  
9 ./primer_designer.pl [options] [dna_sequence or file]
10  
11 Options:
12  
13 -p|--program Program (default "primer3")
14 -n|--number Number of primer sets to return (default "5")
15 -b|--binary Path to binary executable (default "/usr/local/bin")
16 -m|--method "local" or "remote" (default "local")
17 -u|--url URL of remote primer3/e-PCR system
18 (default "aceserver.biotech.ubc.ca/cgi-bin/primer_designer.cgi")
19 --list-aliases Print alias list to primer3 input options and exit
20 --list-params Print a list of primer3/e-PCR input options and exit
21 -h|--help Print help and exit
22  
23 =head1 DESCRIPTION
24  
25 This script tests/demonstrates the Bio::PrimerDesigner interface to
26 primer3 and e-PCR. It can be used with a local installation of the
27 unix binaries or remotely via an HTTP/CGI request.
28  
29 =cut
30  
31 use strict;
32  
33 use Bio::PrimerDesigner;
34 use Getopt::Long;
35 use Pod::Usage;
36  
37 $| = 1;
38  
39 my ( $program, $num_primers, $binary_path, $method, $url, $list_aliases,
40 $list_params, $list_designers, $show_help );
41  
42 GetOptions(
43 'd|designer:s' => \$program,
44 'n|number:i' => \$num_primers,
45 'b|binary:s' => \$binary_path,
46 'm|method:s' => \$method,
47 'u|url:s' => \$url,
48 'list-aliases' => \$list_aliases,
49 'list-params' => \$list_params,
50 'h|help' => \$show_help,
51 ) or pod2usage(2);
52  
53 pod2usage(2) if $show_help;
54  
55 #
56 # Create Bio::PrimerDesigner object.
57 #
58 my $pd = Bio::PrimerDesigner->new(
59 program => $program,
60 method => $method,
61 url => $url,
62 binary_path => $binary_path,
63 ) or die Bio::PrimerDesigner->error;
64  
65 #
66 # List paramaters to primer design program.
67 #
68 if ( $list_params ) {
69 my $title = $program . ' Parameters:';
70 print join "\n", $title, '-' x length $title, $pd->list_params, '';
71 print "\n";
72 }
73
74 #
75 # List aliased keys to primer design program and exit.
76 #
77 if ( $list_aliases ) {
78 my %alias_list = ( $pd->list_aliases );
79  
80 my $longest = 0;
81 for my $length ( map { length $_ } keys %alias_list ) {
82 $longest = $length if $length > $longest;
83 }
84  
85 my @aliases;
86 for my $key ( sort keys %alias_list ) {
87 my $length = length $key;
88 my $space = ' ' x ( $longest - $length + 5 );
89 push @aliases, "$key$space$alias_list{$key}";
90 }
91  
92 my $header = 'Primer3 Parameter';
93 my $space = ' ' x ( $longest - length( $header ) + 5 );
94 my $title = "$header${space}Bio::PrimerDesigner Alias";
95 unshift @aliases, $title, '-' x length $title;
96  
97 print join "\n", @aliases, '';
98 exit;
99 }
100  
101 #
102 # Get the DNA sequence from somewhere.
103 #
104 chomp (my $dna = <DATA>);
105  
106 $num_primers ||= 5;
107 my $length = length $dna;
108 my $seqID = "C02D5.1";
109  
110 #
111 # Define Bio::PrimerDesigner parameters
112 # in this case I use aliased keys
113 # the primer3 Boulder IO keys are also valid
114 #
115 my %params = (
116 num => $num_primers,
117 seq => $dna,
118 sizerange => '500-600',
119 target => '5001,200',
120 excluded => '1,4500 5500,'.($length-5500-1),
121 id => $seqID
122 );
123  
124 #
125 # Design the primers.
126 #
127 my $result = $pd->design( %params );
128  
129 #
130 # Did it work?
131 #
132 die ("Some sort of primer3 error\n", $result->raw_output)
133 unless $result && $result->left;
134  
135 #
136 # Initialize e-PCR object
137 #
138 $method ||= 'local';
139 my $epcr = Bio::PrimerDesigner->new(
140 program => 'epcr',
141 method => $method
142 ) or die Bio::PrimerDesigner->error;
143  
144 #
145 # List paramaters for epcr program and exit.
146 #
147 if ( $list_params ) {
148 my $title = 'e-PCR Parameters:';
149 print join "\n", $title, '-' x length $title,
150 $epcr->list_params, '';
151 exit;
152 }
153  
154 my $header = "Primers designed using $method primer3/e-PCR"
155 ." installation";
156 my $hline = '-' x length $header;
157  
158 print "\n$hline\n$header\n$hline\n\nPrimer",
159 (" " x 14), "\tF/R\t5' Coord Pair-qual\n";
160  
161 for ( 1 .. $num_primers ) {
162 my %params = ( seq => $dna,
163 left => $result->left($_),
164 right => $result->right($_),
165 permute => 1
166 );
167
168 my $epcr_result = $epcr->design( %params )
169 or die $epcr->error;
170
171 print
172 "Set $_\n", $result->left($_),
173 "\t F \t", $result->startleft($_),
174 "\n", $result->right($_),
175 "\t R \t", $result->startright($_),
176 "\t", $result->qual($_)."\n",
177 "\ne-PCR products: ", $epcr_result->products, "\n";
178
179 for my $prod ( 1 .. $epcr_result->products ) {
180 print
181 "product $prod: start->", $epcr_result->start($prod),
182 " end->", $epcr_result->stop($prod), " size->",
183 $epcr_result->size($prod), "bp\n\n";
184 }
185 }
186  
187 =pod
188  
189 =head1 AUTHOR
190  
191 Copyright (C) 2003-4 Sheldon McKay E<lt>smckay@bcgsc.bc.caE<gt>,
192 Ken Y. Clark E<lt>kclark@cpan.orgE<gt>.
193  
194 =head1 SEE ALSO
195  
196 Bio::PrimerDesigner.
197  
198 =cut
199  
200 __DATA__