Debian Codegraph @

t/19-gene-copy-bias.t

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #! perl
2
3 use strict;
4 use warnings;
5 use Test::More;
6 use t::TestUtils;
7 use Grinder;
8
9
10
11 my ($factory, $nof_reads, $read, %sources);
12
13
14 # Specified genome abundance for a single library, no copy bias
15
16 ok $factory = Grinder->new(
17 -abundance_file => data('abundances2.txt') ,
18 -reference_file => data('multiple_amplicon_database.fa'),
19 -forward_reverse => data('forward_reverse_primers.fa') ,
20 -copy_bias => 0 ,
21 -unidirectional => 1 ,
22 -read_dist => 48 ,
23 -random_seed => 1910567890 ,
24 -total_reads => 1000 ,
25 ), 'Genome abundance for a single libraries';
26
27 while ( $read = $factory->next_read ) {
28 my $source = $read->reference->id;
29 # Strip amplicon sources of the 'amplicon' part
30 $source =~ s/_amplicon.*$//;
31 if (not exists $sources{$source}) {
32 $sources{$source} = 1;
33 } else {
34 $sources{$source}++;
35 }
36 };
37
38 ok exists $sources{'seq1'};
39 ok exists $sources{'seq2'};
40 ok exists $sources{'seq3'};
41
42
43 # These tests are quite sensitive to the seed used. Ideal average answer should
44 # be 600, 300 and 100
45 between_ok( $sources{'seq1'}, 580, 620 );
46 between_ok( $sources{'seq2'}, 280, 320 );
47 between_ok( $sources{'seq3'}, 80, 120 );
48
49 is $factory->next_lib, undef;
50 %sources = ();
51
52
53 # Specified genome abundance for a single library
54
55 ok $factory = Grinder->new(
56 -abundance_file => data('abundances2.txt') ,
57 -reference_file => data('multiple_amplicon_database.fa'),
58 -forward_reverse => data('forward_reverse_primers.fa') ,
59 -copy_bias => 1 ,
60 -unidirectional => 1 ,
61 -read_dist => 48 ,
62 -random_seed => 1910567890 ,
63 -total_reads => 1000 ,
64 ), 'Genome abundance for a single libraries';
65
66 while ( $read = $factory->next_read ) {
67 my $source = $read->reference->id;
68 # Strip amplicon sources of the 'amplicon' part
69 $source =~ s/_amplicon.*$//;
70 if (not exists $sources{$source}) {
71 $sources{$source} = 1;
72 } else {
73 $sources{$source}++;
74 }
75 };
76
77 ok exists $sources{'seq1'};
78 ok exists $sources{'seq2'};
79 ok exists $sources{'seq3'};
80
81
82 # These tests are quite sensitive to the seed used. Ideal average answer should
83 # be 387.1, 580.6 and 32.3
84 between_ok( $sources{'seq1'}, 367, 407 );
85 between_ok( $sources{'seq2'}, 560, 600 );
86 between_ok( $sources{'seq3'}, 12, 52 );
87
88 is $factory->next_lib, undef;
89 %sources = ();
90
91 done_testing();