2015-10-11 10:39:59 -03:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Annotate tRNA
|
|
|
|
#
|
|
|
|
#========================================================================================
|
|
|
|
#
|
|
|
|
# Annotate tRNA based on the Aragorn software predictions.
|
|
|
|
|
|
|
|
# go_trna.sh <FASTAFILE>
|
|
|
|
#
|
|
|
|
# - <FASTAFILE> : The fasta file containing the genome to annotate
|
|
|
|
#
|
|
|
|
# Results are printed to the standart output
|
|
|
|
#
|
|
|
|
#========================================================================================
|
|
|
|
|
|
|
|
# -- CAUTION -- Works as long than the script
|
|
|
|
# is not called through a symlink
|
|
|
|
SCRIPT_DIR="$(dirname ${BASH_SOURCE[0]})"
|
|
|
|
source "${SCRIPT_DIR}/scripts/bash_init.sh"
|
|
|
|
|
|
|
|
pushTmpDir ORG.organnot
|
|
|
|
|
|
|
|
if [[ ! "$1" =~ ^/ ]]; then
|
|
|
|
QUERY="${CALL_DIR}/$1"
|
|
|
|
else
|
|
|
|
QUERY="$1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
RESULTS=$(basename ${QUERY/.*/})
|
|
|
|
LOG="${CALL_DIR}/${RESULTS}.log"
|
|
|
|
|
|
|
|
rm -f ${LOG}
|
|
|
|
openLogFile ${LOG}
|
|
|
|
|
2015-10-11 11:58:43 -03:00
|
|
|
loginfo "Normalizing the structure of the Chloroplast sequence..."
|
|
|
|
loginfo " LSC + IRB + SSC + IRA"
|
|
|
|
${PROG_DIR}/detectors/normalize/bin/go_normalize.sh ${QUERY} > "${RESULTS}.norm.fasta"
|
|
|
|
loginfo "Done."
|
2015-10-11 10:39:59 -03:00
|
|
|
|
2015-10-11 11:58:43 -03:00
|
|
|
loginfo "Annotating the Inverted repeats and Single copies (LSC and SSC)..."
|
|
|
|
${PROG_DIR}/detectors/ir/bin/go_ir.sh ${QUERY} > "${RESULTS}.annot"
|
|
|
|
loginfo "Done."
|
2015-10-11 10:39:59 -03:00
|
|
|
|
2015-10-11 11:58:43 -03:00
|
|
|
loginfo "Annotating the tRNA..."
|
|
|
|
${PROG_DIR}/detectors/trna/bin/go_trna.sh ${QUERY} >> "${RESULTS}.annot"
|
|
|
|
loginfo "Done."
|
2015-10-11 10:39:59 -03:00
|
|
|
|
2015-10-12 07:15:08 -03:00
|
|
|
loginfo "Annotating the rRNA genes..."
|
|
|
|
${PROG_DIR}/detectors/rrna/bin/go_rrna.sh ${QUERY} >> "${RESULTS}.annot"
|
|
|
|
loginfo "Done."
|
|
|
|
|
2015-10-11 11:58:43 -03:00
|
|
|
|
|
|
|
loginfo "Printing annotations header..."
|
|
|
|
echo "XX"
|
|
|
|
echo "FH Key Location/Qualifiers"
|
|
|
|
loginfo "Done."
|
|
|
|
|
|
|
|
loginfo "Ordering annotations..."
|
|
|
|
awk '/^.....[^ ]/ { \
|
|
|
|
match($3,"[0-9][0-9]*"); \
|
|
|
|
pos=substr($3,RSTART,RLENGTH)*1000 + 1; \
|
|
|
|
print pos,$0} \
|
|
|
|
/^..... / { \
|
|
|
|
pos++; \
|
|
|
|
print pos,$0}' "${RESULTS}.annot" | \
|
|
|
|
sort -nk1 | \
|
|
|
|
awk '{ \
|
|
|
|
match($0,"^[0-9]* ");\
|
|
|
|
line=substr($0,RLENGTH+1,100000);\
|
|
|
|
print line}'
|
|
|
|
loginfo "Done."
|
|
|
|
|
|
|
|
loginfo "Closing annotations table..."
|
|
|
|
echo "XX"
|
|
|
|
loginfo "Done."
|
|
|
|
|
|
|
|
loginfo "Computing statistics on nucleotide usage..."
|
|
|
|
awk '! /^>/ { \
|
|
|
|
seq=toupper($0); \
|
|
|
|
gsub(" ","",seq); \
|
|
|
|
lseq=length(seq); \
|
|
|
|
for (i=0; i < lseq; i++) { \
|
|
|
|
freq[substr(seq,i,1)]++}\
|
|
|
|
} \
|
|
|
|
END { \
|
|
|
|
other=0; \
|
|
|
|
for (i in freq) { \
|
|
|
|
if (i!="A" && i!="C" && i!="G" && i!="T") {\
|
|
|
|
other+=freq[i] \
|
|
|
|
} \
|
|
|
|
}; \
|
|
|
|
print "SQ Sequence "\
|
|
|
|
(freq["A"]+freq["C"]+freq["G"]+freq["T"]+other) \
|
|
|
|
" BP; "\
|
|
|
|
freq["A"]" A; "\
|
|
|
|
freq["C"]" C; "\
|
|
|
|
freq["G"]" G; "\
|
|
|
|
freq["T"]" T; "\
|
|
|
|
other" other;" \
|
|
|
|
}' ${QUERY}
|
|
|
|
loginfo "Done."
|
|
|
|
|
|
|
|
loginfo "Reformating sequences..."
|
|
|
|
lines=$(wc -l ${QUERY} | awk '{print $1}')
|
|
|
|
awk -v lines=$lines ' \
|
|
|
|
! /^>/ { \
|
|
|
|
seq=tolower($0); \
|
|
|
|
gsub(" ","",seq); \
|
|
|
|
printf(" ") ;\
|
|
|
|
for (i=0; i < 6; i++) { \
|
|
|
|
f=substr(seq,i * 10, 10); \
|
|
|
|
pos+=length(f); \
|
|
|
|
f = f substr(" ",1,10-length(f)); \
|
|
|
|
printf("%s ",f) \
|
|
|
|
}; \
|
|
|
|
if (NR==lines) \
|
|
|
|
{pos-=1}; \
|
|
|
|
printf(" %6d\n",pos) \
|
|
|
|
}' ${QUERY}
|
|
|
|
loginfo "Done."
|
|
|
|
|
|
|
|
loginfo "Closing sequence part..."
|
|
|
|
echo "//"
|
|
|
|
loginfo "Done."
|
|
|
|
|
2015-10-11 10:39:59 -03:00
|
|
|
popTmpDir
|
|
|
|
|