-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmedaka_polypolish_everything.sh
More file actions
executable file
·64 lines (53 loc) · 1.96 KB
/
Copy pathmedaka_polypolish_everything.sh
File metadata and controls
executable file
·64 lines (53 loc) · 1.96 KB
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
#!/usr/bin/env bash
#Checking for dependencies
if ! command -v bwa > /dev/null; then
printf "\n Bwa not found in path. Exiting"
exit
fi
if ! command -v medaka_consensus > /dev/null; then
printf "\n Medaka not found in path. Exiting"
exit
fi
if ! command -v polypolish > /dev/null; then
printf "\n Polipolish not found in path. Exiting"
exit
fi
#Checking to see if there are fasta files in the directory
count=`ls -1 *.fasta 2>/dev/null | wc -l`
if [ $count != 0 ]
then
echo "Fasta files found - processing"
else
echo "No fasta files found in directory. Exiting"
exit
fi
threads="$1"
long_read=$(echo $2 | tr -d '\r')
short_read_1=$(echo $3 | tr -d '\r')
short_read_2=$(echo $4 | tr -d '\r')
for F in *.fasta; do
N=$(basename $F .fasta);
medaka_consensus -i "$long_read" -d "$F" -o medaka_$N -t "$threads" -m r941_min_sup_g507;
rm *.fai *.mmi;
if [[ $# == 4 ]]; then
echo "#####################################################################";
echo " ";
echo "Short reads detected as arguments 3 and 4. Proceeding with polypolish";
echo " ";
echo "#####################################################################";
mkdir polypolish_$N;
bwa index medaka_$N/consensus.fasta;
bwa mem -t "$threads" -a medaka_$N/consensus.fasta "$short_read_1" > polypolish_$N/alignment1.sam;
bwa mem -t "$threads" -a medaka_$N/consensus.fasta "$short_read_2" > polypolish_$N/alignment2.sam;
polypolish medaka_$N/consensus.fasta polypolish_$N/alignment1.sam polypolish_$N/alignment2.sam > polypolish_$N/polypolish_$F;
rm polypolish_$N/alignment1.sam polypolish_$N/alignment2.sam;
rm -rf medaka_$N;
else
echo "Short reads not provided for $F";
fi;
done
echo "#############################"
echo " "
echo "$F polishing finished"
echo " "
echo "#############################"