[Genabel-commits] r968 - pkg/ProbABEL/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Oct 4 00:07:30 CEST 2012


Author: lckarssen
Date: 2012-10-04 00:07:30 +0200 (Thu, 04 Oct 2012)
New Revision: 968

Modified:
   pkg/ProbABEL/src/data.h
   pkg/ProbABEL/src/main.cpp
Log:
In ProbABEL: Fixed a lot of compiler warnings. Mostly by replacing ints with unsigned ints, for example for nids, nsnps. This makes perfect sense and serves as extra sanity check on our data. 



Modified: pkg/ProbABEL/src/data.h
===================================================================
--- pkg/ProbABEL/src/data.h	2012-10-03 21:41:24 UTC (rev 967)
+++ pkg/ProbABEL/src/data.h	2012-10-03 22:07:30 UTC (rev 968)
@@ -291,17 +291,17 @@
 class gendata
 {
 public:
-    int nsnps;
-    int nids;
-    int ngpreds;
+    unsigned int nsnps;
+    unsigned int nids;
+    unsigned int ngpreds;
     gendata();
-    void re_gendata(char * fname, int insnps, int ingpreds,
-		    int npeople, int nmeasured,
+    void re_gendata(char * fname, unsigned int insnps, unsigned int ingpreds,
+		    unsigned int npeople, unsigned int nmeasured,
 		    unsigned short int * allmeasured,
 		    int skipd,
 		    std::string * idnames);
-    void re_gendata(string filename, int insnps, int ingpreds,
-		    int npeople, int nmeasured,
+    void re_gendata(string filename, unsigned int insnps, unsigned int ingpreds,
+		    unsigned int npeople, unsigned int nmeasured,
 		    unsigned short int * allmeasured,
 		    std::string * idnames);
     ~gendata();
@@ -335,8 +335,10 @@
     nsnps=nids=ngpreds=0;
 }
 
-void gendata::re_gendata(string filename, int insnps, int ingpreds, int npeople,
-			 int nmeasured, unsigned short int * allmeasured,
+void gendata::re_gendata(string filename, unsigned int insnps,
+			 unsigned int ingpreds, unsigned int npeople,
+			 unsigned int nmeasured,
+			 unsigned short int * allmeasured,
 			 std::string * idnames)
 {
     nsnps = insnps;
@@ -370,9 +372,11 @@
 
 }
 
-void gendata::re_gendata(char * fname, int insnps, int ingpreds,
-			 int npeople, int nmeasured,
-			 unsigned short int * allmeasured, int skipd,
+void gendata::re_gendata(char * fname, unsigned int insnps,
+			 unsigned int ingpreds, unsigned int npeople,
+			 unsigned int nmeasured,
+			 unsigned short int * allmeasured,
+			 int skipd,
 			 std::string * idnames)
 {
     nids = nmeasured;
@@ -394,7 +398,7 @@
     std::string tmpid,tmpstr;
 
     int k = 0;
-    for (int i = 0; i<npeople; i++)
+    for (unsigned int i = 0; i<npeople; i++)
 	if (allmeasured[i]==1)
 	{
 	    if (skipd>0)
@@ -425,7 +429,7 @@
 	    for (int j=1;j<skipd;j++) {
 		infile >> tmp;
 	    }
-	    for (int j=0; j<(nsnps*ngpreds); j++)
+	    for (unsigned int j=0; j<(nsnps*ngpreds); j++)
 	    {
 		if (infile.good())
 		{
@@ -445,7 +449,7 @@
 	{
 	    for (int j=0; j<skipd; j++)
 		infile >> tmp;
-	    for (int j=0; j<(nsnps*ngpreds); j++)
+	    for (unsigned int j=0; j<(nsnps*ngpreds); j++)
 		infile >> tmp;
 	}
     infile.close();
@@ -600,9 +604,21 @@
 {
     double el1 = *(double*)a;
     double el2 = *(double*)b;
-    if (el1>el2) return 1;
-    if (el1<el2) return -1;
-    if (el1==el2) return 0;
+    if (el1 > el2)
+    {
+	return 1;
+    }
+    if (el1 < el2)
+    {
+	return -1;
+    }
+    if (el1 == el2)
+    {
+	return 0;
+    }
+
+    // You should never come here...
+    return -9;
 }
 
 

Modified: pkg/ProbABEL/src/main.cpp
===================================================================
--- pkg/ProbABEL/src/main.cpp	2012-10-03 21:41:24 UTC (rev 967)
+++ pkg/ProbABEL/src/main.cpp	2012-10-03 22:07:30 UTC (rev 968)
@@ -459,7 +459,7 @@
 
 	    //Header
 	    //_____________________
-	    for(int i=0 ; i<outfile.size() ; i++)
+	    for(unsigned int i=0 ; i<outfile.size() ; i++)
 	    {
 		(*outfile[i]) << "name" << sep << "A1" << sep << "A2" << sep << "Freq1" << sep << "MAF"
 			      << sep << "Quality" << sep << "Rsq" << sep << "n" << sep
@@ -471,7 +471,7 @@
 
 	    if(allcov) //All covariates in output
 	    {
-		for (int file=0; file<outfile.size() ; file++)
+		for (unsigned int file=0; file<outfile.size() ; file++)
 		    for (int i =0; i<phd.n_model_terms-1;i++)
 			*outfile[file] << sep << "beta_" << phd.model_terms[i] << sep
 				       << "sebeta_" << phd.model_terms[i];
@@ -499,7 +499,7 @@
 		}
 #endif
 		//Oct 26, 2009
-		for (int file=1; file<outfile.size() ; file++)
+		for (unsigned int file=1; file<outfile.size() ; file++)
 		{
 		    *outfile[file] << sep << "beta_SNP_" << phd.model_terms[interaction_cox]  << sep
 				   << "sebeta_SNP_" << phd.model_terms[interaction_cox];
@@ -735,13 +735,13 @@
 	    //		freq = ((gtd.G).column_mean(csnp*2)*2.+(gtd.G).column_mean(csnp*2+1))/2.;
 	    gtd.get_var(csnp*2,snpdata1);
 	    gtd.get_var(csnp*2+1,snpdata2);
-	    for (int ii=0;ii<gtd.nids;ii++)
+	    for (unsigned int ii=0;ii<gtd.nids;ii++)
 		if (!isnan(snpdata1[ii]) && !isnan(snpdata2[ii]))
 		{gcount++;freq+=snpdata1[ii]+snpdata2[ii]*0.5;}
 	} else {
 	    //		freq = (gtd.G).column_mean(csnp)/2.;
 	    gtd.get_var(csnp,snpdata1);
-	    for (int ii=0;ii<gtd.nids;ii++)
+	    for (unsigned int ii=0;ii<gtd.nids;ii++)
 		if (!isnan(snpdata1[ii]))
 		{gcount++;freq+=snpdata1[ii]*0.5;}
 	}
@@ -755,7 +755,7 @@
 	if(ngpreds==2) //All models output. One file per each model
 	{
 	    //Write mlinfo to output:
-	    for(int file=0 ; file<outfile.size() ; file++)
+	    for(unsigned int file=0 ; file<outfile.size() ; file++)
 	    {
 		*outfile[file] << mli.name[csnp] << sep << mli.A1[csnp] << sep << mli.A2[csnp] << sep
 			       << mli.Freq1[csnp] << sep << mli.MAF[csnp] << sep << mli.Quality[csnp] << sep
@@ -1076,7 +1076,7 @@
 
 
 
-    for(int i=0 ; i<outfile.size() ; i++)
+    for(unsigned int i=0 ; i<outfile.size() ; i++)
     {
 	outfile[i]->close();
 	delete outfile[i];



More information about the Genabel-commits mailing list