1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#! perl
use strict;
use warnings;
use Test::More;
use lib '.';
use t::TestUtils;
use Grinder;
my ($factory, $nof_reads, $read, %sources);
# Specified genome abundance for a single shotgun library
ok $factory = Grinder->new(
-reference_file => data('shotgun_database_extended.fa'),
-abundance_file => data('abundances.txt') ,
-length_bias => 0 ,
-random_seed => 1910567890 ,
-total_reads => 1000 ,
), 'Genome abundance for a single shotgun libraries';
while ( $read = $factory->next_read ) {
my $source = $read->reference->id;
if (not exists $sources{$source}) {
$sources{$source} = 1;
} else {
$sources{$source}++;
}
};
ok exists $sources{'seq1'};
ok exists $sources{'seq2'};
ok not exists $sources{'seq3'};
ok exists $sources{'seq4'};
ok exists $sources{'seq5'};
# These tests are quite sensitive to the seed used. Ideal average answer should
# be 250 here
between_ok( $sources{'seq1'}, 230, 280 );
between_ok( $sources{'seq2'}, 230, 280 );
between_ok( $sources{'seq4'}, 230, 280 );
between_ok( $sources{'seq5'}, 230, 280 );
is $factory->next_lib, undef;
%sources = ();
# Specified genome abundance for a single amplicon library
ok $factory = Grinder->new(
-abundance_file => data('abundances2.txt') ,
-reference_file => data('amplicon_database.fa') ,
-forward_reverse => data('forward_reverse_primers.fa'),
-copy_bias => 0 ,
-unidirectional => 1 ,
-read_dist => 48 ,
-random_seed => 1910567890 ,
-total_reads => 1000 ,
), 'Genome abundance for a single amplicon libraries';
while ( $read = $factory->next_read ) {
my $source = $read->reference->id;
# Strip amplicon sources of the 'amplicon' part
$source =~ s/_amplicon.*$//;
if (not exists $sources{$source}) {
$sources{$source} = 1;
} else {
$sources{$source}++;
}
};
ok exists $sources{'seq1'};
ok exists $sources{'seq2'};
ok exists $sources{'seq3'};
# These tests are quite sensitive to the seed used. Ideal average answer should
# be 600, 300 and 100 here
between_ok( $sources{'seq1'}, 570, 630 );
between_ok( $sources{'seq2'}, 270, 330 );
between_ok( $sources{'seq3'}, 70 , 130 );
is $factory->next_lib, undef;
%sources = ();
# Specified genome abundance for multiple shotgun libraries
ok $factory = Grinder->new(
-reference_file => data('shotgun_database_extended.fa'),
-abundance_file => data('abundances_multiple.txt') ,
-length_bias => 0 ,
-random_seed => 1232567890 ,
-total_reads => 1000 ,
), 'Genome abundance for multiple shotgun libraries';
ok $factory->next_lib;
$nof_reads = 0;
while ( $read = $factory->next_read ) { $nof_reads++ };
is $nof_reads, 1000;
ok $factory->next_lib;
ok $factory->next_lib;
while ( $read = $factory->next_read ) {
my $source = $read->reference->id;
if (not exists $sources{$source}) {
$sources{$source} = 1;
} else {
$sources{$source}++;
}
};
ok not exists $sources{'seq1'};
ok not exists $sources{'seq2'};
ok exists $sources{'seq3'};
ok not exists $sources{'seq4'};
ok not exists $sources{'seq5'};
is $sources{'seq3'}, 1000;
is $factory->next_lib, undef;
done_testing();
|