-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprokkaGFF2fcGTF.sh
42 lines (32 loc) · 1.14 KB
/
prokkaGFF2fcGTF.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
40
41
42
#! /usr/local/bin/bash
# convert a gff file generated by PROKKA to a featureCounts()-compatible gtf
#
# input file must have extension "gff"
if [ "$1" == "-h" ]; then
echo $'\nConvert a gff file generated by PROKKA to a featureCounts()-compatible gtf\n'
echo $'USAGE:'
echo "`basename $0` [inputGFFfile.gff]"
echo $'\nOUTPUT:\na GTF file with the same base name as the input'
echo $'\nAUTHOR:\[email protected]'
exit 0
fi
GFFIN=$1
GFFBASE=${GFFIN##*/}
# ${FOO/%from/to}
echo "working on ${GFFBASE}"
# gffread -T -F $GFFIN | sed -n '/exon/!p' | sed 's/transcript/exon/' > ${GFFBASE/%gff/gtf}
tmpfile1=$(mktemp)
gffread -T -F $GFFIN | grep "\tbarrnap:" | sed 's/$/ gene_biotype "ribosomal RNA";/' > ${tmpfile1}
echo ${tmpfile1}
tmpfile2=$(mktemp)
gffread -T -F $GFFIN | grep "\tAragorn:" | sed 's/$/ gene_biotype "tRNA";/' > ${tmpfile2}
echo ${tmpfile2}
tmpfile3=$(mktemp)
gffread -T -F $GFFIN | grep "\tProdigal:" | sed 's/$/ gene_biotype "protein_coding";/' > ${tmpfile3}
echo ${tmpfile3}
echo "merging tempfiles..."
cat ${tmpfile1} ${tmpfile2} ${tmpfile3} > ${GFFBASE/%gff/gtf}
rm -f ${tmpfile1}
rm -f ${tmpfile2}
rm -f ${tmpfile3}
echo "Done!"