comparison ezBAMQC/src/htslib/test/test_view.pl @ 0:dfa3745e5fd8

Uploaded
author youngkim
date Thu, 24 Mar 2016 17:12:52 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:dfa3745e5fd8
1 #! /usr/bin/env perl
2 #
3 # Copyright (C) 2013 Genome Research Ltd.
4 #
5 # Author: James Bonfield <jkb@sanger.ac.uk>
6 #
7 # Permission is hereby granted, free of charge, to any person obtaining a copy
8 # of this software and associated documentation files (the "Software"), to deal
9 # in the Software without restriction, including without limitation the rights
10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 # copies of the Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
13 #
14 # The above copyright notice and this permission notice shall be included in
15 # all copies or substantial portions of the Software.
16 #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 # DEALINGS IN THE SOFTWARE.
24 use strict;
25 use warnings;
26
27 my $err_count = 0;
28 my $suc_count = 0;
29
30 sub test {
31 my ($cmd) = @_;
32 print " $cmd\n";
33 if (system("$cmd || exit 1") != 0) {
34 print "FAIL $!\n";
35 $err_count++;
36 } else {
37 $suc_count++;
38 }
39 }
40
41 foreach my $sam (glob("*#*.sam")) {
42 my ($base, $ref) = ($sam =~ /((.*)#.*)\.sam/);
43 $ref .= ".fa";
44
45 my $bam = "$base.tmp.bam";
46 my $cram = "$base.tmp.cram";
47
48 print "\n=== Testing $sam, ref $ref ===\n";
49
50 # SAM -> BAM -> SAM
51 test "./test_view -S -b $sam > $bam";
52 test "./test_view $bam > $bam.sam_";
53 test "./compare_sam.pl $sam $bam.sam_";
54
55 # SAM -> CRAM -> SAM
56 test "./test_view -t $ref -S -C $sam > $cram";
57 test "./test_view -D $cram > $cram.sam_";
58 test "./compare_sam.pl -nomd $sam $cram.sam_";
59
60 # BAM -> CRAM -> BAM -> SAM
61 $cram = "$bam.cram";
62 test "./test_view -t $ref -C $bam > $cram";
63 test "./test_view -b -D $cram > $cram.bam";
64 test "./test_view $cram.bam > $cram.bam.sam_";
65 test "./compare_sam.pl -nomd $sam $cram.bam.sam_";
66 }
67
68 print "\nSuccesses $suc_count\n";
69 print "\nFailures $err_count\n";
70
71 exit ($err_count > 0);