Skip to content

Commit

Permalink
Fixed problem with optional reverse primer read from file
Browse files Browse the repository at this point in the history
  • Loading branch information
fangly committed Mar 14, 2012
1 parent 07dcf87 commit edc8cae
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
9 changes: 6 additions & 3 deletions Bio/Tools/AmpliconSearch.pm
Expand Up @@ -269,9 +269,10 @@ sub _set_primer {
Title : primer_file
Usage : my ($fwd, $rev) = $search->primer_file;
Function : Get/set a sequence file to read the primer from. After reading the
file, the primers are set using fwd_primer() and rev_primer() and
returned.
Function : Get/set a sequence file to read the primer from. The first sequence
must be the forward primer, and the second is the optional reverse
primer. After reading the file, the primers are set using fwd_primer()
and rev_primer() and returned.
Args : Sequence file
Returns : Array containing forward and reverse primers as sequence objects.
Expand Down Expand Up @@ -299,6 +300,8 @@ sub primer_file {
my $rev_primer = $in->next_seq;
if (defined $rev_primer) {
$rev_primer->alphabet('dna');
} else {
$rev_primer = '';
}

$in->close;
Expand Down
25 changes: 23 additions & 2 deletions t/Tools/AmpliconSearch.t
Expand Up @@ -2,7 +2,7 @@ BEGIN {
use lib '.';
use Bio::Root::Test;

test_begin(-tests => 160);
test_begin(-tests => 174);

use_ok 'Bio::PrimarySeq';
use_ok 'Bio::SeqFeature::Primer';
Expand Down Expand Up @@ -103,7 +103,7 @@ is $search->template->seq, 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTac
is $search->next_amplicon, undef;


## Degenerate forward and reverse primers from file, single amplicon
# Degenerate forward and reverse primers from file, single amplicon

ok $search = Bio::Tools::AmpliconSearch->new(
-template => $seq,
Expand All @@ -121,6 +121,26 @@ is $amplicon->seq->seq, 'AAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGT';
is $search->next_amplicon, undef;


# Forward primer only, in sequence file

ok $search = Bio::Tools::AmpliconSearch->new(
-primer_file => test_input_file('forward_primer.fa'),
), 'Forward primer from file';
ok $search->template($seq);
is $search->fwd_primer->seq, 'AAACTTAAAGGAATTGACGG';
is $search->rev_primer, undef;
ok $template_seq = $search->template;
isa_ok $template_seq, 'Bio::Seq';
is $template_seq->seq, 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac';
ok $amplicon = $search->next_amplicon;
isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
is $amplicon->start, 4;
is $amplicon->end, 56;
is $amplicon->strand, 1;
is $amplicon->seq->seq, 'AAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac';
is $amplicon = $search->next_amplicon, undef;


# Multiple amplicons

$seq = Bio::PrimarySeq->new(
Expand Down Expand Up @@ -406,3 +426,4 @@ is $search->template->seq, 'aCCCCgaTTTTTTgacgtacgtac';
ok $amplicon = $search->next_amplicon;
is $amplicon->seq->seq, 'CCCCgaTTTTTT';
is $search->next_amplicon, undef;

0 comments on commit edc8cae

Please sign in to comment.