1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 66);
12 use_ok('Bio::Tools::TandemRepeatsFinder');
15 # first, open empty output file
16 # make sure no results get returned
18 Bio::Tools::TandemRepeatsFinder->new( -file => test_input_file('tandem_repeats_finder.noresults')
20 ok $trf,"Parser created successfully" ;
21 my $feat = $trf->next_result;
22 ok( !defined($feat), "empty results file correctly returns no results" );
25 # now check some results
27 Bio::Tools::TandemRepeatsFinder->new( -file => test_input_file('tandem_repeats_finder.dat')
29 ok $trf,"Second parser created successfully" ;
30 my $feat1 = $trf->next_result();
32 # these are the parameters that should be parsed from
34 # Parameters: 2 7 7 80 10 50 12
35 my $expected_run_parameters = {
45 # test feature properties
46 is ( $feat1->seq_id(), "DDB0169550", "seq_id for first result correctly parsed");
47 is ( $feat1->start(), 13936, "start for first result correctly parsed");
48 is ( $feat1->end(), 13960, "end for first result correctly parsed");
49 is ( $feat1->source_tag(), 'Tandem Repeats Finder', "source tag for first result correctly parsed");
50 is ( $feat1->primary_tag(), 'tandem repeat', "primary tag for first result correctly parsed");
51 is ( $feat1->score(), 50, "score for first result correctly parsed");
54 # all of the data other than start, end, score, and seq_id
56 my ($seqence_description) = $feat1->get_tag_values( 'sequence_description' );
57 is ( $seqence_description, "|Masked Chromosomal Sequence| on chromosome: M", "sequence description correctly parsed.");
58 my ($parameters) = $feat1->get_tag_values( 'run_parameters' );
59 is_deeply ( $parameters, $expected_run_parameters ,"correctly parsed all run parameters");
60 my ($period_size) = $feat1->get_tag_values( 'period_size' );
61 is ( $period_size, 12 ,"correctly parsed period_size for first result");
62 my ($copy_number) = $feat1->get_tag_values( 'copy_number' );
63 is ( $copy_number, 2.1 ,"correctly parsed copy_number for first result");
64 my ($consensus_size) = $feat1->get_tag_values( 'consensus_size' );
65 is ( $consensus_size, 12 ,"correctly parsed consensus_size for first result");
66 my ($percent_matches) = $feat1->get_tag_values( 'percent_matches' );
67 is ( $percent_matches, 100 ,"correctly parsed percent_matches for first result");
68 my ($percent_indels) = $feat1->get_tag_values( 'percent_indels' );
69 is ( $percent_indels, 0 ,"correctly parsed percent_indels for first result");
70 my ($percent_a) = $feat1->get_tag_values( 'percent_a' );
71 is ( $percent_a, 16 ,"correctly parsed percent_a for first result");
72 my ($percent_c) = $feat1->get_tag_values( 'percent_c' );
73 is ( $percent_c, 8 ,"correctly parsed percent_c for first result");
74 my ($percent_g) = $feat1->get_tag_values( 'percent_g' );
75 is ( $percent_g, 52 ,"correctly parsed percent_g for first result");
76 my ($percent_t) = $feat1->get_tag_values( 'percent_t' );
77 is ( $percent_t, 24 ,"correctly parsed percent_t for first result");
78 my ($entropy) = $feat1->get_tag_values( 'entropy' );
79 is ( $entropy, "1.70", "correctly parsed entropy for first result");
80 my ($repeat_sequence) = $feat1->get_tag_values( 'repeat_sequence' );
81 is ( $repeat_sequence, "GGCGTAATGGGTGGCGTAATGGGTG", "correctly parsed repeat_sequence for first result");
82 my ($consensus_sequence) = $feat1->get_tag_values( 'consensus_sequence' );
83 is ( $consensus_sequence, "GGCGTAATGGGT", "correctly parsed consensus_sequence for first result");
85 # for the next result just check the sequence _id, start, and end
86 my $feat2 = $trf->next_result();
87 is ( $feat2->seq_id(), "DDB0169550", "seq_id for second result correctly parsed");
88 is ( $feat2->start(), "16937", "start for second result correctly parsed");
89 is ( $feat2->end(), "16965", "end for second result correctly parsed");
90 is ( $feat2->source_tag(), 'Tandem Repeats Finder', "source tag for first result correctly parsed");
91 is ( $feat2->primary_tag(), 'tandem repeat', "primary tag for first result correctly parsed");
92 is ( $feat2->score(), 58, "score for first result correctly parsed");
95 # all of the data other than start, end, score, and seq_id
97 ($seqence_description) = $feat2->get_tag_values( 'sequence_description' );
98 is ( $seqence_description, "|Masked Chromosomal Sequence| on chromosome: M", "sequence description correctly parsed.");
100 ($parameters) = $feat2->get_tag_values( 'run_parameters' );
101 is_deeply ( $parameters, $expected_run_parameters ,"correctly reatained all run parameters for second feature");
102 ($period_size) = $feat2->get_tag_values( 'period_size' );
103 is ( $period_size, 9 ,"correctly parsed period_size for second result");
104 ($copy_number) = $feat2->get_tag_values( 'copy_number' );
105 is ( $copy_number, "3.2" ,"correctly parsed copy_number for second result");
106 ($consensus_size) = $feat2->get_tag_values( 'consensus_size' );
107 is ( $consensus_size, 9 ,"correctly parsed consensus_size for second result");
108 ($percent_matches) = $feat2->get_tag_values( 'percent_matches' );
109 is ( $percent_matches, 100 ,"correctly parsed percent_matches for second result");
110 ($percent_indels) = $feat2->get_tag_values( 'percent_indels' );
111 is ( $percent_indels, 0 ,"correctly parsed percent_indels for second result");
112 ($percent_a) = $feat2->get_tag_values( 'percent_a' );
113 is ( $percent_a, 44 ,"correctly parsed percent_a for second result");
114 ($percent_c) = $feat2->get_tag_values( 'percent_c' );
115 is ( $percent_c, 0 ,"correctly parsed percent_c for second result");
116 ($percent_g) = $feat2->get_tag_values( 'percent_g' );
117 is ( $percent_g, 10 ,"correctly parsed percent_g for second result");
118 ($percent_t) = $feat2->get_tag_values( 'percent_t' );
119 is ( $percent_t, 44 ,"correctly parsed percent_t for second result");
120 ($entropy) = $feat2->get_tag_values( 'entropy' );
121 is ( $entropy, "1.38", "correctly parsed entropy for second result");
122 ($repeat_sequence) = $feat2->get_tag_values( 'repeat_sequence' );
123 is ( $repeat_sequence, "TATATAGTATATATAGTATATATAGTATA", "correctly parsed repeat_sequence for second result");
124 ($consensus_sequence) = $feat2->get_tag_values( 'consensus_sequence' );
125 is ( $consensus_sequence, "TATATAGTA", "correctly parsed consensus_sequence for second result");
127 # now, check the full results again for last result (on a different sequence).
128 my $feat3 = $trf->next_result();
129 # test feature properties
130 is ( $feat3->seq_id(), "DDB0215018", "seq_id for first result correctly parsed");
131 is ( $feat3->start(), 1649, "start for first result correctly parsed");
132 is ( $feat3->end(), 1679, "end for first result correctly parsed");
133 is ( $feat3->source_tag(), 'Tandem Repeats Finder', "source tag for first result correctly parsed");
134 is ( $feat3->primary_tag(), 'tandem repeat', "primary tag for first result correctly parsed");
135 is ( $feat3->score(), 62, "score for first result correctly parsed");
138 # all of the data other than start, end, score, and seq_id
140 ($seqence_description) = $feat3->get_tag_values( 'sequence_description' );
141 is ( $seqence_description, "|Masked Chromosomal Sequence| on chromosome: 2F", "sequence description correctly parsed.");
143 ($parameters) = $feat3->get_tag_values( 'run_parameters' );
144 is_deeply ( $parameters, $expected_run_parameters ,"correctly reatained all run parameters for third feature");
145 ($period_size) = $feat3->get_tag_values( 'period_size' );
146 is ( $period_size, 1 ,"correctly parsed period_size for third result");
147 ($copy_number) = $feat3->get_tag_values( 'copy_number' );
148 is ( $copy_number, "31.0" ,"correctly parsed copy_number for third result");
149 ($consensus_size) = $feat3->get_tag_values( 'consensus_size' );
150 is ( $consensus_size, 1 ,"correctly parsed consensus_size for third result");
151 ($percent_matches) = $feat3->get_tag_values( 'percent_matches' );
152 is ( $percent_matches, 100 ,"correctly parsed percent_matches for third result");
153 ($percent_indels) = $feat3->get_tag_values( 'percent_indels' );
154 is ( $percent_indels, 0 ,"correctly parsed percent_indels for third result");
155 ($percent_a) = $feat3->get_tag_values( 'percent_a' );
156 is ( $percent_a, 0 ,"correctly parsed percent_a for third result");
157 ($percent_c) = $feat3->get_tag_values( 'percent_c' );
158 is ( $percent_c, 0 ,"correctly parsed percent_c for third result");
159 ($percent_g) = $feat3->get_tag_values( 'percent_g' );
160 is ( $percent_g, 0 ,"correctly parsed percent_g for third result");
161 ($percent_t) = $feat3->get_tag_values( 'percent_t' );
162 is ( $percent_t, 100 ,"correctly parsed percent_t for third result");
163 ($entropy) = $feat3->get_tag_values( 'entropy' );
164 is ( $entropy, "0.00", "correctly parsed entropy for third result");
165 ($repeat_sequence) = $feat3->get_tag_values( 'repeat_sequence' );
166 is ( $repeat_sequence, "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", "correctly parsed repeat_sequence for third result");
167 ($consensus_sequence) = $feat3->get_tag_values( 'consensus_sequence' );
168 is ( $consensus_sequence, "T", "correctly parsed consensus_sequence for third result");
170 my $empty_feat = $trf->next_result();
171 ok( !defined($empty_feat), "correctly return undef when no features are left" );
175 Bio::Tools::TandemRepeatsFinder->new( -file => test_input_file('tandem_repeats_finder_no_desc.dat')
178 my $feat_with_seqid = $trf->next_result();
179 #ensuring that we can parse out seq_id in the file even in the absent of description
180 is( $feat_with_seqid->seq_id(),"DDB0169550", "Correctly parsed seq_id even if description does not exist" );