Skip to content

Commit

Permalink
0.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
telatin committed Apr 20, 2021
1 parent 7142da0 commit 4261528
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 9 deletions.
17 changes: 17 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MIN=1000

DEL=0
KEEP=0

for i in ~/git/dadaist2/data/its-mock/split/*.fq;
do
c=$(wc -l $i| perl -ne 'print $1 if ($_=~/(\d+)/)');
if [ $c -lt $MIN ]; then
DEL=$((DEL+1))
rm $i
else
KEEP=$((KEEP+1))
fi
done

echo "Kept $KEEP, deleted $DEL"
2 changes: 1 addition & 1 deletion seqfu.nimble
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Package
version = "0.9.5"
version = "0.9.6"
author = "Andrea Telatin"
description = "SeqFU command-line tools"
license = "MIT"
Expand Down
10 changes: 9 additions & 1 deletion src/fu_sw.nim
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,15 @@ proc main(args: var seq[string]): int =
query = $args["--query"]
target = $args["--target"]
pctid = parseFloat($args["--pct-id"])


if not fileExists(query):
stderr.writeLine("ERROR: Query file not found: ", query)
quit(1)


if not fileExists(target):
stderr.writeLine("ERROR: Target file not found: ", target)
quit(1)

poolSize = parseInt($args["--pool-size"])

Expand Down
5 changes: 3 additions & 2 deletions src/seqfu_utils.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import klib, readfq

import strutils, os, re

when not defined(windows):
import posix
const NimblePkgVersion {.strdefine.} = "<NimblePkgVersion>"
proc version*(): string =
return NimblePkgVersion
Expand Down Expand Up @@ -361,6 +361,7 @@ proc main_helper*(main_func: var seq[string] -> int) =
stderr.writeLine( getCurrentExceptionMsg() )
quit(2)
else:

signal(SIG_PIPE, SIG_IGN)
# Handle Ctrl+C interruptions and pipe breaks
type EKeyboardInterrupt = object of CatchableError
Expand Down
4 changes: 2 additions & 2 deletions src/sfu.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import strutils
import tables
import algorithm
import docopt
import posix




Expand Down Expand Up @@ -96,7 +96,7 @@ proc main(args: var seq[string]): int =
echo format(" • $1: $2", k & repeat(" ", 20 - len(k)), helps_last[k])

echo "\nAdd --help after each command to print usage"
1
0
else:
var p = args[0]
var pargs = args[1 .. ^1]
Expand Down
80 changes: 77 additions & 3 deletions test/mini.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ PLATFORM=""
#if [[ $(uname) == "Darwin" ]]; then
# PLATFORM="_mac"
#fi
BIN=$DIR/../bin/seqfu${PLATFORM}
BINDIR="$DIR/../bin/"
BIN="$BINDIR"/seqfu
FILES=$DIR/../data/

iInterleaved=$FILES/interleaved.fq.gz
Expand All @@ -18,9 +19,15 @@ ERRORS=0
echo "# Minimal test suite"

# Binary works
$BIN > /dev/null|| { echo "Binary not working"; exit 1; }
echo "OK: Running"
$BIN > /dev/null || { echo "Binary not working: $BIN"; exit 1; }
echo "OK: Binary running"

for MOD in head tail view qual derep sort count stats grep rc interleave deinterleave count;
do
echo " - $MOD"
$BIN $MOD --help >/dev/null 2>&1 || { echo "Help for $MOD returned non-zero"; exit 1; }

done
# Dereiplicate
if [[ $($BIN derep $iAmpli | grep -c '>') -eq "18664" ]]; then
echo "OK: Dereplicate"
Expand Down Expand Up @@ -85,13 +92,80 @@ else
ERRORS=$((ERRORS+1))
fi

## Head
if [[ $($BIN head -n 1 $iInterleaved | wc -l) -eq 4 ]]; then
echo "OK: Head 1 sequence"
else
echo "ERR: Head failed"
ERRORS=$((ERRORS+1))
fi



## Tail
if [[ $($BIN tail -n 1 $iInterleaved | wc -l) -eq 4 ]]; then
echo "OK: tail 1 sequence"
else
echo "ERR: Tail failed"
ERRORS=$((ERRORS+1))
fi



##QUal
if [[ $($BIN qual $iInterleaved | grep 'Illumina-1.8' | wc -l ) -eq 1 ]]; then
echo "OK: qual tested"
else
echo "ERR: qual failed"
ERRORS=$((ERRORS+1))
fi
## External

if [[ $($BINDIR/fu-orf -1 $iPair1 -m 29 | grep -c '>') -eq 5 ]]; then
echo "OK: fu-orf tested"
else
echo "ERR: fu-orf test failed: $($BINDIR/fu-orf -1 $iPair1 -m 29 | grep -c '>') != 5"
ERRORS=$((ERRORS+1))
fi

if [[ $($BINDIR/fu-sw -q $FILES/query.fa -t $FILES/target.fa | grep -c 'Score') -eq 2 ]]; then
echo "OK: fu-sw tested"
else
echo "ERR: fu-sw test failed: $BINDIR/fu-sw -q $DATA/query.fa -t $DATA/target.fa | grep -c 'Score' != 2"
ERRORS=$((ERRORS+1))
fi
## STREAMING

if [[ $(cat $iInterleaved | gzip -d | $BIN head -n 1 2>/dev/null | wc -l) -eq 4 ]]; then
echo "OK: Head 1 sequence (stream)"
else
echo "ERR: Head failed"
ERRORS=$((ERRORS+1))
fi

if [[ $(cat $iInterleaved | gzip -d | $BIN tail -n 1 2>/dev/null | wc -l) -eq 4 ]]; then
echo "OK: tail 1 sequence (stream)"
else
echo "ERR: tail failed"
ERRORS=$((ERRORS+1))
fi

if [[ $($BIN head -n 6 $iInterleaved | $BIN tail -n 2 2>/dev/null | wc -l) -eq 8 ]]; then
echo "OK: head/tail 1 sequence (stream)"
else
echo "ERR: head/tail failed"
ERRORS=$((ERRORS+1))
fi

### Check failures
if [[ $ERRORS -gt 0 ]]; then
echo "FAIL: $ERRORS test failed."
exit 1
else
echo "PASS"
fi


echo ""
for TEST in $DIR/*.sh;
do
Expand Down

0 comments on commit 4261528

Please sign in to comment.