source: trunk/GDE/SINA/builddir/tests/readwrite.test

Last change on this file was 19170, checked in by westram, 2 years ago
  • sina source
    • unpack + remove tarball
    • no longer ignore sina builddir.
  • Property svn:executable set to *
File size: 4.5 KB
Line 
1#!/bin/bash
2
3source tests/test_helper.sh
4
5TEST_ARB=$TEST_ARGS
6maketmpdir T
7
8cp $TEST_ARB $T/ref.arb
9
10SINA="./src/sina --prealigned --preserve-order"
11
12
13begin_test "Copy ARB to FASTA (TEST_ARB->test.fasta)"
14capture_stdouterr "$SINA -i $T/ref.arb -o $T/test.fasta --select-step 1000"
15assert_exit_success
16assert_output_contains "align 12 sequences"
17end_test
18
19begin_test "Copy ARB to FASTA.gz (TEST_ARB->test.fasta.gz)"
20capture_stdouterr "$SINA -i $T/ref.arb -o $T/test.fasta.gz --select-step 1000"
21assert_exit_success
22assert_output_contains "align 12 sequences"
23capture_stderr "gunzip -c $T/test.fasta.gz | cmp - $T/test.fasta"
24assert_exit_success
25end_test
26
27begin_test "Copy ARB to FASTA (TEST_ARB->STDOUT)"
28capture_stdouterr "$SINA -i $T/ref.arb -o - --select-step 1000 > $T/test2.fasta"
29assert_exit_success
30assert_output_contains "align 12 sequences"
31capture_stderr "cmp $T/test.fasta $T/test2.fasta"
32assert_exit_success
33end_test
34
35begin_test "Copy ARB to ARB (TEST_ARB->test.arb)"
36capture_stdouterr "$SINA -i $T/ref.arb -o $T/test.arb --select-step 1000"
37assert_exit_success
38assert_output_contains "align 12 sequences"
39end_test
40
41begin_test "Copy FASTA to ARB (test.fasta->test2.arb)"
42capture_stdouterr "$SINA -i $T/test.fasta -o $T/test2.arb"
43assert_exit_success
44assert_output_contains "align 12 sequences"
45capture_stdouterr "cmp $T/test.arb $T/test2.arb"
46assert_exit_success
47end_test
48
49begin_test "Copy FASTA.gz to ARB (test.fasta->test2.arb)"
50capture_stdouterr "$SINA -i $T/test.fasta.gz -o $T/test2.arb"
51assert_exit_success
52assert_output_contains "align 12 sequences"
53capture_stdouterr "cmp $T/test.arb $T/test2.arb"
54assert_exit_success
55end_test
56
57begin_test "Copy ARB into ARB (TEST_ARB->test2.arb)"
58capture_stdouterr "$SINA -i $T/ref.arb -o $T/test2.arb --select-step 1001"
59assert_exit_success
60assert_output_contains "align 12 sequences"
61capture_stdouterr "cmp $T/test.arb $T/test2.arb"
62assert_exit_failure
63end_test
64
65begin_test "Copy ARB to NULL (outtype=NONE)"
66capture_stdouterr "$SINA -i $T/test2.arb --outtype NONE"
67assert_exit_success
68assert_output_contains "align 23 sequences"
69end_test
70
71begin_test "Copy FASTA to NULL (test.fasta->/dev/null)"
72capture_stdouterr "$SINA -i $T/test.fasta -o /dev/null"
73assert_exit_success
74assert_output_contains "align 12 sequences"
75end_test
76
77begin_test "Meta Data in FASTA header"
78capture_stdouterr "$SINA -i $T/test.arb -o $T/test.fasta --meta-fmt header -f acc"
79assert_exit_success
80assert_output_contains "align 12 sequences"
81grep "^>" $T/test.fasta | sed 's/.*\[acc=\([^]]*\)\].*/\1/' | sort -u > $T/acc.txt
82capture_stdout "wc -l $T/acc.txt"
83assert_output_contains "12"
84end_test
85
86begin_test "Meta Data in sidecar CSV"
87capture_stdouterr "$SINA -i $T/test.arb -o $T/test.fasta --meta-fmt csv -f acc"
88assert_exit_success
89assert_output_contains "align 12 sequences"
90cut -d, -f2 $T/test.csv | tr -d $'\\r' | tail -n+2 | sort  > $T/acc2.txt
91assert_exit_success "cmp $T/acc.txt $T/acc2.txt"
92end_test
93
94begin_test "Meta Data in FASTA comments"
95capture_stdouterr "$SINA -i $T/test.arb -o $T/test.fasta --meta-fmt comment -f acc"
96assert_exit_success
97assert_output_contains "align 12 sequences"
98sed -n 's/^; acc=//p' $T/test.fasta | sort > $T/acc2.txt
99assert_exit_success "cmp $T/acc.txt $T/acc2.txt"
100end_test
101
102begin_test "CSV writer"
103capture_stdouterr "$SINA -i $T/test.arb -o $T/test.fasta -o $T/test.csv -f acc"
104assert_exit_success
105assert_output_contains "align 12 sequences"
106cut -d, -f2 $T/test.csv | tail -n+2 | sort  > $T/acc2.txt
107assert_exit_success "cmp $T/acc.txt $T/acc2.txt"
108end_test
109
110begin_test "CSV writer - stdout"
111capture_stdouterr "$SINA -i $T/test.arb -o $T/test.fasta --outtype CSV -o - -f acc > $T/test.csv"
112assert_exit_success
113assert_output_contains "align 12 sequences"
114cut -d, -f2 $T/test.csv | tail -n+2 | sort  > $T/acc2.txt
115assert_exit_success "cmp $T/acc.txt $T/acc2.txt"
116end_test
117
118begin_test "CSV writer - gzip"
119capture_stdouterr "$SINA -i $T/test.arb  -o $T/test.csv.gz -f acc"
120assert_exit_success
121assert_output_contains "align 12 sequences"
122gzip -dc $T/test.csv.gz | cut -d, -f2 | tail -n+2 | sort  > $T/acc2.txt
123assert_exit_success "cmp $T/acc.txt $T/acc2.txt"
124end_test
125
126begin_test "CSV writer - CRLF"
127capture_stdouterr "$SINA -i $T/test.arb -o $T/test.csv -f acc --csv-crlf"
128assert_exit_success
129assert_output_contains "align 12 sequences"
130cut -d, -f2 $T/test.csv | tail -n+2 | sort  > $T/acc2.txt
131assert_exit_failure "cmp $T/acc.txt $T/acc2.txt"
132assert_exit_success "tr -d $'\\r' < $T/acc2.txt | cmp $T/acc.txt -"
133assert_exit_success "grep -c $'\\r' $T/test.csv"
134assert_output_contains 13
135end_test
136
137
Note: See TracBrowser for help on using the repository browser.