modified: src1/input.c
[GalaxyCodeBases.git] / c_cpp / lib / htslib / test / cross_validate.sh
blob226f13f46a0f93fdbd105f7255c3d18a7aeef97c
1 #!/bin/sh
4 # -----------------------------------------------------------------------------
5 # Author: James Bonfield.
7 # This cross validation script is designed to run the htslib test_view
8 # and cramtools.jar CRAM implementations to test compatibility between
9 # implementations.
11 # The test set may contain many dubious and ambiguous SAM cases, such as
12 # single base reads (is that quality "*" really meaning Q9 or no quality?).
13 # Some of these may fail one or the other implementations and be acceptable
14 # in the short-term, so to spot more important regressions we can tag
15 # specific cases as being known-pass or known-fail.
16 # -----------------------------------------------------------------------------
19 vers=3.0
21 cramtools_jar=$HOME/work/cram/cramtools/cramtools-$vers.jar
23 test_view="./test_view -o VERSION=$vers"
25 cramtools="/software/bin/java -Xmx4000m -jar $cramtools_jar"
26 cramtools="/software/bin/java -Xmx4000m -jar $cramtools_jar"
28 run_out() {
29 out=$1; shift
30 echo "$@ > $out"
31 $@ > $out
34 run() {
35 echo "$@"
40 sam_to_Ccram() {
41 run_out _tmp.cram $test_view -C -t $1 $2
42 #run_out _tmp.cram $HOME/io_lib/trunk/build.seq3/progs/scramble -r $1 -O CRAM $2
43 if [ $? != 0 ]
44 then
45 crash=`expr $crash + 1`
46 false
50 Ccram_to_sam() {
51 run_out _tmp.sam $test_view -i REFERENCE=$1 _tmp.cram
52 #run_out _tmp.sam $HOME/io_lib/trunk/build.seq3/progs/scramble -r $1 _tmp.cram
54 if [ $? != 0 ]
55 then
56 crash=`expr $crash + 1`
57 false
61 sam_to_Jcram() {
62 run $cramtools cram -R $1 -I $2 -O _tmp.cram -n -Q --capture-all-tags
63 if [ $? != 0 ]
64 then
65 crash=`expr $crash + 1`
66 false
70 Jcram_to_sam() {
71 run $cramtools bam -R $1 -I _tmp.cram -O _tmp.sam
73 if [ $? != 0 ]
74 then
75 crash=`expr $crash + 1`
76 false
80 compare_sam() {
81 #run ./compare_sam.pl $i _tmp.sam -nomd -notemplate -unknownrg -Baux
82 run ./compare_sam.pl $i _tmp.sam -nomd -Baux
83 if [ $? != 0 ]
84 then
85 fails=`expr $fails + 1`
86 false
90 trials=0
91 fails=0
92 crash=0
94 files=`ls -1 *#*.sam`
96 # Restrict to known workers from SAM->CRAM->CRAM in cramtools
97 #files="auxf#values.sam c1#bounds.sam c1#noseq.sam c1#pad1.sam c1#pad2.sam c1#pad3.sam c1#unknown.sam ce#1.sam ce#2.sam ce#5b.sam ce#large_seq.sam ce#tag_depadded.sam ce#tag_padded.sam ce#unmap.sam ce#unmap1.sam ce#unmap2.sam xx#large_aux.sam xx#large_aux2.sam xx#pair.sam xx#rg.sam xx#unsorted.sam"
99 for i in $files
101 r=`echo $i | sed 's/#.*/.fa/'`
102 echo "=== $i"
104 # C to C
105 trials=`expr $trials + 1`
106 sam_to_Ccram $r $i && Ccram_to_sam $r && compare_sam $i _tmp.sam
108 # Java to Java
109 trials=`expr $trials + 1`
110 sam_to_Jcram $r $i && Jcram_to_sam $r && compare_sam $i _tmp.sam
112 # C to Java
113 trials=`expr $trials + 1`
114 sam_to_Ccram $r $i && Jcram_to_sam $r && compare_sam $i _tmp.sam
116 # Java to C
117 trials=`expr $trials + 1`
118 sam_to_Jcram $r $i && Ccram_to_sam $r && compare_sam $i _tmp.sam
119 done
121 # Overcounts failures as an early fail can lead to 1 or 2 more fails.
122 echo ""
123 echo ============
124 echo No. tests: $trials
125 echo No. diffs: $fails
126 echo No. crash: $crash