Permalink
Browse files

SABlastPlus.t: Some bl2seq tests were giving hits even when the

blast output said 'no hits found' because of no similarity
between the sequences. After fixing SearchResultEventBuilder 'end_hit',
now I'm adapting those tests to give similarity in some cases
and no similarity in others, and expect num_hits accordingly.
Also reflowed some paragraphs
  • Loading branch information...
1 parent 1714031 commit 864e2b68995f283a85bec44bc6d13f6133e243d5 @fjossandon fjossandon committed Dec 11, 2013
Showing with 116 additions and 86 deletions.
  1. +116 −86 t/SABlastPlus.t
View
@@ -1,4 +1,3 @@
-
#-*-perl-*-
#$Id$
# testing StandAloneBlastPlus.pm
@@ -8,8 +7,8 @@ use warnings;
our $home;
BEGIN {
use Bio::Root::Test;
- test_begin(-tests => 65,
- -requires_modules => [qw( Bio::Tools::Run::BlastPlus)]);
+ test_begin(-tests => 69,
+ -requires_modules => [qw( Bio::Tools::Run::BlastPlus)]);
}
use_ok( 'Bio::Tools::Run::StandAloneBlastPlus' );
@@ -18,104 +17,106 @@ use_ok( 'Bio::Tools::Run::WrapperBase::CommandExts' );
use Bio::SeqIO;
use Bio::AlignIO;
-ok my $bpfac = Bio::Tools::Run::BlastPlus->new(-command => 'makeblastdb'),
+ok my $bpfac = Bio::Tools::Run::BlastPlus->new(-command => 'makeblastdb'),
"BlastPlus factory";
SKIP : {
- test_skip( -tests => 61,
- -requires_executable => $bpfac);
+ test_skip( -tests => 65,
+ -requires_executable => $bpfac);
diag('DB and mask make tests');
-
+
# testing using fasta files as input...
ok my $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_data => test_input_file('test-spa.fas'),
- -create => 1
+ -db_data => test_input_file('test-spa.fas'),
+ -create => 1
), "make factory";
ok $fac->make_db, "test db made with fasta";
like $fac->db, qr/DB.{5}/, "temp db";
is ($fac->db_type, 'nucl', "right type");
$fac->cleanup;
ok $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_name => 'test',
- -db_data => test_input_file('test-spa.fas'),
- -create => 1
+ -db_name => 'test',
+ -db_data => test_input_file('test-spa.fas'),
+ -create => 1
);
-
+
like($fac->program_version, qr/2\.\d+\.\d+/, 'program version');
like($fac->package_version, qr/2\.\d+\.\d+/, 'package version');
-
+
ok $fac->make_db, "named db made";
ok $fac->check_db, "check_db";
is $fac->db, 'test', "correct name";
is ref $fac->db_info, 'HASH', "dbinfo hash returned";
is $fac->db_type, 'nucl', "correct type";
ok $fac->make_mask(
- -data=>test_input_file('test-spa.fas'),
- -masker=>'windowmasker'), "windowmasker mask made";
+ -data => test_input_file('test-spa.fas'),
+ -masker => 'windowmasker'
+ ), "windowmasker mask made";
ok $fac->make_mask(
- -data=>test_input_file('test-spa.fas'),
- -masker=>'dustmasker'), "dustmasker mask made";
+ -data => test_input_file('test-spa.fas'),
+ -masker => 'dustmasker'
+ ), "dustmasker mask made";
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_data => test_input_file('test-spa-p.fas'),
- -create => 1
+ -db_data => test_input_file('test-spa-p.fas'),
+ -create => 1
);
ok $fac->check_db('test'), "check_db with arg";
is $fac->db_info('test')->{_db_type}, 'nucl', "db_info with arg";
ok $fac->make_db, "protein db made";
is $fac->db_type, 'prot', "correct type";
ok $fac->make_mask(-data=>$fac->db, -masker=>'segmasker'), "segmasker mask made";
ok $fac->make_mask(
- -data=>$fac->db,
- -masker=>'segmasker'), "segmasker mask made; blastdb as data";
+ -data => $fac->db,
+ -masker => 'segmasker'
+ ), "segmasker mask made; blastdb as data";
$fac->_register_temp_for_cleanup('test');
$fac->cleanup;
-
+
ok $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_data => test_input_file('test-spa-p.fas'),
- -mask_file => test_input_file('segmask_data.asn'),
- -create => 1
+ -db_data => test_input_file('test-spa-p.fas'),
+ -mask_file => test_input_file('segmask_data.asn'),
+ -create => 1
);
ok $fac->make_db, "protein db made with pre-built mask";
is $fac->db_filter_algorithms->[0]{algorithm_name}, 'seg', "db_info records mask info";
$fac->cleanup;
-
ok $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_data => test_input_file('test-spa.fas'),
- -masker=>'windowmasker',
- -mask_data => test_input_file('test-spa.fas'),
- -create => 1
+ -db_data => test_input_file('test-spa.fas'),
+ -masker => 'windowmasker',
+ -mask_data => test_input_file('test-spa.fas'),
+ -create => 1
);
$fac->no_throw_on_crash(1);
-
+
TODO: {
local $TODO = 'BLAST+ 2.2.24+ not working';
ok $fac->make_db, "mask built and db made on construction (windowmasker)";
}
$fac->cleanup;
-
+
ok $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_data => test_input_file('test-spa-p.fas'),
- -masker=>'segmasker',
- -mask_data => test_input_file('test-spa-p.fas'),
- -create => 1
+ -db_data => test_input_file('test-spa-p.fas'),
+ -masker => 'segmasker',
+ -mask_data => test_input_file('test-spa-p.fas'),
+ -create => 1
);
$fac->no_throw_on_crash(1);
TODO: {
local $TODO = 'BLAST+ 2.2.24+ not working';
ok $fac->make_db, "mask built and db made on construction (segmasker)";
}
$fac->cleanup;
-
+
ok $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_data => test_input_file('test-spa.fas'),
- -masker=>'dustmasker',
- -mask_data => test_input_file('test-spa.fas'),
- -create => 1
+ -db_data => test_input_file('test-spa.fas'),
+ -masker => 'dustmasker',
+ -mask_data => test_input_file('test-spa.fas'),
+ -create => 1
);
$fac->no_throw_on_crash(1);
TODO: {
@@ -129,27 +130,27 @@ SKIP : {
ok my $aio = Bio::AlignIO->new(-file => test_input_file('test-spa-p.fas'));
ok $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_name => 'siodb',
- -db_data => $sio,
- -create => 1
+ -db_name => 'siodb',
+ -db_data => $sio,
+ -create => 1
);
ok $fac->make_db, "make db from Bio::SeqIO";
$fac->cleanup;
ok $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_name => 'aiodb',
- -db_data => $aio,
- -create => 1
+ -db_name => 'aiodb',
+ -db_data => $aio,
+ -create => 1
);
ok $fac->make_db, "make db from Bio::AlignIO";
$fac->cleanup;
- $aio = Bio::AlignIO->new(-file=>test_input_file('test-aln.msf'));
+ $aio = Bio::AlignIO->new(-file => test_input_file('test-aln.msf'));
my @seqs = $aio->next_aln->each_seq;
ok $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_name => 'aiodb',
- -db_data => \@seqs,
- -create => 1
+ -db_name => 'aiodb',
+ -db_data => \@seqs,
+ -create => 1
);
ok $fac->make_db, 'make db from \@seqs';
@@ -160,26 +161,26 @@ SKIP : {
#$DB::single=1;
mkdir "./a"; mkdir "./a/b";
ok $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_dir => "./a/b",
- -db_name => "test",
- -db_data => test_input_file('test-spa.fas'),
- -create => 1
+ -db_dir => "./a/b",
+ -db_name => "test",
+ -db_data => test_input_file('test-spa.fas'),
+ -create => 1
), "dbdir : ./a/b; dbname : test; create";
ok $fac->make_db, "make db";
lives_ok { Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_dir => "./a",
- -db_name => "b/test"
- ) };
+ -db_dir => "./a",
+ -db_name => "b/test"
+ ) };
lives_ok { Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_dir => ".",
- -db_name => "a/b/test"
- ) };
+ -db_dir => ".",
+ -db_name => "a/b/test"
+ ) };
lives_ok { Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_name => "a/b/test"
- ) };
+ -db_name => "a/b/test"
+ ) };
dies_ok { Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_name => "/a/b/test"
- ) };
+ -db_name => "/a/b/test"
+ ) };
$fac->_register_temp_for_cleanup('a/b/test');
$fac->cleanup;
rmdir 'a/b';
@@ -190,16 +191,21 @@ SKIP : {
diag("run BLAST methods");
$fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_data => test_input_file('test-spa.fas'),
- -create => 1);
+ -db_data => test_input_file('test-spa.fas'),
+ -create => 1
+ );
- ok my $result = $fac->run( -method => 'blastn', -query => test_input_file('test-query.fas')), "run blastn";
+ ok my $result = $fac->run(-method => 'blastn',
+ -query => test_input_file('test-query.fas')
+ ), "run blastn";
is $result->num_hits, 291, "default hit limit";
- ok $result = $fac->blastn( -query => test_input_file('test-query.fas'),
- -method_args => [ -num_alignments => 1000 ] ), "return more alignments (arg spec)";
+ ok $result = $fac->blastn(-query => test_input_file('test-query.fas'),
+ -method_args => [ -num_alignments => 1000 ]
+ ), "return more alignments (arg spec)";
is $result->num_hits, 291, "got more hits";
$fac->cleanup;
- my $ntseq = Bio::Seq->new( -seq => 'GACGATCCTTCGGTGAGCAAAGAAATTTTAGCAGAAGCTAAAAAGCTAAACGATGCTCAAGCACCAAAAG', -id => 'SA009');
+ my $ntseq = Bio::Seq->new(-seq => 'GACGATCCTTCGGTGAGCAAAGAAATTTTAGCAGAAGCTAAAAAGCTAAACGATGCTCAAGCACCAAAAG',
+ -id => 'SA009');
my $aaseq = $ntseq->translate;
ok $result = $fac->blastn( -query => $ntseq ), "run blastn with Bio::Seq query";
@@ -211,31 +217,55 @@ SKIP : {
$fac->cleanup;
ok $fac = Bio::Tools::Run::StandAloneBlastPlus->new(
- -db_data => test_input_file('test-spa-p.fas'),
- -create => 1);
+ -db_data => test_input_file('test-spa-p.fas'),
+ -create => 1
+ );
ok $result = $fac->blastp( -query => $aaseq ), "run blastp";
is $result->num_hits, 222, "blastp hits";
$fac->cleanup;
- $sio = Bio::SeqIO->new(-file=>test_input_file('test-spa.fas'));
+ $sio = Bio::SeqIO->new(-file=>test_input_file('test-spa.fas'));
$sio->next_seq;
my $seq1 = $sio->next_seq;
my $seq2 = $sio->next_seq;
- ok $result = $fac->bl2seq( -method => 'blastn',
- -query => $seq1,
- -subject => $seq2 ), "bl2seq (blastn)";
+ ok $result = $fac->bl2seq(-method => 'blastn',
+ -query => $seq1,
+ -subject => $seq2
+ ), "bl2seq (blastn)";
+ is $result->num_hits, 1, "got hit";
+
+ ok $result = $fac->bl2seq(-method => 'tblastx',
+ -query => $seq1,
+ -subject => $seq2
+ ), "bl2seq (tblastx)";
is $result->num_hits, 1, "got hit";
- ok $result = $fac->bl2seq( -method => 'blastx',
- -query => $seq1,
- -subject => $seq2 ), "bl2seq (blastx)";
+
+ $seq2 = $seq2->translate(-frame => 1);
+ ok $result = $fac->bl2seq(-method => 'blastx',
+ -query => $seq1,
+ -subject => $seq2
+ ), "bl2seq (blastx)";
is $result->num_hits, 1, "got hit";
- $seq1 = $seq1->translate;
- $seq2 = $seq2->translate;
- ok $result = $fac->bl2seq( -method => 'blastp',
- -query => $seq1,
- -subject => $seq2 ), "bl2seq (blastp)";
+
+ # There is no similarity between the sequences
+ # at these reading frames, so there should be no hits
+ my $seq1_frame0 = $seq1->translate;
+ ok $result = $fac->bl2seq(-method => 'blastp',
+ -query => $seq1_frame0,
+ -subject => $seq2
+ ), "bl2seq (blastp)";
+ is $result->num_hits, 0, "no hit";
+
+ # There is similarity between the sequences
+ # at these reading frames, so there should be hits
+ $seq1 = $seq1->translate(-frame => 2);
+ ok $result = $fac->bl2seq(-method => 'blastp',
+ -query => $seq1,
+ -subject => $seq2
+ ), "bl2seq (blastp)";
is $result->num_hits, 1, "got hit";
+
$fac->cleanup;
} # SKIP to here

0 comments on commit 864e2b6

Please sign in to comment.