File: test-complement.sh

package info (click to toggle)
bedtools 2.31.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 57,304 kB
  • sloc: ansic: 38,507; cpp: 29,721; sh: 8,001; makefile: 663; python: 240; javascript: 16
file content (150 lines) | stat: -rw-r--r-- 4,194 bytes parent folder | download | duplicates (4)
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
set -e;
BT=${BT-../../bin/bedtools}

FAILURES=0;

check()
{
     if diff $1 $2; then
          echo ok
     else
          FAILURES=$(expr $FAILURES + 1);
          echo fail
     fi
}


###########################################################
# test baseline complement
###########################################################
echo -e "    complement.t1...\c"
echo "chr1	1	20" > exp
$BT complement -i <(echo -e "chr1\t0\t1") \
               -g <(echo -e "chr1\t20") \
               > obs
check obs exp
rm obs exp


###########################################################
# ends are covered
###########################################################
echo -e "    complement.t2...\c"
echo "chr1	1	19" > exp
$BT complement -i <(echo -e "chr1\t0\t1\nchr1\t19\t20") \
               -g <(echo -e "chr1\t20") \
               > obs
check obs exp
rm obs exp

###########################################################
# middle is covered
###########################################################
echo -e "    complement.t3...\c"
echo "chr1	0	10
chr1	15	20" > exp
$BT complement -i <(echo -e "chr1\t10\t15") \
               -g <(echo -e "chr1\t20") \
               > obs
check obs exp
rm obs exp

###########################################################
# entirety is covered
###########################################################
echo -e "    complement.t4...\c"
touch exp
$BT complement -i <(echo -e "chr1\t0\t20") \
               -g <(echo -e "chr1\t20") \
               > obs
check obs exp
rm obs exp


###########################################################
# nothing is covered
###########################################################
echo -e "    complement.t5...\c"
echo "chr1	0	20" > exp
$BT complement -i <(echo -e "chr2\t0\t20") \
               -g <(echo -e "chr1\t20\nchr2\t20") \
               > obs
check obs exp
rm obs exp

###########################################################
# Issue #356
###########################################################
echo -e "    complement.t6...\c"
echo "chr1	10000	249250621" > exp
$BT complement -i <(echo -e "chr1\t0\t10000\ttelomere") \
               -g <(echo -e "chr1\t249250621") \
               > obs
check obs exp
rm obs exp

###########################################################
# Multiple chroms 
###########################################################
echo -e "    complement.t7...\c"
echo "chr1	0	10
chr2	0	10" > exp
$BT complement -i <(echo -e "chr1\t10\t20\nchr2\t10\t20") \
               -g <(echo -e "chr1\t20\nchr2\t20") \
               > obs
check obs exp
rm obs exp

###########################################################
# Multiple chroms, chr1 is covered
###########################################################
echo -e "    complement.t8...\c"
echo "chr2	0	10" > exp
$BT complement -i <(echo -e "chr1\t0\t20\nchr2\t10\t20") \
               -g <(echo -e "chr1\t20\nchr2\t20") \
               > obs
check obs exp
rm obs exp

###########################################################
# record exceeds chrom length
###########################################################
echo -e "    complement.t9...\c"
echo -e "***** WARNING: chr1:90-110 exceeds the length of chromosome (chr1)\nchr1\t0\t90" > exp
$BT complement -i <(echo -e "chr1\t90\t110") \
               -g <(echo -e "chr1\t100") \
               &> obs
check obs exp
rm obs exp
[[ $FAILURES -eq 0 ]] || exit 1;

###########################################################
# -L only reports chroms that were in the BED file.
###########################################################
echo -e "    complement.t9...\c"
echo "chr1	0	1
chr1	500	900
chr1	950	1000" > exp
$BT complement -i issue_503.bed \
               -g issue_503.genome \
               -L \
               > obs
check obs exp
rm obs exp

###########################################################
# Now, without -L
###########################################################
echo -e "    complement.t10...\c"
echo "chr1	0	1
chr1	500	900
chr1	950	1000
chr2	0	1000
chr3	0	1000" > exp
$BT complement -i issue_503.bed \
               -g issue_503.genome \
               > obs
check obs exp
rm obs exp

[[ $FAILURES -eq 0 ]] || exit 1;