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