Skip to content

Commit

Permalink
Windows compatibility changes:
Browse files Browse the repository at this point in the history
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
  • Loading branch information
charlesgregory committed Aug 12, 2020
1 parent a4c8f86 commit d5b24b9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 36 deletions.
32 changes: 28 additions & 4 deletions source/dhtslib/htslib/hts.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 0 additions & 27 deletions source/dhtslib/htslib/sam.d
Original file line number Diff line number Diff line change
Expand Up @@ -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 ***
**********************/
Expand Down
8 changes: 4 additions & 4 deletions source/dhtslib/htslib/vcf.d
Original file line number Diff line number Diff line change
Expand Up @@ -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; /// ???
Expand Down
2 changes: 1 addition & 1 deletion source/dhtslib/sam.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit d5b24b9

Please sign in to comment.