summaryrefslogtreecommitdiff
path: root/debian/tests/run-unit-test
blob: f78cfa30401abbcdd3b680f24b5d1035b63839bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
set -e

pkg="ncbi-tools-bin"

if [ "$AUTOPKGTEST_TMP" = "" ] ; then
    AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
    trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
fi
cd $AUTOPKGTEST_TMP
cp -a /usr/share/doc/${pkg}/test-data/* .
cp /usr/share/doc/${pkg}/{asnpub.all.gz,medline.ent} .
cp /usr/share/ncbi/data/autofix.prt .
cp /usr/share/ncbi/data/UniVec.* .
gunzip *.gz

check_GI()
{
	while read GI; do
		grep -q $GI $1
	done < $2
}

##################################################################
echo '---asn2asn test---'
##################################################################
/usr/bin/asn2asn -i nc0225.aso -b -o nc0225.text
/usr/bin/asn2asn -i nc0225.text -s -o nc0225_new.aso
[ -s nc0225.text ]
[ -s nc0225_new.aso ]
diff nc0225.aso nc0225_new.aso
rm nc0225.aso nc0225_new.aso

##################################################################
echo '---asn2all test---'
##################################################################
/usr/bin/asn2all -i nc0225.text -f g -o nc0225.nuc -v nc0225.prt
[ -s nc0225.nuc ]
genes_dna="$(grep -c " mol dna ," nc0225.text)"
genes_rna="$(grep -c " mol rna ," nc0225.text)"
genes=$(expr $genes_dna + $genes_rna)
nuc="$(grep -c "^LOCUS " nc0225.nuc)"
[ $genes -eq $nuc ]
[ -s nc0225.prt ]
proteins="$(grep -c " mol aa ," nc0225.text)"
prt="$(grep -c "^LOCUS " nc0225.prt)"
[ $proteins -eq $prt ]

##################################################################
echo '---asn2fsa test---'
##################################################################
/usr/bin/asn2fsa -i nc0225.text -a t -o nc0225.fna -v nc0225.faa
[ -s nc0225.fna ]
fna="$(grep -c "^>" nc0225.fna)"
[ $genes -eq $fna ]
[ -s nc0225.faa ]
faa="$(grep -c "^>" nc0225.faa)"
[ $proteins -eq $faa ]

##################################################################
echo '---asn2gb test---'
##################################################################
/usr/bin/asn2gb -i nc0225.text -a t -o nc0225.gbk
[ -s nc0225.gbk ]
gbk="$(grep -c "^LOCUS " nc0225.gbk)"
[ $genes -eq $gbk ]

##################################################################
echo '---asn2idx test---'
##################################################################
/usr/bin/asn2idx -p . -x .text < nc0225.text
[ -s nc0225.idx ]
[ -s master.idx ]
awk 'NR == 1 || NR % 50 == 0 {print $1}' nc0225.idx | sed 's/\.1//' > indexed_GIs
check_GI nc0225.text indexed_GIs

##################################################################
echo '---asn2xml test---'
##################################################################
/usr/bin/asn2xml -i nc0225.text -b F -o nc0225.xml
[ -s nc0225.xml ]
dna_xml="$(grep -c '<Seq-inst_mol value="dna"/>' nc0225.xml)"
rna_xml="$(grep -c '<Seq-inst_mol value="rna"/>' nc0225.xml)"
proteins_xml="$(grep -c '<Seq-inst_mol value="aa"/>' nc0225.xml)"
[ $genes -eq $(expr $dna_xml + $rna_xml) ]
[ $proteins -eq $proteins_xml ]

##################################################################
echo '---cleanasn test---'
##################################################################
/usr/bin/cleanasn -a t -D t -i nc0225.text -o nc0225_cleaned.text
[ -s nc0225_cleaned.text ]
titles="$(grep -c " title \"" nc0225.text)"
titles_to_clean="$(grep -A 1 " descr {$" nc0225.text | grep -c " title \"")"
titles_left="$(grep -c " title \"" nc0225_cleaned.text)"
[ $(expr $titles - $titles_to_clean) -eq $titles_left ]

##################################################################
echo '---gene2xml test---'
##################################################################
/usr/bin/gene2xml -b -i dsRNA_viruses.ags -o dsRNA_viruses.xgs
[ -s dsRNA_viruses.xgs ]
# The content in dsRNA_viruses.gene_info mirrors the content in dsRNA_viruses.ags
first_id="$(awk 'NR==2{print $1}' dsRNA_viruses.gene_info)"
last_id="$(awk 'END{print $1}' dsRNA_viruses.gene_info)"
# check the beginning of the output
start_in="$(grep -c "^${first_id}" dsRNA_viruses.gene_info)"
start_out="$(grep -c "<Object-id_id>${first_id}</Object-id_id>" dsRNA_viruses.xgs)"
[ $start_in -eq $start_out ]
#check the ending of the output
end_in="$(grep -c "^${last_id}" dsRNA_viruses.gene_info)"
end_out="$(grep -c "<Object-id_id>${last_id}</Object-id_id>" dsRNA_viruses.xgs)"
[ $end_in -eq $end_out ]


## _insdseqget_ and _idfetch_ testing requires internet connection.
## Uncomment the lines below to run the tests provided.
#grep 'GI:' nc0225.gbk | head | sed 's/.*GI://' > GIs.txt
###################################################################
#echo '---insdseqget test---'
###################################################################
#/usr/bin/insdseqget -i GIs.txt > insdset.xml
#[ -s insdset.xml ]
#check_GI insdset.xml GIs.txt
###################################################################
#echo '---idfetch test---'
###################################################################
#/usr/bin/idfetch -G GIs.txt -o idfetch.text
#[ -s idfetch.text ]
#check_GI idfetch.text GIs.txt


##################################################################
echo '---vecscreen test---'
##################################################################
/usr/bin/vecscreen -f 3 < nc0225.fna > vecscreen.output
[ -s vecscreen.output ]
last_in="$(grep ">" nc0225.fna | tail -1 | sed 's/>//' | sed 's/ .*//')"
last_out="$(grep ">" vecscreen.output | tail -1 | sed 's/>Vector //' | sed 's/ .*//')"
[ $last_in==$last_out ]


echo '---asndisc test---'
/usr/bin/asndisc -i nc0225.text -a t -o nc0225.disc
[ -s nc0225.disc ]

echo '---asnval test---'
/usr/bin/asnval -i nc0225.text -a t -o nc0225.val -Q 2
[ -s nc0225.val ]

echo '---asnmacro test---'
/usr/bin/asnmacro -i nc0225.text -m autofix.prt -o asnmacro.output
[ -s asnmacro.output ]

echo '---asntool test---'
/usr/bin/asntool -m asnpub.all -v medline.ent -p asntool.output
[ -s asntool.output ]

echo '---debruijn test---'
/usr/bin/debruijn -a ncbistdaa -n 4 > debruijn.output
[ -s debruijn.output ]

echo '---tbl2asn test---'
/usr/bin/tbl2asn -t Sc_16.sbt -i Sc_16.fsa
[ -s Sc_16.sqn ]

echo '---trna2sap test---'
/usr/bin/trna2sap < trnascan-se_sample.output > trna2sap.output
[ -s trna2sap.output ]
echo '---trna2tbl test---'
/usr/bin/trna2tbl < trnascan-se_sample.output > trna2tbl.output
[ -s trna2tbl.output ]