[adegenet-commits] r830 - in pkg: R src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 1 12:57:12 CET 2011


Author: jombart
Date: 2011-03-01 12:57:12 +0100 (Tue, 01 Mar 2011)
New Revision: 830

Modified:
   pkg/R/SNPbin.R
   pkg/src/GLfunctions.c
   pkg/src/snpbin.c
Log:
All bugs seem fixed now.
glSim OK
glPca OK
glSum OK


Modified: pkg/R/SNPbin.R
===================================================================
--- pkg/R/SNPbin.R	2011-03-01 11:12:30 UTC (rev 829)
+++ pkg/R/SNPbin.R	2011-03-01 11:57:12 UTC (rev 830)
@@ -672,8 +672,8 @@
 ## convert SNPbin to integers (0/1/2...)
 .SNPbin2int <- function(x){
     ##res <- lapply(x at snp, .raw2bin)
-    
-    res <- .C("bytesToInt", unlist(x at snp), length(x at snp[[1]]), length(x at snp), integer(nLoc(x)), as.integer(nLoc(x)), PACKAGE="adegenet")[[4]][1:nLoc(x)]
+    resSize <- length(x at snp[[1]])*8
+    res <- .C("bytesToInt", unlist(x at snp), length(x at snp[[1]]), length(x at snp), integer(resSize), as.integer(resSize), PACKAGE="adegenet")[[4]][1:nLoc(x)]
     ##res <- lapply(res, function(e) e[1:x at n.loc])
     ##res <- as.integer(Reduce("+", res))
     if(length(x at NA.posi)>0){

Modified: pkg/src/GLfunctions.c
===================================================================
--- pkg/src/GLfunctions.c	2011-03-01 11:12:30 UTC (rev 829)
+++ pkg/src/GLfunctions.c	2011-03-01 11:57:12 UTC (rev 830)
@@ -92,6 +92,7 @@
 	/* Internal C representation of the genlight object */
 	dat = genlightTogenlightC(gen, nbvecperind, byteveclength, nbnaperind, naposi, nind, nloc, ploidy);
 
+
 	/* === working on frequencies === */
 	/* Lower triangle - without the diagonal */
 	for(i=0; i < (*nind); i++){ /* for all individuals*/

Modified: pkg/src/snpbin.c
===================================================================
--- pkg/src/snpbin.c	2011-03-01 11:12:30 UTC (rev 829)
+++ pkg/src/snpbin.c	2011-03-01 11:57:12 UTC (rev 830)
@@ -310,8 +310,10 @@
 /* transform a snpbin into a vector of integers */
 void snpbin2intvec(struct snpbin *x, int *out){
 	int *temp;
+	temp= (int *) calloc(1, sizeof(int));
 	*temp=nLoc(x);
 	bytesToInt(x->bytevec, x->byteveclength, x->bytevecnb, out, temp);
+	free(temp);
 /*reminders:
 - void bytesToInt(unsigned char *vecbytes, int *veclength, int *nbvec, int *vecres, int reslength){
 - snpbin: unsigned char *bytevec; int *byteveclength, *bytevecnb, *nloc, *nanb, *naposi; */
@@ -323,6 +325,7 @@
 void snpbin2freq(struct snpbin *x, double *out){
 	double ploid = (double) ploidy(x);
 	int *temp;
+	temp= (int *) calloc(1, sizeof(int));
 	*temp=nLoc(x);
 	bytesToDouble(x->bytevec, x->byteveclength, x->bytevecnb, out, temp);
 	int i;
@@ -330,6 +333,7 @@
 	for(i=0; i < nLoc(x); i++){
 		out[i] = out[i] / ploid;
 	}
+	free(temp);
 /*reminders:
 - void bytesToInt(unsigned char *vecbytes, int *veclength, int *nbvec, int *vecres, int reslength){
 - snpbin: unsigned char *bytevec; int *byteveclength, *bytevecnb, *nloc, *nanb, *naposi; */



More information about the adegenet-commits mailing list