Debian Codegraph @

t/19-gene-copy-bias.t

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