-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpick_adapter.sh
More file actions
executable file
·52 lines (40 loc) · 1016 Bytes
/
pick_adapter.sh
File metadata and controls
executable file
·52 lines (40 loc) · 1016 Bytes
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
#!/bin/bash
#
# Automatic adapter detection in ChIP pipeline
#
# Use:
# for f in data/*.fastq.gz;do ./pick_adapter.sh $f;done
#set -x
# Standard illumina adapter
ad1=AGATCGGAAGAGC
#
ad2=GCGGGTTGAGCCAAGCCTGTGCAGTA
#
ad4=GATCGTCGGACTGTAGAAC
#
ad3=TGGAATTCTCGGGTGCCAA
ll=$(zcat $1|head -2|tail -1|wc -c)
c1=$(zcat $1|head -400000 |awk 'BEGIN{i = 0}{if(i % 4 == 1){print $0};i = i + 1}'|grep -c $ad1)
c2=$(zcat $1|head -400000 |awk 'BEGIN{i = 0}{if(i % 4 == 1){print $0};i = i + 1}'|grep -c $ad2)
c3=$(zcat $1|head -400000 |awk 'BEGIN{i = 0}{if(i % 4 == 1){print $0};i = i + 1}'|grep -c $ad3)
c4=$(zcat $1|head -400000 |awk 'BEGIN{i = 0}{if(i % 4 == 1){print $0};i = i + 1}'|grep -c $ad4)
call=$((c1 + c2 + c3 + c4))
if [ $((c4 + c4)) -gt $((call + 10)) ]
then
echo $ad4
exit 0
fi
if [ $((c3 + c3)) -gt $((call + 10)) ]
then
echo $ad3
exit 0
fi
if [ $((c2 + c2)) -gt $((call + 10)) ]
then
echo $ad2
exit 0
else
# default on standard illumina adapter
echo $ad1
exit 0
fi