From f61ec5c7fb599905beccf1631781615e69296b33 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Sat, 21 Sep 2024 20:29:18 -0700 Subject: [PATCH] apply patch suggested by @maxcoulter This will fix #363 --- ChangeLog | 7 +++++++ DESCRIPTION | 2 +- R/glHandle.R | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d9eceeb..1c50356 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ + CHANGES IN ADEGENET VERSION 2.1.11 + +BUG FIX + +- genlight objects subset without any arguments to loci no longer gain an + extra byte. (reported: @maxcoulter, #363) + CHANGES IN ADEGENET VERSION 2.1.10 CRAN MAINTENANCE diff --git a/DESCRIPTION b/DESCRIPTION index 075e7e0..9a568e1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: adegenet Title: Exploratory Analysis of Genetic and Genomic Data -Version: 2.1.10 +Version: 2.1.11 Authors@R: c(person(given = "Thibaut", family = "Jombart", diff --git a/R/glHandle.R b/R/glHandle.R index 2971fae..dc7c105 100644 --- a/R/glHandle.R +++ b/R/glHandle.R @@ -4,7 +4,10 @@ # Take a raw vector, subset the bits and then convert to integers. xint <- as.integer(rawToBits(x)[i]) # Figure out how many zeroes are needed to pad the end. - zeroes <- 8 - (length(xint) %% 8) + extra_bits <- length(xint) %% 8 + # https://github.com/thibautjombart/adegenet/issues/363 + # Fix to a bug caught by @maxcoulter. In the case + zeroes <- if (extra_bits > 0) 8 - extra_bits else 0 # Convert the integer vector with zeroes on the end back into a raw vector. return(packBits(c(xint, rep(0L, zeroes)))) }