-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-scaffold.bash
executable file
·126 lines (103 loc) · 3.35 KB
/
run-scaffold.bash
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
#! /bin/bash
if [ $# -lt 3 ];then
#usage:$0 <-r "read file(s)" | -b "bam file"> <-R reference.fa> <-k kmer> [-m maximum mismatch bwa] [-p min pairs] [-o output prefix] [-s seed length] [-t threads]
cat << _TEXT
usage:$0 <-r "read file(s)"> <-R reference.fa> <-k kmer> [-m maximum mismatch bwa] [-p min pairs] [-o output prefix] [-s seed length] [-t threads]
_TEXT
exit 1
fi
i=0
while getopts ":r:m:p:o:s:t:k:R:b:" fl; do
case $fl in
r)
reads=$OPTARG
for c in $reads;do
if [ ! -f $c ];then
echo "could not locate file \"$c\", please provide a complete path"
exit 1
else
if [ $i -eq 0 ];then
input=$c
let i+=1
else
input="$input $c"
fi
fi
done
;;
b)
bam=$OPTARG
;;
m)
mmatch=$OPTARG
;;
p)
mpairs=$OPTARG
;;
o)
pref=$OPTARG
;;
s)
seed=$OPTARG
;;
t)
threads=$OPTARG
;;
k)
kmer=$OPTARG
;;
R)
ref="$OPTARG"
;;
\?)
echo "$fl is not a valid option"
exit 1
;;
:)
echo "$fl requires an argument"
exit 1
;;
esac
done
mkdir -p scaffold;cd scaffold
mkdir -p aln ref;cd ref
if [ ! -f $ref ]; then
echo "could not locate $ref, please provide a complete path"
exit 1
fi
if [ -z $mmatch ]; then
mmatch=0.04
fi
if [ -z $mpairs ]; then
mpairs=5
fi
if [ -z $pref ]; then
pref="bpa_out"
fi
if [ -z $seed ]; then
seed=200
fi
if [ -z $threads ]; then
threads=2
fi
#if [ -z $bam ];then
awk '{if(/^>/){a++;print ">"a}else{print}}' $ref > scaffolds_in.fna
bwa index scaffolds_in.fna
cd ../aln
bwa aln -t $threads -n $mmatch -f $pref.sai ../ref/scaffolds_in.fna <( cat $input )
bwa samse -f $pref.int ../ref/scaffolds_in.fna $pref.sai <( cat $input )
cd ..
cat aln/$pref.int | abyss-fixmate -h scaffold.hist \
|sort -T /tmp/ -snk3 -k4 \
|DistanceEst --dot -v -k$kmer -j$threads -s$seed -n$mpairs -o scaffold.dist.dot scaffold.hist
abyss-todot -v -e ref/scaffolds_in.fna scaffold.dist.dot > gmerge.dist.dot
abyss-scaffold -v -n$mpairs -s$seed -k$kmer -o scaffold.paths -g scaffold.adj gmerge.dist.dot
MergeContigs -v -k$kmer -o scaffolds.fna ref/scaffolds_in.fna gmerge.dist.dot scaffold.paths
#else
# samtools view -h $bam | abyss-fixmate -h scaffold.hist \
# |sort -T /tmp/ -snk3 -k4 \
# |DistanceEst --dot -v -k$kmer -j$threads -s$seed -n$mpairs -o scaffold.dist.dot scaffold.hist
# abyss-todot -v -e ref/scaffolds_in.fna scaffold.dist.dot > gmerge.dist.dot
# abyss-scaffold -v -n$mpairs -s$seed -k$kmer -o scaffold.paths -g scaffold.adj gmerge.dist.dot
# MergeContigs -v -k$kmer -o scaffolds.fna ref/scaffolds_in.fna gmerge.dist.dot scaffold.paths
#fi