File: test-shift.sh

package info (click to toggle)
bedtools 2.27.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 54,804 kB
  • sloc: cpp: 38,072; sh: 7,307; makefile: 2,241; python: 163
file content (142 lines) | stat: -rw-r--r-- 3,761 bytes parent folder | download
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
set -e;
BT=${BT-../../bin/bedtools}

FAILURES=0;

check()
{
	if diff $1 $2; then
    	echo ok

	else
    	FAILURES=$(expr $FAILURES + 1);
		echo fail

	fi
}

# cat a.bed
# chr1	100	200	a1	1	+
# chr1	100	200	a2	2	-

###########################################################
# test shifting forward via -s
###########################################################
echo -e "    shift.t1...\c"
echo \
"chr1	105	205	a1	1	+
chr1	105	205	a2	2	-" > exp
$BT shift -i a.bed -s 5 -g tiny.genome > obs
check obs exp
rm obs exp

###########################################################
# test shifting backward via -s
###########################################################
echo -e "    shift.t2...\c"
echo \
"chr1	95	195	a1	1	+
chr1	95	195	a2	2	-" > exp
$BT shift -i a.bed -s -5 -g tiny.genome > obs
check obs exp
rm obs exp

###########################################################
# test shifting forward via -m and -p
###########################################################
echo -e "    shift.t3...\c"
echo \
"chr1	105	205	a1	1	+
chr1	105	205	a2	2	-" > exp
$BT shift -i a.bed -p 5 -m 5 -g tiny.genome > obs
check obs exp
rm obs exp

###########################################################
# test shifting backward via -m and -p
###########################################################
echo -e "    shift.t3...\c"
echo \
"chr1	95	195	a1	1	+
chr1	95	195	a2	2	-" > exp
$BT shift -i a.bed -p -5 -m -5 -g tiny.genome > obs
check obs exp
rm obs exp

###########################################################
# test just a -m shift (-p == 0)
###########################################################
echo -e "    shift.t4...\c"
echo \
"chr1	100	200	a1	1	+
chr1	95	195	a2	2	-" > exp
$BT shift -i a.bed -m -5 -p 0 -g tiny.genome > obs
check obs exp
rm obs exp

###########################################################
# test just a -p shift (-m == 0)
###########################################################
echo -e "    shift.t5...\c"
echo \
"chr1	105	205	a1	1	+
chr1	100	200	a2	2	-" > exp
$BT shift -i a.bed -m 0 -p 5 -g tiny.genome > obs
check obs exp
rm obs exp

###########################################################
# test going beyond the start of the chrom
###########################################################
echo -e "    shift.t6...\c"
echo \
"chr1	0	1	a1	1	+
chr1	0	1	a2	2	-" > exp
$BT shift -i a.bed -s -200 -g tiny.genome > obs
check obs exp
rm obs exp

###########################################################
# test going beyond the end of the chrom
###########################################################
echo -e "    shift.t7...\c"
echo \
"chr1	999	1000	a1	1	+
chr1	999	1000	a2	2	-" > exp
$BT shift -i a.bed -s 1000 -g tiny.genome > obs
check obs exp
rm obs exp

###########################################################
# test shift being larger than a signed int
###########################################################
echo -e "    shift.t8...\c"
echo \
"chr1	999	1000	a1	1	+
chr1	999	1000	a2	2	-" > exp
$BT shift -i a.bed -s 3000000000 -g tiny.genome > obs
check obs exp
rm obs exp

###########################################################
# test chrom boundaries
###########################################################
echo -e "    shift.t9...\c"
echo -e "chrom1\t10" >genome.len; 
echo -e "chrom1\t5\t10\tcds1\t0\t+" | $BT shift -i - -g genome.len -s 2 > obs
echo \
"chrom1	7	10	cds1	0	+" > exp
check obs exp
rm obs exp

###########################################################
# test shift huge genome
###########################################################
echo -e "    shift.t10...\c"
echo \
"chr1	67000638	67217822	NM_032291	0	+
chr1	92146899	92352836	NR_036634	0	-" > exp
$BT shift -i b.bed -s 1000 -g huge.genome > obs
check obs exp
rm obs exp
[[ $FAILURES -eq 0 ]] || exit 1;