[adegenet-commits] r820 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 24 14:24:12 CET 2011


Author: jombart
Date: 2011-02-24 14:24:11 +0100 (Thu, 24 Feb 2011)
New Revision: 820

Modified:
   pkg/src/GLfunctions.c
   pkg/src/snpbin.c
Log:
First attempt of GLsumInt - compute sum of alleles per loci in C.


Modified: pkg/src/GLfunctions.c
===================================================================
--- pkg/src/GLfunctions.c	2011-02-24 12:44:47 UTC (rev 819)
+++ pkg/src/GLfunctions.c	2011-02-24 13:24:11 UTC (rev 820)
@@ -75,6 +75,39 @@
 
 
 
+
+
+
+void GLsumInt(unsigned char *gen, int *nbvecperind, int *byteveclength, int *nbnaperind, int *naposi, int *nind, int *nloc, int *ploidy, int *res){
+	struct genlightC dat;
+	int i, j;
+	int *vecIntTemp;
+	vecIntTemp = (int *) calloc(*nloc, sizeof(int));
+	
+	/* set res to zeros */
+	for(j=0;j< *nloc;j++){
+		res[j] = 0;
+	}
+
+	/* 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-1); i++){ /* for all individuals*/
+		/* conversion to integers of current indiv */
+		snpbin2intvec(&(dat.x[i]), vecIntTemp);
+		
+		for(j=0; j < *nloc; j++){ /* for all loci */
+			if(!snpbin_isna(&(dat.x[i]), j)) res[j] += vecIntTemp[j];
+		}
+	}
+}
+
+
+
+
+
 /* TESTING in R */
 
 /*

Modified: pkg/src/snpbin.c
===================================================================
--- pkg/src/snpbin.c	2011-02-24 12:44:47 UTC (rev 819)
+++ pkg/src/snpbin.c	2011-02-24 13:24:11 UTC (rev 820)
@@ -377,7 +377,7 @@
 	vecx = (int *) calloc(P, sizeof(int));
 	vecy = (int *) calloc(P, sizeof(int));
 
-	/* conversion to integers or frequencies*/
+	/* conversion to integers */
 	snpbin2intvec(x, (int *) vecx);
 	snpbin2intvec(y, (int *) vecy);
 



More information about the adegenet-commits mailing list