1#!/bin/sh
2# test for fastadiff utility
3
4FASTAREVCOMP="../../src/util/fastarevcomp"
5FASTADIFF="../../src/util/fastadiff"
6FASTALENGTH="../../src/util/fastalength"
7CALM="../data/cdna/calm.human.dna.fasta"
8CALM_RC="fastarevcomp.rc.test.fasta"
9CALM_RCRC="fastarevcomp.rc.rc.test.fasta"
10
11clean_exit(){
12    rm -f $CALM_RC $CALM_RCRC
13    exit $1
14    }
15
16run_revcomp(){
17    $FASTAREVCOMP $1 > $2
18    if [ $? -eq 0 ]
19    then
20        echo Reverse complement created : $1
21    else
22        echo Problem generating reverse complement : $1
23        clean_exit 1
24    fi
25    }
26
27run_revcomp $CALM $CALM_RC
28run_revcomp $CALM_RC $CALM_RCRC
29
30check_length(){
31    $FASTALENGTH $1 | (read LENGTH IDENTIFIER
32        if [ $LENGTH -eq 2175 ]
33        then
34            echo RC length is the same
35        else
36            echo RC length changed
37            clean_exit 1
38        fi
39        )
40    return
41    }
42
43check_length $CALM_RC
44check_length $CALM_RCRC
45
46$FASTADIFF -c no $CALM $CALM_RCRC
47if [ $? -eq 0 ]
48then
49    echo 2nd reverse complement same as original
50else
51    echo 2nd reverse complement not same as original
52    clean_exit 1
53fi
54
55clean_exit 0
56
57