First version including the rRNA detector
Former-commit-id: 865e2626c7cd92ea596aedefe2b760b3eaaa9c77 Former-commit-id: 94a2e642328eb679660c6ac5a6cb6803c2083632
This commit is contained in:
44
detectors/rrna/tools/revcomp_alignments.sh
Normal file
44
detectors/rrna/tools/revcomp_alignments.sh
Normal file
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Reverse complement a fasta formated alignment
|
||||
#
|
||||
#========================================================================================
|
||||
|
||||
# -- 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"
|
||||
|
||||
|
||||
function revcomp {
|
||||
awk 'function printfasta(seq) { \
|
||||
seqlen=length(seq); \
|
||||
for (i=1; i <= seqlen; i+=60) \
|
||||
print substr(seq,i,60); \
|
||||
} \
|
||||
function comp(seq) { \
|
||||
"echo "seq" | tr acgtACGT tgcaTGCA " | getline res; \
|
||||
close("echo "seq" | tr acgtACGT tgcaTGCA "); \
|
||||
return res; \
|
||||
} \
|
||||
function rev(seq) { \
|
||||
"echo "seq" | rev " | getline res; \
|
||||
close("echo "seq" | rev "); \
|
||||
return res; \
|
||||
} \
|
||||
function revcomp(seq) { \
|
||||
res=rev(comp(seq)); \
|
||||
return res; \
|
||||
} \
|
||||
\
|
||||
(seq) && /^>/ {print head; \
|
||||
printfasta(revcomp(seq)); \
|
||||
seq=""} \
|
||||
/^>/ {head=$0} \
|
||||
! /^>/ {seq=seq$0} \
|
||||
END { print head; \
|
||||
printfasta(revcomp(seq)); \
|
||||
}' $*
|
||||
}
|
||||
|
||||
revcomp $*
|
Reference in New Issue
Block a user