-
Notifications
You must be signed in to change notification settings - Fork 2
/
BOLD_lineage_primers_cut.sh
41 lines (31 loc) · 1.04 KB
/
BOLD_lineage_primers_cut.sh
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
#!/bin/bash
INPUT="${1}"
PRIMER_F="${2}"
PRIMER_R="${3}"
filename=$(basename -- "$INPUT")
filename="${filename%.*}"
TMP_FASTA="tmp.fasta"
TMP_FASTA2="tmp2.fasta"
TMP_FASTA3="tmp3.fasta"
FINAL=${filename}_cut.fasta
if [ -z "${PRIMER_F}" ] || [ -z "${PRIMER_R}" ]; then
awk 'BEGIN {FS = "\t"}
{if (NR > 1) {
print ">"$1"/"$7" "$9"|"$11"|"$13"|"$15"|"$17"|"$19"|"$21"|"$23"\n"$45
}}' "${INPUT}" >> "${TMP_FASTA}"
sed -e '/^[a-zA-Z]/ s/-*//g' "${TMP_FASTA}" >> "${TMP_FASTA2}"
sed -e '/^> / s/ /BOLD? /g' "${TMP_FASTA2}" >> "${FINAL}"
rm "${TMP_FASTA}"
rm "${TMP_FASTA2}"
else
awk 'BEGIN {FS = "\t"}
{if (NR > 1) {
print ">"$1"/"$7" "$9"|"$11"|"$13"|"$15"|"$17"|"$19"|"$21"|"$23"\n"$45
}}' "${INPUT}" >> "${TMP_FASTA}"
sed -e '/^[a-zA-Z]/ s/-*//g' "${TMP_FASTA}" >> "${TMP_FASTA2}"
sed -e '/^> / s/ /BOLD? /g' "${TMP_FASTA2}" >> "${TMP_FASTA3}"
cutadapt --quiet --discard-untrimmed -g "${PRIMER_F}" -a "${PRIMER_R}" -o "${FINAL}" "${TMP_FASTA3}"
rm "${TMP_FASTA}"
rm "${TMP_FASTA2}"
rm "${TMP_FASTA3}"
fi