# HG changeset patch # User peterjc # Date 1455795669 18000 # Node ID 7cd370b7a952154812d75d845c7286d1abc5c20a # Parent 56852ae15eddf2b6c3dd3cd3ab28e3fe0f38347d v0.0.3 - More tests, fixed accidental path change in v0.0.2 diff -r 56852ae15edd -r 7cd370b7a952 tools/count_roi_variants/README.rst --- a/tools/count_roi_variants/README.rst Wed Feb 17 11:42:16 2016 -0500 +++ b/tools/count_roi_variants/README.rst Thu Feb 18 06:41:09 2016 -0500 @@ -55,6 +55,7 @@ ------- ---------------------------------------------------------------------- v0.0.1 - Initial public release v0.0.2 - Cope with pipes in reference name (e.g. NCBI style FASTA naming) +v0.0.3 - Include a functional test for using an unrecognised reference. ======= ====================================================================== diff -r 56852ae15edd -r 7cd370b7a952 tools/count_roi_variants/count_roi_variants.py --- a/tools/count_roi_variants/count_roi_variants.py Wed Feb 17 11:42:16 2016 -0500 +++ b/tools/count_roi_variants/count_roi_variants.py Thu Feb 18 06:41:09 2016 -0500 @@ -19,7 +19,7 @@ if "-v" in sys.argv or "--version" in sys.argv: # Galaxy seems to invert the order of the two lines - print("BAM coverage statistics v0.0.2 (using samtools)") + print("BAM coverage statistics v0.0.3 (using samtools)") cmd = "samtools 2>&1 | grep -i ^Version" sys.exit(os.system(cmd)) @@ -165,8 +165,8 @@ # Call samtools view, don't need header so no -h added. # Only want mapped reads, thus flag filter -F 4. - child = subprocess.Popen(["/mnt/galaxy/bin/samtools_1.1", "view", "-F", "4", bam_file, region], - stdout=subprocess.PIPE) + child = subprocess.Popen(["samtools", "view", "-F", "4", bam_file, region], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) for line in child.stdout: assert line[0] != "@", "Got unexpected SAM header line: %s" % line qname, flag, rname, pos, mapq, cigar, rnext, pnext, tlen, seq, rest = line.split("\t", 10) @@ -186,10 +186,14 @@ except KeyError: tally[roi_seq] = 1 + stderr = child.stderr.read() child.stdout.close() + child.stderr.close() return_code = child.wait() if return_code: sys.exit("Got return code %i from samtools view" % return_code) + elif "specifies an unknown reference name. Continue anyway." in stderr: + sys.exit(stderr.strip() + "\n\nERROR: samtools did not recognise the region requested, can't count any variants.") return tally diff -r 56852ae15edd -r 7cd370b7a952 tools/count_roi_variants/count_roi_variants.xml --- a/tools/count_roi_variants/count_roi_variants.xml Wed Feb 17 11:42:16 2016 -0500 +++ b/tools/count_roi_variants/count_roi_variants.xml Thu Feb 18 06:41:09 2016 -0500 @@ -1,4 +1,4 @@ - + using samtools view samtools @@ -59,6 +59,13 @@ + + + + + + + **What it does**