[Genabel-commits] r1595 - pkg/OmicABEL/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 5 17:36:00 CET 2014


Author: dfabregat
Date: 2014-02-05 17:35:59 +0100 (Wed, 05 Feb 2014)
New Revision: 1595

Modified:
   pkg/OmicABEL/src/GWAS.c
   pkg/OmicABEL/src/databel.h
Log:
Resolving an old request from Yurii:
    "can we check for the data type prior to the run and 
	 issue an warning in case we have eg float and not double?"

Now this is checked during the initialization of the structures
prior to the actual run of the simulation.



Modified: pkg/OmicABEL/src/GWAS.c
===================================================================
--- pkg/OmicABEL/src/GWAS.c	2014-02-04 21:00:43 UTC (rev 1594)
+++ pkg/OmicABEL/src/GWAS.c	2014-02-05 16:35:59 UTC (rev 1595)
@@ -195,4 +195,28 @@
 	assert( cf->XL_fvi->fvi_header.numObservations == cf->Phi_fvi->fvi_header.numObservations );
 	assert( cf->XL_fvi->fvi_header.numObservations == cf->Phi_fvi->fvi_header.numVariables );
 	// Assert type is double
+	if ( cf->Phi_fvi->fvi_header.type != DOUBLE_TYPE )
+	{
+		fprintf(stderr, "[ERROR] Phi data is stored in %s format\n", TYPE2STR(cf->Phi_fvi->fvi_header.type));
+		fprintf(stderr, "[ERROR] Data must be provided in DOUBLE format. Exiting...");
+		exit(-1);
+	}
+	if ( cf->XL_fvi->fvi_header.type != DOUBLE_TYPE )
+	{
+		fprintf(stderr, "[ERROR] XL data is stored in %s format\n", TYPE2STR(cf->XL_fvi->fvi_header.type));
+		fprintf(stderr, "[ERROR] Data must be provided in DOUBLE format. Exiting...");
+		exit(-1);
+	}
+	if ( cf->XR_fvi->fvi_header.type != DOUBLE_TYPE )
+	{
+		fprintf(stderr, "[ERROR] XR data is stored in %s format\n", TYPE2STR(cf->XR_fvi->fvi_header.type));
+		fprintf(stderr, "[ERROR] Data must be provided in DOUBLE format. Exiting...");
+		exit(-1);
+	}
+	if ( cf->Y_fvi->fvi_header.type != DOUBLE_TYPE )
+	{
+		fprintf(stderr, "[ERROR] Y data is stored in %s format\n", TYPE2STR(cf->Y_fvi->fvi_header.type));
+		fprintf(stderr, "[ERROR] Data must be provided in DOUBLE format. Exiting...");
+		exit(-1);
+	}
 }

Modified: pkg/OmicABEL/src/databel.h
===================================================================
--- pkg/OmicABEL/src/databel.h	2014-02-04 21:00:43 UTC (rev 1594)
+++ pkg/OmicABEL/src/databel.h	2014-02-05 16:35:59 UTC (rev 1595)
@@ -25,15 +25,28 @@
 #ifndef DATABEL_H
 #define DATABEL_H
 
-enum datatype{ UNSIGNED_SHORT_INT_TYPE = 1,
-               SHORT_INT_TYPE,
-               UNSIGNED_INT_TYPE,
-               INT_TYPE,
-               FLOAT_TYPE,
-               DOUBLE_TYPE,
-               SIGNED_CHAR_TYPE,
-               UNSIGNED_CHAR_TYPE };
+enum datatype { UNSIGNED_SHORT_INT_TYPE = 1,
+                SHORT_INT_TYPE,
+                UNSIGNED_INT_TYPE,
+                INT_TYPE,
+                FLOAT_TYPE,
+                DOUBLE_TYPE,
+                SIGNED_CHAR_TYPE,
+                UNSIGNED_CHAR_TYPE };
 
+static char *type_string[8] = {
+	"UNSIGNED SHORT INT",
+	"SHORT_INT",
+	"UNSIGNED_INT",
+	"INT",
+	"FLOAT",
+	"DOUBLE",
+	"SIGNED CHAR",
+	"UNSIGNED CHAR"
+};
+
+#define TYPE2STR(TYPE) (type_string[TYPE-1])
+
 #define NAMELENGTH 32
 #define RESERVEDSPACE 5
 



More information about the Genabel-commits mailing list