Supply TEMPLATE and SUFFIX for temporary query sequence files.
[bioperl-run.git] / t / MCS.t
blobd4e6312a29a7a03b9a344eb7f1afb6b9bbed619e
1 use strict;
3 BEGIN {
4     use Bio::Root::Test;
6     test_begin(-tests => 24,
7                -requires_modules => [qw(Config::Any)]);
9     use_ok('Bio::Tools::Run::MCS');
10     use_ok('Bio::SeqFeature::Annotated');
11     use_ok('Bio::Location::Atomic');
14 # setup input files etc
15 my $alignfilename = test_input_file('gumby', 'hmrd.mfa');
16 ok (-e $alignfilename, 'Found input alignment file');
18 my $factory = Bio::Tools::Run::MCS->new(-verbose => -1,
19                                         -quiet => 1);
20 isa_ok($factory, 'Bio::Tools::Run::MCS');
21 ok $factory->can('neutral'), 'has a created method not in args supplied to new';
22 is $factory->quiet, 1, 'quiet was set';
24 # test default factory values
25 is ($factory->program_dir, $ENV{'MCSDIR'}, 'program_dir returned correct default');
26 is ($factory->program_name(), 'align2binomial.pl', 'Correct exe default name');
28 # test the program itself
29 SKIP: {
30     test_skip(-requires_executable => $factory,
31               -tests => 15);
33     my $alignio = Bio::AlignIO->new(-file => $alignfilename);
34     my $align = $alignio->next_aln;
36     my @cds_feats;
37     foreach my $data ([47367820, 47367830], [47367850, 47367860], [47367870, 47367880]) {
38         my $cds_feat = Bio::SeqFeature::Annotated->new(
39                 -seq_id       => 'Homo_sapiens',
40                 -start        => $data->[0],
41                 -end          => $data->[1],
42                 -frame        => 0,
43                 -strand       => 1,
44                 -primary      => 'CDS',
45                 -type         => 'CDS',
46                 -source       => 'UCSC');
47         push(@cds_feats, $cds_feat);
48     }
49     my $location = Bio::Location::Atomic->new(-start => 47367748, -end => 47427851, -strand => 1, -seq_id => 'chr1');
51     # run the program
52     my @feats = $factory->run($align, $location, \@cds_feats);
54     # spot-test the results
55     my @spot_results = ($feats[0], $feats[1], $feats[2]);
56     foreach my $expected ([47373765, 47373846, 1000],
57                           [47373848, 47373883, 1000],
58                           [47377883, 47377908, 1000]) {
59         my $feat = shift(@spot_results);
60         isa_ok $feat, 'Bio::SeqFeature::Annotated';
61         is $feat->source->value, 'MCS', 'correct source';
62         is $feat->start, shift(@{$expected}), 'feature start correct';
63         is $feat->end, shift(@{$expected}), 'feature end correct';
64         is $feat->score, shift(@{$expected}), 'feature score correct';
65     }