From d5b24b957cb0c0b4cebedc2821d10aad72c8d07d Mon Sep 17 00:00:00 2001 From: charlesgregory Date: Wed, 12 Aug 2020 11:47:39 -0400 Subject: [PATCH] Windows compatibility changes: windows doesn't like uint32_t so changed to uint windows doesn't like casting ulong to uint (unsure why it was casting anyway. maybe 32 bit build?) moved some compatibilty code from dhtslib.htslib.sam.d to dhtslib.htslib.hts.d where it belongs Now unittests compile (DMD and LDC) so I assume most code compiles on windows closes #38 for now --- source/dhtslib/htslib/hts.d | 32 ++++++++++++++++++++++++++++---- source/dhtslib/htslib/sam.d | 27 --------------------------- source/dhtslib/htslib/vcf.d | 8 ++++---- source/dhtslib/sam.d | 2 +- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/source/dhtslib/htslib/hts.d b/source/dhtslib/htslib/hts.d index 0845b7a..ec2aa22 100644 --- a/source/dhtslib/htslib/hts.d +++ b/source/dhtslib/htslib/hts.d @@ -335,18 +335,42 @@ The input character may be either an IUPAC ambiguity code, '=' for 0, or '0'/'1'/'2'/'3' for a result of 1/2/4/8. The result is encoded as 1/2/4/8 for A/C/G/T or combinations of these bits for ambiguous bases. */ -extern const(char)[256] seq_nt16_table; + +version(Windows){ + const (char)[256] seq_nt16_table = [ + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, + 1, 2, 4, 8, 15,15,15,15, 15,15,15,15, 15, 0 /*=*/,15,15, + 15, 1,14, 2, 13,15,15, 4, 11,15,15,12, 15, 3,15,15, + 15,15, 5, 6, 8,15, 7, 9, 15,10,15,15, 15,15,15,15, + 15, 1,14, 2, 13,15,15, 4, 11,15,15,12, 15, 3,15,15, + 15,15, 5, 6, 8,15, 7, 9, 15,10,15,15, 15,15,15,15, + + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, + 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15 + ]; +}else{ + extern const(char)[256] seq_nt16_table; +} /**! @abstract Table for converting a 4-bit encoded nucleotide to an IUPAC ambiguity code letter (or '=' when given 0). */ -extern __gshared const(char)[16] seq_nt16_str; +version(Windows) __gshared const (char)[16] seq_nt16_str = ['=','A','C','M','G','R','S','V','T','W','Y','H','K','D','B','N']; +else extern __gshared const(char)[16] seq_nt16_str; /**! @abstract Table for converting a 4-bit encoded nucleotide to about 2 bits. Returns 0/1/2/3 for 1/2/4/8 (i.e., A/C/G/T), or 4 otherwise (0 or ambiguous). */ -extern const int[] seq_nt16_int; - +version(Windows) const (int)[16] seq_nt16_int = [ 4, 0, 1, 4, 2, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4 ]; +else extern const int[] seq_nt16_int; /**! @abstract Get the htslib version number @return For released versions, a string like "N.N[.N]"; or git describe diff --git a/source/dhtslib/htslib/sam.d b/source/dhtslib/htslib/sam.d index 98369f5..41f5b75 100644 --- a/source/dhtslib/htslib/sam.d +++ b/source/dhtslib/htslib/sam.d @@ -66,33 +66,6 @@ import dhtslib.htslib.kstring: __kstring_t, kstring_t; /// Highest SAM format version supported by this library auto SAM_FORMAT_VERSION = "1.6"c; -// For whatever reason, these are neccessary on windows builds -version(Windows){ - const ubyte[256] seq_nt16_table = [ - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 1, 2, 4, 8, 15,15,15,15, 15,15,15,15, 15, 0 /*=*/,15,15, - 15, 1,14, 2, 13,15,15, 4, 11,15,15,12, 15, 3,15,15, - 15,15, 5, 6, 8,15, 7, 9, 15,10,15,15, 15,15,15,15, - 15, 1,14, 2, 13,15,15, 4, 11,15,15,12, 15, 3,15,15, - 15,15, 5, 6, 8,15, 7, 9, 15,10,15,15, 15,15,15,15, - - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, - 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15 - ]; - - const char[16] seq_nt16_str = ['=','A','C','M','G','R','S','V','T','W','Y','H','K','D','B','N']; - - const int[16] seq_nt16_int = [ 4, 0, 1, 4, 2, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4 ]; -} - /********************** *** SAM/BAM header *** **********************/ diff --git a/source/dhtslib/htslib/vcf.d b/source/dhtslib/htslib/vcf.d index 424e528..ee89525 100644 --- a/source/dhtslib/htslib/vcf.d +++ b/source/dhtslib/htslib/vcf.d @@ -248,12 +248,12 @@ struct bcf1_t { // @suppress(dscanner.style.phobos_naming_convention) float qual; /// QUAL mixin(bitfields!( - uint32_t, "n_info", 16, - uint32_t, "n_allele", 16)); + uint, "n_info", 16, /// For whatever reason, windows doesn't like uint32_t + uint, "n_allele", 16)); mixin(bitfields!( - uint32_t, "n_fmt", 8, - uint32_t, "n_sample", 24)); + uint, "n_fmt", 8, /// For whatever reason, windows doesn't like uint32_t + uint, "n_sample", 24)); kstring_t _shared; /// ??? (name mangled due to D reserved keyword shared) kstring_t indiv; /// ??? diff --git a/source/dhtslib/sam.d b/source/dhtslib/sam.d index dd86b17..24a6b52 100644 --- a/source/dhtslib/sam.d +++ b/source/dhtslib/sam.d @@ -1031,7 +1031,7 @@ private char* reverse(char* str) { import core.stdc.string : strlen; - ulong i = strlen(str) - 1, j = 0; + auto i = strlen(str) - 1, j = 0; char ch; while (i > j) {