diff --git a/bin/seqfu b/bin/seqfu index 40abf45..a1c5da6 100755 Binary files a/bin/seqfu and b/bin/seqfu differ diff --git a/docs/1_install.md b/docs/1_install.md index 2b4ab43..61b5310 100644 --- a/docs/1_install.md +++ b/docs/1_install.md @@ -8,7 +8,8 @@ permalink: /installation ## Install via Miniconda -The recommended installation method is via BioConda. If you have _conda_ installed ([how to install it](https://docs.conda.io/en/latest/miniconda.html)): +The **recommended** installation method is via BioConda. +If you have _conda_ installed ([how to install it](https://docs.conda.io/en/latest/miniconda.html)): ``` conda install -c conda-forge -c bioconda seqfu @@ -18,6 +19,6 @@ More info on [installing conda](https://telatin.github.io/microbiome-bioinformat ## Pre-compiled binaries -Pre-compiled binaries are distributed with the [stable releases](https://github.com/telatin/qax/releases). +Pre-compiled binaries are distributed with the [stable releases](https://github.com/telatin/seqfu2/releases). diff --git a/docs/tools/2.12_usage_rc.md b/docs/tools/2.12_usage_rc.md index 3ffbefc..52f982e 100644 --- a/docs/tools/2.12_usage_rc.md +++ b/docs/tools/2.12_usage_rc.md @@ -35,6 +35,12 @@ CTGCWGCCNCCCGTAGG GGATTAGATACCCBDGTAGTCC ``` +**Note**: if a single sequence (string) is provided, the output is not in FASTA format but a plain string. This makes easier +a programmatic use like: +```bash +removePrimersScript.sh --for $FOR --rev $(seqfu rc $REV) +``` + ## Reverse commplement files When supplying input files, the whole file will be complemented. If the file is in FASTQ format the quality will be reversed as well. The program can process multiple files. diff --git a/src/fastx_rc.nim b/src/fastx_rc.nim index 633c039..68cc98e 100644 --- a/src/fastx_rc.nim +++ b/src/fastx_rc.nim @@ -44,8 +44,12 @@ Options: if not fileExists(filename): # Process as string stringCount += 1 - echo ">", seqDefaultName, "_" , $stringCount, "\n", revcompl(filename) - continue + if len(files) == 1: + echo revcompl(filename) + continue + else: + echo ">", seqDefaultName, "_" , $stringCount, "\n", revcompl(filename) + continue else: echoVerbose(filename, verbose) diff --git a/src/fastx_view.nim b/src/fastx_view.nim index 5a92ada..d7e3527 100644 --- a/src/fastx_view.nim +++ b/src/fastx_view.nim @@ -101,27 +101,46 @@ proc qualToColor(s: string, v: seq[int], color = false): string = else: result &= i -proc highlight(r: string, matches: seq[seq[int]], l:int, color: proc) = +proc isOnlySpaces(s: string): bool = + for c in s: + if c != ' ': + return false + return true + +proc highlightOligoMatches(r: string, matches: seq[seq[int]], oligo_length:int, color: proc): string = + var + glyphs = newSeq[string](len(r)) + + for i in 0 ..< len(r): + glyphs[i] = " " + + if len(matches[0]) > 0: for m in matches[0]: let - stop = if m >= 0: l - else: l + m + stop = if m >= 0: oligo_length + else: oligo_length + m start = if m >= 0: m else: 0 - echo ' '.repeat(start) & "ᐅ".color.fgWhite.repeat(stop) + for i in start ..< start+stop: + if i < len(glyphs): + glyphs[i] = "ᐅ".color.fgWhite #echo r - if len(matches[1]) > 0: for m in matches[1]: let - stop = if m >= 0: l - else: l + m + stop = if m >= 0: oligo_length + else: oligo_length + m start = if m >= 0: m else: 0 - echo ' '.repeat(start) & "ᐊ".color.fgWhite.repeat(stop) - + #echo "?", ' '.repeat(start) & "ᐊ".color.fgWhite.repeat(stop) + for i in start ..< start+stop: + if i < len(glyphs): + glyphs[i] = "ᐊ".color.fgWhite + + return glyphs.join("") + proc fastx_view(argv: var seq[string]): int = let args = docopt(""" Usage: view [options] [] @@ -192,10 +211,14 @@ Options: if $args["--oligo1"] != "nil": let matches = findPrimerMatches(read.seq, $args["--oligo1"], matchThs, maxMismatches, minMatches) - highlight(read.seq, matches, len($args["--oligo1"]), bgBlue) + let forString = highlightOligoMatches(read.seq, matches, len($args["--oligo1"]), bgBlue) + if forString.isOnlySpaces == false: + echo forString if $args["--oligo2"] != "nil": let matches = findPrimerMatches(read.seq, $args["--oligo2"], matchThs, maxMismatches, minMatches) - highlight(read.seq, matches, len($args["--oligo2"]), bgRed) + let revString = highlightOligoMatches(read.seq, matches, len($args["--oligo2"]), bgRed) + if revString.isOnlySpaces == false: + echo revString echo read.seq if args["--qual-chars"]: echo qualToColor(read.qual, thresholdValues, colorOutput)