From 1248586b54af4bd4dfb28ebfebfc6bf012e7a587 Mon Sep 17 00:00:00 2001 From: Artem Tarasov Date: Sat, 10 Sep 2016 08:58:07 +0200 Subject: [PATCH 1/9] fixes lomereiter/sambamba#244 --- bio/bam/pileup.d | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bio/bam/pileup.d b/bio/bam/pileup.d index 576a16b..a4c6a12 100644 --- a/bio/bam/pileup.d +++ b/bio/bam/pileup.d @@ -864,6 +864,11 @@ struct PileupChunkRange(C) { private bool _use_md_tag; private ulong _start_from; private ulong _end_at; + private int _chunk_right_end; + + private int computeRightEnd(ref ElementType!C chunk) { + return chunk.map!(r => r.position + r.basesCovered()).reduce!max; + } this(C chunks, bool use_md_tag, ulong start_from, ulong end_at) { _chunks = chunks; @@ -885,10 +890,9 @@ struct PileupChunkRange(C) { break; } - auto last_read = _current_chunk[$-1]; - if (last_read.position + last_read.basesCovered() > start_from) { + _chunk_right_end = computeRightEnd(_current_chunk); + if (_chunk_right_end > start_from) break; - } } } } @@ -900,7 +904,7 @@ struct PileupChunkRange(C) { auto front() @property { auto end_pos = _current_chunk[$-1].position; if (_chunks.empty || _chunks.front[0].ref_id != _current_chunk[$-1].ref_id) - end_pos += _current_chunk[$-1].basesCovered(); + end_pos = _chunk_right_end; return makePileup(chain(_prev_chunk, _current_chunk), _use_md_tag, @@ -921,6 +925,8 @@ struct PileupChunkRange(C) { if (_current_chunk[0].ref_id >= 0) break; } + _chunk_right_end = computeRightEnd(_current_chunk); + // if we changed reference, nullify prev_chunk if (_prev_chunk.length > 0 && _prev_chunk[$ - 1].ref_id == _current_chunk[0].ref_id) From c37b0e7e03de77d231d596a16293907fa4f7ca92 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 16 Dec 2016 12:41:21 +0000 Subject: [PATCH 2/9] switch to undead.stream; --- bio/bam/bai/indexing.d | 2 +- bio/bam/baifile.d | 2 +- bio/bam/reader.d | 2 +- bio/bam/readrange.d | 2 +- bio/bam/reference.d | 2 +- bio/bam/referenceinfo.d | 2 +- bio/bam/writer.d | 4 ++-- bio/core/bgzf/inputstream.d | 2 +- bio/core/bgzf/outputstream.d | 2 +- bio/core/utils/stream.d | 4 ++-- bio/core/utils/switchendianness.d | 2 +- bio/sff/reader.d | 2 +- bio/sff/readrange.d | 2 +- bio/sff/writer.d | 2 +- dub.json | 5 ++++- examples/create_bam_from_scratch.d | 2 +- test/unittests.d | 2 +- 17 files changed, 22 insertions(+), 19 deletions(-) diff --git a/bio/bam/bai/indexing.d b/bio/bam/bai/indexing.d index 270f5e6..43e89d3 100644 --- a/bio/bam/bai/indexing.d +++ b/bio/bam/bai/indexing.d @@ -30,7 +30,7 @@ import bio.bam.constants; import bio.bam.bai.bin; import bio.core.bgzf.chunk; -import std.stream; +import undead.stream; import std.array; import std.algorithm; import std.system; diff --git a/bio/bam/baifile.d b/bio/bam/baifile.d index 57359a9..276e685 100644 --- a/bio/bam/baifile.d +++ b/bio/bam/baifile.d @@ -28,7 +28,7 @@ public import bio.bam.bai.bin; import bio.core.bgzf.virtualoffset; import bio.bam.constants; -import std.stream; +import undead.stream; import std.system; import std.exception; import std.algorithm; diff --git a/bio/bam/reader.d b/bio/bam/reader.d index fae864f..728ccb5 100644 --- a/bio/bam/reader.d +++ b/bio/bam/reader.d @@ -94,7 +94,7 @@ class BamReader : IBamSamReader { } ------------------------------------------- */ - this(std.stream.Stream stream, + this(undead.stream.Stream stream, std.parallelism.TaskPool task_pool = std.parallelism.taskPool) { _source_stream = new EndianStream(stream, Endian.littleEndian); _task_pool = task_pool; diff --git a/bio/bam/readrange.d b/bio/bam/readrange.d index 6767a74..fc17aff 100644 --- a/bio/bam/readrange.d +++ b/bio/bam/readrange.d @@ -29,7 +29,7 @@ import bio.bam.reader; import bio.core.bgzf.inputstream; import bio.core.bgzf.virtualoffset; -import std.stream; +import undead.stream; import std.algorithm; import std.system; import std.bitmanip; diff --git a/bio/bam/reference.d b/bio/bam/reference.d index 997e6b4..6406b32 100644 --- a/bio/bam/reference.d +++ b/bio/bam/reference.d @@ -47,7 +47,7 @@ import bio.bam.region; import bio.bam.randomaccessmanager; import bio.core.bgzf.virtualoffset; -import std.stream; +import undead.stream; import std.exception; import std.array; diff --git a/bio/bam/referenceinfo.d b/bio/bam/referenceinfo.d index 3824fe8..91b8d96 100644 --- a/bio/bam/referenceinfo.d +++ b/bio/bam/referenceinfo.d @@ -23,7 +23,7 @@ */ module bio.bam.referenceinfo; -import std.stream; +import undead.stream; import std.exception; import std.array; diff --git a/bio/bam/writer.d b/bio/bam/writer.d index 4d5b4f1..5e92930 100644 --- a/bio/bam/writer.d +++ b/bio/bam/writer.d @@ -35,7 +35,7 @@ import bio.core.utils.stream; import std.parallelism; import std.exception; -import std.stream; +import undead.stream; import std.traits; import std.system; import std.algorithm; @@ -73,7 +73,7 @@ final class BamWriter { /// compression_level = compression level, must be in range -1..9 /// task_pool = task pool to use for parallel compression /// buffer_size = size of BgzfOutputStream buffer - this(std.stream.Stream stream, + this(undead.stream.Stream stream, int compression_level=-1, std.parallelism.TaskPool task_pool=std.parallelism.taskPool, size_t buffer_size=0) diff --git a/bio/core/bgzf/inputstream.d b/bio/core/bgzf/inputstream.d index 169e189..2bfc658 100644 --- a/bio/core/bgzf/inputstream.d +++ b/bio/core/bgzf/inputstream.d @@ -30,7 +30,7 @@ import bio.core.bgzf.chunk; import bio.bam.constants; import bio.core.utils.roundbuf; -import std.stream; +import undead.stream; import std.exception; import std.conv; import std.parallelism; diff --git a/bio/core/bgzf/outputstream.d b/bio/core/bgzf/outputstream.d index b9f3d07..89cbecb 100644 --- a/bio/core/bgzf/outputstream.d +++ b/bio/core/bgzf/outputstream.d @@ -28,7 +28,7 @@ import bio.core.bgzf.compress; import bio.core.utils.roundbuf; -import std.stream; +import undead.stream; import std.exception; import std.parallelism; import std.array; diff --git a/bio/core/utils/stream.d b/bio/core/utils/stream.d index 6c5146d..ee57fe7 100644 --- a/bio/core/utils/stream.d +++ b/bio/core/utils/stream.d @@ -1,6 +1,6 @@ module bio.core.utils.stream; -public import std.stream; +public import undead.stream; import core.stdc.stdio; import core.stdc.errno; import core.stdc.string; @@ -48,7 +48,7 @@ FileMode toFileMode(string mode) { return result; } -final class File: std.stream.File { +final class File: undead.stream.File { this(string filename, string mode="rb") { version (Posix) { // Issue 8528 workaround diff --git a/bio/core/utils/switchendianness.d b/bio/core/utils/switchendianness.d index 7b141cf..6772e70 100644 --- a/bio/core/utils/switchendianness.d +++ b/bio/core/utils/switchendianness.d @@ -1,5 +1,5 @@ /** - (Almost) a copy-paste from std/stream.d + (Almost) a copy-paste from undead.stream.d */ module bio.core.utils.switchendianness; diff --git a/bio/sff/reader.d b/bio/sff/reader.d index d0c21a2..257a859 100644 --- a/bio/sff/reader.d +++ b/bio/sff/reader.d @@ -29,7 +29,7 @@ import bio.sff.readrange; import bio.sff.constants; import bio.core.utils.stream; -import std.stream; +import undead.stream; import std.system; import std.range; import std.exception; diff --git a/bio/sff/readrange.d b/bio/sff/readrange.d index eda29d3..5f70f08 100644 --- a/bio/sff/readrange.d +++ b/bio/sff/readrange.d @@ -5,7 +5,7 @@ import bio.sff.index; import bio.core.utils.switchendianness; import std.algorithm; -import std.stream; +import undead.stream; import std.system; import std.array; diff --git a/bio/sff/writer.d b/bio/sff/writer.d index 7937d79..1ebd0ca 100644 --- a/bio/sff/writer.d +++ b/bio/sff/writer.d @@ -4,7 +4,7 @@ import bio.sff.constants; import bio.sff.utils.roundup; import bio.core.utils.stream; -import std.stream; +import undead.stream; import std.system; /// Class for outputting SFF files diff --git a/dub.json b/dub.json index ec26904..6135f32 100644 --- a/dub.json +++ b/dub.json @@ -8,5 +8,8 @@ "copyright": "Copyright © 2016, BioD developers", "license": "MIT", "sourcePaths": ["bio"], - "importPaths": ["bio"] + "importPaths": ["bio"], + "dependencies": { + "undead": "~>1.0.6" + } } diff --git a/examples/create_bam_from_scratch.d b/examples/create_bam_from_scratch.d index ad6053a..b011d93 100644 --- a/examples/create_bam_from_scratch.d +++ b/examples/create_bam_from_scratch.d @@ -3,7 +3,7 @@ // this example shows how to create BAM files from scratch import bio.bam.read, bio.bam.referenceinfo, bio.sam.header; import bio.bam.reader, bio.bam.writer; -import std.stream, std.stdio; +import undead.stream, std.stdio; void main() { auto header = new SamHeader(); // First, create SAM header diff --git a/test/unittests.d b/test/unittests.d index 4435008..cefa6a9 100644 --- a/test/unittests.d +++ b/test/unittests.d @@ -49,7 +49,7 @@ import bio.core.utils.roundbuf; import std.path; import std.range; import std.stdio; -import std.stream; +import undead.stream; import std.algorithm; import std.array; import std.conv; From 4901cda76512a1c819bc2f9ec2af7048ae9db80d Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 16 Dec 2016 13:30:13 +0000 Subject: [PATCH 3/9] std.c -> core.stdc --- bio/bam/bai/indexing.d | 2 +- bio/bam/read.d | 2 +- bio/bam/thirdparty/msgpack.d | 4 ++-- bio/bam/utils/array.d | 2 +- bio/core/bgzf/outputstream.d | 6 +++--- bio/core/utils/bylinefast.d | 2 +- bio/core/utils/format.d | 6 +++--- bio/core/utils/stream.d | 2 +- bio/sam/reader.d | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bio/bam/bai/indexing.d b/bio/bam/bai/indexing.d index 43e89d3..fec5662 100644 --- a/bio/bam/bai/indexing.d +++ b/bio/bam/bai/indexing.d @@ -35,7 +35,7 @@ import std.array; import std.algorithm; import std.system; import std.exception; -import std.c.string; +import core.stdc.string; // Suppose we have an alignment which covers bases on a reference, // starting from one position and ending at another position. diff --git a/bio/bam/read.d b/bio/bam/read.d index 6e81263..3f51dc8 100644 --- a/bio/bam/read.d +++ b/bio/bam/read.d @@ -72,7 +72,7 @@ import std.system; import std.traits; import std.array; import std.bitmanip; -import std.c.stdlib; +import core.stdc.stdlib; /** Represents single CIGAR operation diff --git a/bio/bam/thirdparty/msgpack.d b/bio/bam/thirdparty/msgpack.d index bf5ca5b..1032b33 100644 --- a/bio/bam/thirdparty/msgpack.d +++ b/bio/bam/thirdparty/msgpack.d @@ -59,7 +59,7 @@ else // for Converting Endian using ntohs and ntohl; version(Windows) { - import std.c.windows.winsock; + import core.stdc.windows.winsock; } else { @@ -82,7 +82,7 @@ static if (real.sizeof == double.sizeof) { import std.numeric; } -version(unittest) import std.file, std.c.string; +version(unittest) import std.file, core.stdc.string; @trusted: diff --git a/bio/bam/utils/array.d b/bio/bam/utils/array.d index 4e5f8a1..42000df 100644 --- a/bio/bam/utils/array.d +++ b/bio/bam/utils/array.d @@ -23,7 +23,7 @@ */ module bio.bam.utils.array; -import std.c.string; +import core.stdc.string; import std.traits; /// Modifies array in-place so that $(D slice) is replaced by diff --git a/bio/core/bgzf/outputstream.d b/bio/core/bgzf/outputstream.d index 89cbecb..ae335be 100644 --- a/bio/core/bgzf/outputstream.d +++ b/bio/core/bgzf/outputstream.d @@ -34,7 +34,7 @@ import std.parallelism; import std.array; import std.algorithm : max; import std.typecons; -import std.c.stdlib; +import core.stdc.stdlib; alias void delegate(ubyte[], ubyte[]) BlockWriteHandler; @@ -88,7 +88,7 @@ class BgzfOutputStream : Stream { // 1 extra block to which we can write while n_tasks are executed auto comp_buf_size = (2 * n_tasks + 2) * max_block_size; - auto p = cast(ubyte*)std.c.stdlib.malloc(comp_buf_size); + auto p = cast(ubyte*)core.stdc.stdlib.malloc(comp_buf_size); _compression_buffer = p[0 .. comp_buf_size]; _buffer = _compression_buffer[0 .. block_size]; _tmp = _compression_buffer[max_block_size .. max_block_size * 2]; @@ -210,7 +210,7 @@ class BgzfOutputStream : Stream { _stream.close(); writeable = false; - std.c.stdlib.free(_compression_buffer.ptr); + core.stdc.stdlib.free(_compression_buffer.ptr); } /// Adds EOF block. This function is called in close() method. diff --git a/bio/core/utils/bylinefast.d b/bio/core/utils/bylinefast.d index 50fb756..6a71520 100644 --- a/bio/core/utils/bylinefast.d +++ b/bio/core/utils/bylinefast.d @@ -6,7 +6,7 @@ module bio.core.utils.bylinefast; import std.stdio; import std.string: indexOf; -import std.c.string: memmove; +import core.stdc.string: memmove; /** Reads by line in an efficient way (10 times faster than File.byLine from std.stdio). diff --git a/bio/core/utils/format.d b/bio/core/utils/format.d index ae8b4e6..a3ac3f1 100644 --- a/bio/core/utils/format.d +++ b/bio/core/utils/format.d @@ -34,8 +34,8 @@ */ module bio.core.utils.format; -import std.c.stdio; -import std.c.stdlib; +import core.stdc.stdio; +import core.stdc.stdlib; import std.string; import std.traits; import std.array; @@ -161,7 +161,7 @@ private { if (isSomeString!T) { auto str = cast(const(char)[])s; - std.c.string.memcpy(sink, str.ptr, str.length); + core.stdc.string.memcpy(sink, str.ptr, str.length); sink += str.length; } diff --git a/bio/core/utils/stream.d b/bio/core/utils/stream.d index ee57fe7..b3f7d34 100644 --- a/bio/core/utils/stream.d +++ b/bio/core/utils/stream.d @@ -15,7 +15,7 @@ version(Posix){ version(Windows) { private import std.file; private import std.utf; - private import std.c.windows.windows; + private import core.stdc.windows.windows; extern (Windows) { DWORD GetFileType(HANDLE hFile); } diff --git a/bio/sam/reader.d b/bio/sam/reader.d index e7724ed..4302e9b 100644 --- a/bio/sam/reader.d +++ b/bio/sam/reader.d @@ -49,7 +49,7 @@ import std.typecons; import std.parallelism; import std.process; import std.exception; -import std.c.string; +import core.stdc.string; BamRead _parseSamRecord(Tuple!(char[], SamReader, OutBuffer) t) { auto r = parseAlignmentLine(cast(string)t[0], t[1]._header, t[2]); From 4394f15bfdda766dce69fd3f5711d05bae71a1bb Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 16 Dec 2016 14:25:58 +0000 Subject: [PATCH 4/9] fix deprecations and some warnings --- bio/bam/randomaccessmanager.d | 1 + bio/bam/read.d | 1 + bio/bam/reader.d | 2 +- bio/bam/snpcallers/maq.d | 2 +- bio/bam/tagvalue.d | 2 +- bio/bam/thirdparty/msgpack.d | 8 ++++---- bio/core/utils/format.d | 1 + bio/core/utils/outbuffer.d | 2 +- bio/core/utils/stream.d | 1 - bio/sam/header.d | 2 +- dub.json | 3 ++- 11 files changed, 14 insertions(+), 11 deletions(-) diff --git a/bio/bam/randomaccessmanager.d b/bio/bam/randomaccessmanager.d index e5beb4b..fcd5d62 100644 --- a/bio/bam/randomaccessmanager.d +++ b/bio/bam/randomaccessmanager.d @@ -50,6 +50,7 @@ import std.traits; import std.exception; import std.container; import std.parallelism; +static import std.file; debug { import std.stdio; diff --git a/bio/bam/read.d b/bio/bam/read.d index 3f51dc8..b2f8cd1 100644 --- a/bio/bam/read.d +++ b/bio/bam/read.d @@ -1579,6 +1579,7 @@ unittest { { import std.typecons; + static import bio.bam.thirdparty.msgpack; auto packer = bio.bam.thirdparty.msgpack.packer(Appender!(ubyte[])()); read.toMsgpack(packer); auto data = packer.stream.data; diff --git a/bio/bam/reader.d b/bio/bam/reader.d index 728ccb5..f1fb8d4 100644 --- a/bio/bam/reader.d +++ b/bio/bam/reader.d @@ -95,7 +95,7 @@ class BamReader : IBamSamReader { ------------------------------------------- */ this(undead.stream.Stream stream, - std.parallelism.TaskPool task_pool = std.parallelism.taskPool) { + TaskPool task_pool = taskPool) { _source_stream = new EndianStream(stream, Endian.littleEndian); _task_pool = task_pool; diff --git a/bio/bam/snpcallers/maq.d b/bio/bam/snpcallers/maq.d index 2cb8a4b..3eee066 100644 --- a/bio/bam/snpcallers/maq.d +++ b/bio/bam/snpcallers/maq.d @@ -5,7 +5,7 @@ module bio.bam.snpcallers.maq; */ import core.stdc.math; -import std.math : LN2, LN10, isnan; +import std.math : LN2, LN10, isNaN; import std.traits; import std.range; import std.algorithm; diff --git a/bio/bam/tagvalue.d b/bio/bam/tagvalue.d index dbd9aad..55adb1d 100644 --- a/bio/bam/tagvalue.d +++ b/bio/bam/tagvalue.d @@ -296,7 +296,7 @@ string injectOpCast() { } cs ~= `(is(T == string)) {` ~ - ` if (is_string) {` + ` if (is_string) {` ~ ` return bam_typeid == 'Z' ? u.Z : u.H;`~ ` } else if (is_integer || is_float || is_character) {`~ ` `~injectSwitchPrimitive("string")~ diff --git a/bio/bam/thirdparty/msgpack.d b/bio/bam/thirdparty/msgpack.d index 1032b33..8aea071 100644 --- a/bio/bam/thirdparty/msgpack.d +++ b/bio/bam/thirdparty/msgpack.d @@ -344,7 +344,7 @@ struct PackerImpl(Stream) if (isOutputRange!(Stream, ubyte) && isOutputRange!(St * Params: * withFieldName = serialize class / struct with field name */ - this(bool withFieldName = false) + this(bool withFieldName) { withFieldName_ = withFieldName; } @@ -3145,7 +3145,7 @@ struct Value * type = the type of value. */ @safe - this(Type type = Type.nil) + this(Type type) { this.type = type; } @@ -3617,7 +3617,7 @@ struct Value ret ^= value.toHash(); } return ret; - } catch assert(0); + } catch (Exception) assert(0); } } } @@ -4656,7 +4656,7 @@ mixin template MessagePackable(Members...) if (withFieldName) { packer.beginMap(this.tupleof.length); foreach (i, member; this.tupleof) { - pack(getFieldName!(typeof(this), i)); + packer.pack(getFieldName!(typeof(this), i)); packer.pack(member); } } else { diff --git a/bio/core/utils/format.d b/bio/core/utils/format.d index a3ac3f1..74bcfaf 100644 --- a/bio/core/utils/format.d +++ b/bio/core/utils/format.d @@ -36,6 +36,7 @@ module bio.core.utils.format; import core.stdc.stdio; import core.stdc.stdlib; +static import core.stdc.string; import std.string; import std.traits; import std.array; diff --git a/bio/core/utils/outbuffer.d b/bio/core/utils/outbuffer.d index 56c0879..983bb58 100644 --- a/bio/core/utils/outbuffer.d +++ b/bio/core/utils/outbuffer.d @@ -93,7 +93,7 @@ class OutBuffer { /// Responsibility that there's enough capacity is on the user void putUnsafe(T)(T bytes) if (is(T == ubyte[])) { _heap_ptr[_heap_used .. _heap_used + bytes.length] = bytes[]; - _heap_used += bytes.length;; + _heap_used += bytes.length; } /// ditto diff --git a/bio/core/utils/stream.d b/bio/core/utils/stream.d index b3f7d34..aafcd43 100644 --- a/bio/core/utils/stream.d +++ b/bio/core/utils/stream.d @@ -135,7 +135,6 @@ final class File: undead.stream.File { if (ret <= 0) { size = 0; throw new ReadException("read timeout"); - break; } } else { throw new ReadException(to!string(strerror(errno))); diff --git a/bio/sam/header.d b/bio/sam/header.d index 6f315e5..3d4697e 100644 --- a/bio/sam/header.d +++ b/bio/sam/header.d @@ -707,7 +707,7 @@ class SamHeader { JSONValue json; json.object = result; - sink.write(toJSON(&json)); + sink.write(toJSON(json)); } /// Packs message in the following format: diff --git a/dub.json b/dub.json index 6135f32..693e9c7 100644 --- a/dub.json +++ b/dub.json @@ -11,5 +11,6 @@ "importPaths": ["bio"], "dependencies": { "undead": "~>1.0.6" - } + }, + "buildRequirements": ["allowWarnings"] } From 05f86b887728a30128c68cb14012f84093132eac Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 16 Dec 2016 14:28:52 +0000 Subject: [PATCH 5/9] fix toHash signature --- bio/sam/header.d | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bio/sam/header.d b/bio/sam/header.d index 3d4697e..df88d64 100644 --- a/bio/sam/header.d +++ b/bio/sam/header.d @@ -8,10 +8,10 @@ the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -117,7 +117,7 @@ private { mixin template toSamMethod(string line_prefix, Field...) { void toSam(Sink)(auto ref Sink sink) const if (isSomeSink!Sink) { sink.write(line_prefix); - mixin(serializeFields!Field()); + mixin(serializeFields!Field()); } } @@ -132,9 +132,9 @@ private { mixin template toHashMethod(string struct_name, string id_field, Field...) { static if (id_field != null) { - hash_t toHash() const { + hash_t toHash() const nothrow @safe{ hash_t result = 1; - mixin(generateHashExpression!Field()); + mixin(generateHashExpression!Field()); return result; } @@ -195,12 +195,12 @@ private { } } - mixin template HeaderLineStruct(string struct_name, + mixin template HeaderLineStruct(string struct_name, string line_prefix, string id_field, - Field...) + Field...) { - mixin(`struct `~struct_name~`{ + mixin(`struct `~struct_name~`{ mixin structFields!Field; mixin parseStaticMethod!(struct_name, Field); mixin toSamMethod!(line_prefix, Field); @@ -359,7 +359,7 @@ class HeaderLineDictionary(T) { _index_to_id.length = _index_to_id.length - 1; _dict.remove(id); - _id_to_index.remove(id); + _id_to_index.remove(id); return true; } @@ -484,7 +484,7 @@ class SamHeader { try { sorting_order = to!SortingOrder(header_line.sorting_order); } catch (ConvException e) { - sorting_order = SortingOrder.unknown; + sorting_order = SortingOrder.unknown; // FIXME: should we do that silently? } } else { @@ -536,14 +536,14 @@ class SamHeader { core.memory.GC.enable(); } - + /// Format version string format_version; /// Sorting order SortingOrder sorting_order = SortingOrder.unknown; - /// Dictionary of @SQ lines. + /// Dictionary of @SQ lines. /// Removal is not allowed, you can only replace the whole dictionary. SqLineDictionary sequences() @property { if (_sequences is null) @@ -624,7 +624,7 @@ class SamHeader { sink.write(to!string(sorting_order)); } sink.write('\n'); - + for (size_t i = 0; i < sequences.length; i++) { auto sq_line = getSequence(i); sq_line.toSam(sink); @@ -713,7 +713,7 @@ class SamHeader { /// Packs message in the following format: /// $(BR) /// MsgPack array with elements - /// $(OL + /// $(OL /// $(LI format version - string) /// $(LI sorting order - string) /// $(LI @SQ lines - array of dictionaries) @@ -789,7 +789,7 @@ unittest { dict["zzz"] = zzz; header.sequences = dict; - assert(header.text == + assert(header.text == "@HD\tVN:1.4\tSO:coordinate\n@SQ\tSN:yay\tLN:111\n@SQ\tSN:zzz\tLN:222\tUR:ftp://nyan.cat\n"); assert(header.sequences == dict); From 0ec8d39d8f99e090055193a79997b93d3fcb35c4 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 16 Dec 2016 14:33:26 +0000 Subject: [PATCH 6/9] fix tabs/spaces in dub.json --- dub.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dub.json b/dub.json index 693e9c7..0ab0eaf 100644 --- a/dub.json +++ b/dub.json @@ -9,8 +9,8 @@ "license": "MIT", "sourcePaths": ["bio"], "importPaths": ["bio"], - "dependencies": { - "undead": "~>1.0.6" - }, - "buildRequirements": ["allowWarnings"] + "dependencies": { + "undead": "~>1.0.6" + }, + "buildRequirements": ["allowWarnings"] } From 27cbaadf3707728f18621970ba60fe9a4d5755aa Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 16 Dec 2016 14:35:27 +0000 Subject: [PATCH 7/9] better .travis.yml, uses dub test and tests ldc --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7b3485..5a09379 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ language: d -script: -- rdmd -unittest -d test/unittests.d + +d: + - dmd + - ldc From 3b7464d3b1ff647768d7da18f8d7ddf0c73c01f4 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 16 Dec 2016 14:37:10 +0000 Subject: [PATCH 8/9] test osx build --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5a09379..8706ecc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: d +os: + - linux + - osx + d: - dmd - ldc From 468c01931dcdade9478c6849e85a105c8930c604 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Fri, 16 Dec 2016 14:40:47 +0000 Subject: [PATCH 9/9] fix toJSON usage for new and old compilers --- bio/sam/header.d | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bio/sam/header.d b/bio/sam/header.d index df88d64..57054bf 100644 --- a/bio/sam/header.d +++ b/bio/sam/header.d @@ -707,7 +707,10 @@ class SamHeader { JSONValue json; json.object = result; - sink.write(toJSON(json)); + static if (__VERSION__ < 2072) + sink.write(toJSON(&json)); + else + sink.write(toJSON(json)); } /// Packs message in the following format: