Skip to content

Commit

Permalink
enabled-danger-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
telatin committed Feb 8, 2022
1 parent d4f01ea commit c766c8d
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 19 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@

BIN=./bin
SOURCE=./src
NIM_PATHS= --colors:on --noNimblePath --path:/local/giovanni/bamtocov/nimbledeps/pkgs/hts-0.3.17 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/docopt-0.6.8 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/regex-0.19.0 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/unicodedb-0.9.0 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/lapper-0.1.7
VERSION := $(shell grep version bamtocov.nimble | grep -o "[0-9]\\+\.[0-9]\.[0-9]\\+")
LIST=$(BIN)/bamtocov $(BIN)/bamtocounts $(BIN)/covtotarget $(BIN)/bamcountrefs $(BIN)/gff2bed $(BIN)/bamtocounts_legacy $(BIN)/bamtarget

$(BIN)/%: $(SOURCE)/%.nim $(SOURCE)/covutils.nim bamtocov.nimble
nim c -d:NimblePkgVersion=$(VERSION) -d:release --opt:speed -d:danger --out:$@ $<
nim c $(NIM_PATHS) -d:NimblePkgVersion=$(VERSION) -d:release --opt:speed -d:danger --out:$@ $<

all: $(LIST)

#bin/bamtocov:
# nimble build

test: testshpec

Expand Down
2 changes: 1 addition & 1 deletion bamtocov.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "MIT"
requires "hts >= 0.3.1", "docopt >= 0.6.8", "nim >= 1.0.0", "lapper"
srcDir = "src"
binDir = "bin"
bin = @["covtotarget", "bamtocounts", "bamtocov", "bamcountrefs", "gff2bed"]
bin = @["covtotarget", "bamtocounts", "bamtocov", "bamcountrefs", "gff2bed", "bamtarget"]
skipDirs = @["tests", "docs"]
skipFiles = @["example.bam"]

Expand Down
Binary file modified bin/covtotarget
Binary file not shown.
Binary file modified bin/gff2bed
Binary file not shown.
2 changes: 1 addition & 1 deletion nim.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# in htslib: cd
# nim c -a -d:static -d:release


-d:danger
-d:release
--opt:speed
@if static:
Expand Down
21 changes: 17 additions & 4 deletions src/bamtarget.nim
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ proc main(argv: var seq[string]): int =
let doc = format("""
BamTarget $version
Usage: BamTarget [options] [<Target>]
Usage: BamTarget [options] <Target> [<BAM>]
Arguments:
<Target> A target to be parsed (GFF, GTF, BED)
<BAM> A BAM file linked to the target
Target files:
-r, --regions <bed> Target file in BED or GFF3/GTF format (detected with the extension)
Expand Down Expand Up @@ -177,13 +176,27 @@ Other options:
target = bed_to_table($args["<Target>"])

if debug:
stderr.writeLine "Target parsed: ", len(target), " regions"
stderr.writeLine "Target parsed: ", len(target), " reference sequences"

for t in target.keys():
if debug:
echo "# Chromosome:" , t
for region in target[t]:
echo region.chrom, "\t", region.start, "\t", region.stop, "\t", region.name

if fileExists($args["<BAM>"]):
if debug:
stderr.writeLine "BAM file: ", $args["<BAM>"]
var
bam: Bam
open(bam, cstring($args["<BAM>"]), threads=1)
let cooked = cookTarget(target, bam)
for t in cooked.keys():
if debug:
echo "# Chromosome:" , t
for region in cooked[t]:
echo "[",t,"]\t", region.start, "\t", region.stop, "\t", region.label

return 0

type EKeyboardInterrupt = object of CatchableError
Expand Down
2 changes: 1 addition & 1 deletion src/bamtocov.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import sets

# FEATURES paper
# ✅ TODO multi-bam report
# ✅ TODO quantized output
# ✅ TODO quantized output m
# TODO max-min coverage?
# TODO number of bases under X per target
# ✅ TODO no output option, if one only wants the report
Expand Down
27 changes: 27 additions & 0 deletions tests/batch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set -euxo pipefail
BIN=bin/bamtocov
touch $BIN && rm $BIN
test="bin/bamtocov --version && bin/bamtocov -r input/regions.bed -o ciao input/mini.bam --debug"
nim c --colors:on --noNimblePath --path:/local/giovanni/bamtocov/nimbledeps/pkgs/hts-0.3.17 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/docopt-0.6.8 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/regex-0.19.0 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/unicodedb-0.9.0 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/lapper-0.1.7 -d:NimblePkgVersion=V1 -d:release --opt:speed -d:danger --out:bin/bamtocov src/bamtocov.nim 2>&1 > /dev/null

$test

nim c --path:/local/giovanni/bamtocov/nimbledeps/pkgs/hts-0.3.17 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/docopt-0.6.8 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/regex-0.19.0 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/unicodedb-0.9.0 --path:/local/giovanni/bamtocov/nimbledeps/pkgs/lapper-0.1.7 -d:NimblePkgVersion=V2 -d:release --opt:speed -d:danger --out:bin/bamtocov src/bamtocov.nim 2>&1 > /dev/null

$test

nim c -d:NimblePkgVersion=V3 -d:release --opt:speed -d:danger --out:bin/bamtocov src/bamtocov.nim 2>&1 > /dev/null

$test

nim c -d:NimblePkgVersion=V4 -d:release --opt:speed --out:bin/bamtocov src/bamtocov.nim 2>&1 > /dev/null

$test

nim c -d:NimblePkgVersion=V5 --opt:speed --out:bin/bamtocov src/bamtocov.nim 2>&1 > /dev/null

$test

nim c -d:NimblePkgVersion=V6 --out:bin/bamtocov src/bamtocov.nim 2>&1 > /dev/null

$test
23 changes: 14 additions & 9 deletions tests/shpec/bamtocov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ describe "Coverage tools tested by Shpec"
DATADIR="$( cd -- "$( dirname -- "$SELFDIR"/../../input/mini.bam )" &> /dev/null && pwd )"
fi

it "Binary found"
assert file_present "$BINDIR/bamtocov"
assert file_present "$BINDIR/bamtocounts"
end
# PROGRAM: bamtocov
describe "BamToCov"
it "Binary exist"
assert file_present "$BINDIR"/bamtocov
end
it "Version emitted is 2.x"
VERSION=$("$BINDIR"/bamtocov --version)
VERSION=$("$BINDIR"/bamtocov --version)
it "Version emitted is 2.x [$VERSION]"

assert glob "$VERSION" "2.*"
end

Expand Down Expand Up @@ -47,13 +52,13 @@ describe "Coverage tools tested by Shpec"
assert file_present $TMPFILE
end

# it "Target BED: Report file ($TMPFILE)"
# LINES=$(cat "$TMPFILE" | wc -l)
# STRING=$(cat "$TMPFILE")
# assert equal $LINES 7
# assert grep "${STRING}" "shared1_10"
# rm $TMPFILE
# end
it "Target BED: Report file ($TMPFILE)"
LINES=$(cat "$TMPFILE" | wc -l)
STRING=$(cat "$TMPFILE")
assert equal $LINES 7
assert glob "${STRING}" "interval*"
rm $TMPFILE
end

end

Expand Down

0 comments on commit c766c8d

Please sign in to comment.