| 1 |
#!/usr/bin/env perl |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use File::Temp; |
| 5 |
|
| 6 |
BEGIN { unshift( @INC, './lib' ) } |
| 7 |
BEGIN { unshift( @INC, '../lib' ) } |
| 8 |
|
| 9 |
BEGIN { |
| 10 |
use Test::Most; |
| 11 |
use_ok('Bio::Tradis::Parser::Cigar'); |
| 12 |
} |
| 13 |
|
| 14 |
my ( $obj, $fastqfile ); |
| 15 |
|
| 16 |
my @cigar_tests = ( |
| 17 |
{ |
| 18 |
name => 'all matching', |
| 19 |
cigar => '100M', |
| 20 |
coord => 100, |
| 21 |
start => 100, |
| 22 |
end => 199, |
| 23 |
}, |
| 24 |
{ |
| 25 |
name => 'nothing matching', |
| 26 |
cigar => '*', |
| 27 |
coord => 1000, |
| 28 |
start => 0, |
| 29 |
end => 0, |
| 30 |
}, |
| 31 |
{ |
| 32 |
name => 'soft clipping at start', |
| 33 |
cigar => '10S90M', |
| 34 |
coord => 100, |
| 35 |
start => 110, |
| 36 |
end => 199, |
| 37 |
}, |
| 38 |
{ |
| 39 |
name => 'soft clipping at end', |
| 40 |
cigar => '90M10S', |
| 41 |
coord => 100, |
| 42 |
start => 100, |
| 43 |
end => 189, |
| 44 |
}, |
| 45 |
{ |
| 46 |
name => 'soft clipping at both ends', |
| 47 |
cigar => '10S80M10S', |
| 48 |
coord => 100, |
| 49 |
start => 110, |
| 50 |
end => 189, |
| 51 |
}, |
| 52 |
{ |
| 53 |
name => 'deletion in middle', |
| 54 |
'cigar' => '20M1D80M', |
| 55 |
'coord' => 20, |
| 56 |
'end' => 120, |
| 57 |
'start' => 20 |
| 58 |
}, |
| 59 |
{ |
| 60 |
name => 'insertions and deletions', |
| 61 |
'cigar' => '27M1I6M1D66M', |
| 62 |
'coord' => 46, |
| 63 |
'end' => 145, |
| 64 |
'start' => 46 |
| 65 |
}, |
| 66 |
{ |
| 67 |
name => 'insertions in the middle', |
| 68 |
'cigar' => '90M1I9M', |
| 69 |
'coord' => 80, |
| 70 |
'end' => 178, |
| 71 |
'start' => 80 |
| 72 |
} |
| 73 |
|
| 74 |
); |
| 75 |
|
| 76 |
for my $cigar_test (@cigar_tests) { |
| 77 |
ok( $obj = Bio::Tradis::Parser::Cigar->new( coordinate => $cigar_test->{coord}, cigar => $cigar_test->{cigar} ), |
| 78 |
'initialise obj -' . $cigar_test->{name} ); |
| 79 |
is( $obj->start, $cigar_test->{start}, 'read start -' . $cigar_test->{name} ); |
| 80 |
is( $obj->end, $cigar_test->{end}, 'read end -' . $cigar_test->{name} ); |
| 81 |
} |
| 82 |
|
| 83 |
done_testing(); |