[Bioperl-l] use primer3 to design primers with multiple sequences

Wiersma, Paul WiersmaP at AGR.GC.CA
Tue May 9 17:59:20 UTC 2006


Hi Li,

I've attached some code I used to explore basic functionality of Primer3.pm modules.  Hopefully you can see how I've picked out parts of the results for printing.  You can modify it as you need to output only some results.

>>>>>>>>
  # design the primers. This runs primer3 and returns a 
  # Bio::Tools::Run::Primer3 object with the results
my $results=$primer3->run;

  # see the Bio::Tools::Run::Primer3 pod for
  # things that you can get from this. For example:

print "There were ", $results->number_of_results+1, " primers\n";

my @out_keys_part = qw(	START
			LENGTH
			TM
			GC_PERCENT
			SELF_ANY
			SELF_END
			SEQUENCE );

for (my $i=0;$i <= $results->number_of_results;$i++){
	
	# get specific results
	my $result1=$results->primer_results($i);
 
	print "\n",$i+1;	
	for $key qw(PRIMER_LEFT PRIMER_RIGHT){
			
			my ($start, $length) = split /,/, ${$result1}{$key};
			${$result1}{$key."_START"} = $start;
			${$result1}{$key."_LENGTH"} = $length;
			foreach $partkey (@out_keys_part) {
				print "\t", ${$result1}{$key."_".$partkey};
			} 
			print "\n";
	}
	print "\tPRODUCT SIZE: ", ${$result1}{'PRIMER_PRODUCT_SIZE'}, ", PAIR ANY COMPL: ",
				${$result1}{'PRIMER_PAIR_COMPL_ANY'};
	print ", PAIR 3\' COMPL: ", ${$result1}{'PRIMER_PAIR_COMPL_END'}, "\n";
}
>>>>>>>>>>>>>>>

Paul A. Wiersma
Agriculture and Agri-Food Canada/Agriculture et Agroalimentaire Canada
Telephone/Téléphone: 250-494-6388
Facsimile/Télécopieur: 250-494-0755
Box 5000, 4200 Hwy 97
Summerland, BC
V0H 1Z0
wiersmap at agr.gc.ca
 
 



-----Original Message-----
From: chen li [mailto:chen_li3 at yahoo.com] 
Sent: Tuesday, May 09, 2006 10:33 AM
To: Wiersma, Paul
Cc: bioperl-l at lists.open-bio.org
Subject: Re: [Bioperl-l] use primer3 to design primers with multiple sequences

Thanks Paul it REALLY works.

I have other questions:
1) When I run the script I use this line on the
command prompt

perl primer.pl >test

When I check the default output file(temp.out) used by
the script I only see the information about the last
sequence which is different from what is in the test
file. In test file I can get all the information for
all the sequences.

2)Is it possible directly to use Bio::Tools:: Primer3
to print out selective information such as the primer
sequence and the size of PCR product?  Or do I have
parse the file by myself?

After I get all these information I would like to post
the script for bacth-designing PCR primers.


Thanks,

Li 



--- "Wiersma, Paul" <WiersmaP at agr.gc.ca> wrote:

> Hi Li,
> 
> The line "my $result = $primer3->run" is already in
> the code you submitted.  In the Bio::Tools::Primer3
> module the author uses "$p3" for the object.  If you
> change your line to "my $p3 = $primer3->run" you
> should be able to run the examples below. Process
> the results for each sequence and output the results
> before looping to the next sequence.
> 
> >From Bio::Tools::Primer3.pm:
> 
>  # how many results were there?
>  my $num=$p3->number_of_results;
>  print "There were $num results\n";
> 
>  # get all the results
>  my $all_results=$p3->all_results;
>  print "ALL the results\n";
>  foreach my $key (keys %{$all_results}) {print
> "$key\t${$all_results}{$key}\n"}
> 
>  # get specific results
>  my $result1=$p3->primer_results(1);
>  print "The first primer is\n";
>  foreach my $key (keys %{$result1}) {print
> "$key\t${$result1}{$key}\n"}
> 
> Paul
> 
> Paul A. Wiersma
> Agriculture and Agri-Food Canada/Agriculture et
> Agroalimentaire Canada
> Summerland, BC
> wiersmap at agr.gc.ca
>  
>  
> 
> 
> 
> -----Original Message-----
> From: chen li [mailto:chen_li3 at yahoo.com] 
> Sent: Monday, May 08, 2006 8:32 PM
> To: Wiersma, Paul
> Subject: Re: [Bioperl-l] use primer3 to design
> primers with multiple sequences
> 
> Hi Paul,
> 
> I read both documents. What I understand is that
> Bio:Tools::Run:Primer3 is for designing primers and
> Bio:Tools::Primer3 is for parsing the results. When
> I
> read the documents I do not see this line
>  $result = $primer3->run in Bio:Tools::Primer3. I
> wonder how you get this infomration.
> 
> Thanks,
> 
> Li 
> 
> --- "Wiersma, Paul" <WiersmaP at agr.gc.ca> wrote:
> 
> > Hi Li,
> > 
> >  
> > 
> > When you execute $primer3->run with a
> > Bio::Tools::Run::Primer3 object it
> > opens -outfile=>"filename" for writing and then
> > closes.  That's why
> > putting it in a loop will overwrite your output
> file
> > each time so you
> > only see the last one.  I suppose you could read
> in
> > each output file
> > before looping to the next seq and append it to
> > another file.
> > 
> >  
> > 
> > If you're doing a fair bit of work with this
> module
> > it would be worth
> > looking at the Bio::Tools::Primer3 module.  The
> > statement $result =
> > $primer3->run produces a Bio::Tools::Primer3
> object
> > which has all the
> > methods you need for customizing your output.
> > 
> >  
> > 
> > Paul
> > 
> >  
> > 
> > Paul A. Wiersma
> > Agriculture and Agri-Food Canada/Agriculture et
> > Agroalimentaire Canada
> > Summerland, BC
> > 
> > wiersmap at agr.gc.ca
> > 
> >  
> > 
> >  
> > 
> > 
> > _______________________________________________
> > Bioperl-l mailing list
> > Bioperl-l at lists.open-bio.org
> >
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the Bioperl-l mailing list