9 $home = '.'; # set to '.' for Build use,
10 # '..' for debugging from .t file
13 test_begin(-tests => 36,
14 -requires_modules => [qw(IPC::Run Bio::Tools::Run::Samtools)]);
18 use Bio::Tools::Run::WrapperBase;
20 ok my $samt = Bio::Tools::Run::Samtools->new(
24 ), "make a factory using command 'pileup'";
25 # ParameterBaseI compliance : really AssemblerBase tests...
26 ok $samt->parameters_changed, "parameters changed on construction";
27 ok $samt->refseq, "access parameter";
28 ok !$samt->parameters_changed, "parameters_changed cleared on read";
29 ok $samt->set_parameters( -n_haplos => 4 ), "set a param not set in constructor";
30 ok $samt->parameters_changed, "parameters_changed set";
31 is ($samt->n_haplos, 4, "parameter really set");
32 is ($samt->refseq, 'my.fas', "original parameter unchanged");
33 ok !$samt->parameters_changed, "parameters_changed cleared on read";
34 ok $samt->set_parameters( -refseq => 'their.fas' ), "change an original parameter";
35 is ($samt->refseq, 'their.fas', "parameter really changed");
36 ok $samt->reset_parameters( -refseq => 'our.fas' ), "reset parameters with arg";
37 ok !$samt->theta, "original parameters undefined";
38 is ($samt->refseq, 'our.fas', "parameter really reset via arg");
40 $samt->set_parameters(
45 ok $samt->parameters_changed, "parameters changed";
47 is( scalar $samt->available_parameters, 14, "all available options");
48 is( scalar $samt->available_parameters('params'), 9, "available parameters" );
49 is( scalar $samt->available_parameters('switches'), 5, "available switches" );
50 my %pms = $samt->get_parameters;
52 { command => 'pileup',
54 theta => 0.05 }, "get_parameters correct");
55 is( $samt->command, 'pileup', "command attribute set");
57 is_deeply( $samt->{_options}->{_commands},
58 [@Bio::Tools::Run::Samtools::program_commands],
59 "internal command array set" );
61 is_deeply( $samt->{_options}->{_prefixes},
62 {%Bio::Tools::Run::Samtools::command_prefixes},
63 "internal prefix hash set");
65 is_deeply( $samt->{_options}->{_params},
66 [qw( command refseq map_qcap ref_list site_list theta n_haplos exp_hap_diff indel_prob )],
67 "commands filtered by prefix");
68 is( join(' ', @{$samt->_translate_params}),
69 "pileup -T 0.05 -f my.fas", "translate params" );
74 test_skip( -requires_executable => $samt,
77 for (qw(refseq bamfile samfile rtbamfile fai bai)) {
78 $tmpfiles{$_} = test_output_file();
80 copy(test_input_file('Ft.bam'), $tmpfiles{bamfile}) or die "copy failed (1)";
81 copy(test_input_file('Ft.frag.fas'), $tmpfiles{refseq}) or die "copy failed (2)";
82 ok $samt = Bio::Tools::Run::Samtools->new( -command => 'faidx' ), "fasta index factory";
83 ok $samt->run( -fas => $tmpfiles{refseq}, -out => $tmpfiles{fai}), "make fasta index";
84 ok -e $tmpfiles{fai}, "fai file present";
85 ok $samt = Bio::Tools::Run::Samtools->new( -command => 'view' ), "bam -> sam cvt factory";
87 ok $samt->run( -bam => $tmpfiles{bamfile}, -out => $tmpfiles{samfile} ), "convert bam -> sam";
88 ok -T $tmpfiles{samfile}, "sam file present and text";
89 ok $samt->set_parameters( -sam_input => 1, -bam_output => 1, -refseq => $tmpfiles{refseq} ), "sam -> bam cvt factory";
90 ok $samt->run( -bam => $tmpfiles{samfile}, -out => $tmpfiles{rtbamfile} ), "convert sam -> bam";
91 ok -B $tmpfiles{rtbamfile}, "bam file present and binary";
92 ok $samt = Bio::Tools::Run::Samtools->new( -command => 'index' ), 'bam index factory';
93 ok $samt->run( -bam => $tmpfiles{rtbamfile}, -out => $tmpfiles{bai}), 'make bam index';
94 ok -B $tmpfiles{bai}, 'bai file present and binary';