[Genabel-commits] r1401 - in pkg/GenABEL/src: GAlib ITERlib

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 19 19:17:39 CET 2013


Author: maksim
Date: 2013-11-19 19:17:38 +0100 (Tue, 19 Nov 2013)
New Revision: 1401

Modified:
   pkg/GenABEL/src/GAlib/Chip.cpp
   pkg/GenABEL/src/GAlib/convert.snp.affymetrix.cpp
   pkg/GenABEL/src/GAlib/convert_snp_illumina.cpp
   pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp
   pkg/GenABEL/src/GAlib/convert_snp_merlin_wslash.cpp
   pkg/GenABEL/src/GAlib/convert_snp_tped.cpp
   pkg/GenABEL/src/GAlib/export_plink.cpp
   pkg/GenABEL/src/GAlib/gtps_container.cpp
   pkg/GenABEL/src/GAlib/gwaa.c
   pkg/GenABEL/src/GAlib/gwaa_cpp.cpp
   pkg/GenABEL/src/GAlib/interactions_rare_recesive_alleles.cpp
   pkg/GenABEL/src/GAlib/mematrix.h
   pkg/GenABEL/src/GAlib/reg1.h
   pkg/GenABEL/src/GAlib/reg1data.h
   pkg/GenABEL/src/ITERlib/iterator_functions.cpp
Log:
Fixed most of the issues reported by Mr. Jenkins: mostly unused variables, memory leak, and style.

Modified: pkg/GenABEL/src/GAlib/Chip.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/Chip.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/Chip.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -77,7 +77,7 @@
 
 file.close();
 
-delete buf;
+delete[] buf;
 
 }
 //__________________________________________________________
@@ -277,7 +277,7 @@
 
 
 file.close();
-delete buf;
+delete[] buf;
 }
 //__________________________________________________________
 

Modified: pkg/GenABEL/src/GAlib/convert.snp.affymetrix.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/convert.snp.affymetrix.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/convert.snp.affymetrix.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -229,8 +229,8 @@
 	outfile<<"\n";
 	}
 
-delete gtps_for_one_snp;	
-delete rearrangement_array;
+delete[] gtps_for_one_snp;	
+delete[] rearrangement_array;
 
 Rprintf("%i SNPs excluded bacause of absent in annotation\n", snp_excludet_from_output_data);
 Rprintf("Total %i SNPs are written into output file\n", snp_amount-snp_excludet_from_output_data);

Modified: pkg/GenABEL/src/GAlib/convert_snp_illumina.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/convert_snp_illumina.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/convert_snp_illumina.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -43,7 +43,7 @@
 	long unsigned int bcast = *Bcast;
 
 	bool loud = TRUE;
-	if (bcast <= 0) loud = FALSE;
+	//if (bcast <= 0) loud = FALSE;
 
 	long unsigned int nsnps=0;
 	long unsigned int nids=0;
@@ -100,13 +100,14 @@
 	//
 	//Processing rest of the file
 	//
+		
+	char gdata;
 
 	while (getline(illfile,data)) {
 		nsnps++;
 
 		istringstream datas (data);
 
-		char gdata;
 
 		if (!(datas >> tmp_snpnam >> tmp_chrom >> tmp_map))
 			error("First three fields are missing in line %i!\n",(nsnps+1));
@@ -238,7 +239,12 @@
 				lasti += 1;
 			}
 
+		delete [] gnum;
+		delete [] tmp_gtype;
 		}
+	
+	
+	
 	}
 
 	const ios_base::fmtflags hex = ios_base::hex;
@@ -294,13 +300,12 @@
 		}
 		outfile << endl;
 
-		delete [] tmp_gtype;
 	}
 
 	if (loud) {
 		Rprintf("... done.\n");
 	}
 
-
+    delete [] chgt;
 }
 }

Modified: pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -422,10 +422,12 @@
 		}
 		outfile << endl;
 
-		delete [] tmp_gtype;
 	}
 
-	if (verbose) {
+		delete [] gnum;
+		delete [] tmp_gtype;
+
+		if (verbose) {
 		Rprintf("... done.\n");
 	}
 

Modified: pkg/GenABEL/src/GAlib/convert_snp_merlin_wslash.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/convert_snp_merlin_wslash.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/convert_snp_merlin_wslash.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -435,8 +435,10 @@
 		}
 		outfile << endl;
 
-		delete [] tmp_gtype;
 	}
+	
+	delete [] tmp_gtype;
+	delete [] gnum;
 
 	if (verbose) {
 		Rprintf("... done.\n");

Modified: pkg/GenABEL/src/GAlib/convert_snp_tped.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/convert_snp_tped.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/convert_snp_tped.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -291,10 +291,12 @@
 		}
 		outfile << endl;
 
-		delete [] tmp_gtype;
 
 		//      gtype.pop_front();
 	} //while (!gtype.empty());
+		
+	delete [] tmp_gtype;
+	delete [] gnum;
 
 	if (verbose) {
 		Rprintf("... done.\n");

Modified: pkg/GenABEL/src/GAlib/export_plink.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/export_plink.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/export_plink.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -212,6 +212,7 @@
             }
         }
         fileWoA << "\n";
+    delete [] Genotype;
         //Rprintf("\n");
     }
     //Rprintf("B\n");
@@ -237,7 +238,6 @@
     //for (int i=0; i<10; i++) Rprintf("%d ",sex[i]);
     //Rprintf("oooo!\n" );
 
-    delete [] Genotype;
     delete [] gtint;
 
     return R_NilValue;

Modified: pkg/GenABEL/src/GAlib/gtps_container.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/gtps_container.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/gtps_container.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -33,8 +33,11 @@
 
 
 
+local_person_number = 0; // Mr. Jenkins likes when everything is initilized in constructor
+our_byte_number = 1;
 
 
+
 gtps_array = gtps_array_;	
 strand_array = strand_array_;
 coding_array = coding_array_;
@@ -60,9 +63,11 @@
 rearrangement_array[3] = 0;
 
 
+local_person_number = 0; // Mr. Jenkins likes when everything is initilized in constructor
+strand_array = NULL;
+our_byte_number = 1;
+coding_array = NULL;
 
-
-
 gtps_array = gtps_array_;	
 id_numbers = id_numbers_;
 snp_numbers = snp_numbers_;

Modified: pkg/GenABEL/src/GAlib/gwaa.c
===================================================================
--- pkg/GenABEL/src/GAlib/gwaa.c	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/gwaa.c	2013-11-19 18:17:38 UTC (rev 1401)
@@ -364,7 +364,7 @@
 	unsigned int nids = (*Nids);
 	unsigned int nsnps = (*Nsnps);
 	unsigned int gt[nids];
-	unsigned int count[2][4],R,S,N,r1,r2,n1,n2;
+	unsigned int count[2][4],R,N,r1,r2,n1,n2;//,S;
 	double mul, a, b, c, den;
 	char str;
 	unsigned int nbytes;
@@ -389,7 +389,7 @@
 		r1 = count[1][2]; r2 = count[1][3];
 		n1 = r1 + count[0][2]; n2 = r2 + count[0][3];
 		R = r1 + r2 + count[1][1];
-		S = count[0][1]+count[0][2]+count[0][3];
+		//S = count[0][1]+count[0][2]+count[0][3];
 		if (N>0 && R>0 && R<N) {
 			mul = (1.*N)/(1.*R*(N-R));
 			a = 1.*(n1+2.*n2);
@@ -513,7 +513,7 @@
 	int nbytes;
 	double Ttotg, mx, bb, dgt, totg[nstra], x2[nstra], sumx[nstra];
 	double Tsg1, Tsg2, sg1[nstra], sg2[nstra], xg1[nstra], xg2[nstra];
-	double det, u, v, u1, u2, v11, v12, v22;
+	double u, v, u1, u2, v11, v12, v22,det;
 	if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
 	//	char chgt[nbytes];
 
@@ -1028,7 +1028,7 @@
 	double sumOmegaJ[nids];
 	double YiSumOmegaij[nids];
 	double sumOmega = 0.;
-	double sumYiSumOmegaij = 0.;
+//	double sumYiSumOmegaij = 0.;
 	for (i=0;i<nids;i++) {
 		sumOmegaJ[i] = 0.;
 		YiSumOmegaij[i] = 0.;
@@ -1040,7 +1040,7 @@
 		}
 		sumOmega += sumOmegaJ[i];
 		YiSumOmegaij[j] = pheno[i]*sumOmegaJ[i];
-		sumYiSumOmegaij += YiSumOmegaij[j];
+//		sumYiSumOmegaij += YiSumOmegaij[j];
 		ePH[j] = sph[j]/nIndividuals[j];
 	}
 
@@ -1074,8 +1074,8 @@
 		}
 		double sumYSumGOmega = 0.;
 		double sumGSumGOmega = 0.;
-		double sumGSumOmega = 0.;
-		double SumSumGOmega = 0.;
+//		double sumGSumOmega = 0.;
+//		double SumSumGOmega = 0.;
 		double summand2y, summand3y, summand2g, summand3g, summand4;
 		summand2y = summand3y = summand2g = summand3g = summand4 = 0.;
 		for (i=0;i<nids;i++) {
@@ -1086,8 +1086,8 @@
 			}
 			sumYSumGOmega += pheno[i]*svec[i];
 			sumGSumGOmega += gtctr[i]*svec[i];
-			sumGSumOmega += gtctr[i]*sumOmegaJ[i];
-			SumSumGOmega += svec[i];
+//			sumGSumOmega += gtctr[i]*sumOmegaJ[i];
+//			SumSumGOmega += svec[i];
 			summand2y += eG[cstr]*YiSumOmegaij[i];
 			summand2g += eG[cstr]*gtctr[i]*sumOmegaJ[i];
 			summand3y += ePH[cstr]*svec[i];
@@ -1130,7 +1130,7 @@
 	int gt[nids];
 	int i, j, igt, i1=1;
 	int nbytes;
-	double Ttotg,dgt,svec[nids],gtctr[nids];
+	double Ttotg,svec[nids],gtctr[nids];//,dgt;
 	double Tsg;
 	double u, v;
 	if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
@@ -1184,8 +1184,8 @@
 		double SumSumGOmega = 0.;
 		double summand2y, summand3y, summand2g, summand3g, summand4;
 		summand2y = summand3y = summand2g = summand3g = summand4 = 0.;
-		int gtOffs[4];
-		gtOffs[0]=0;gtOffs[1]=nids*nids;gtOffs[2]=nids*nids*2;gtOffs[3]=nids*nids*3;
+//		int gtOffs[4];
+//		gtOffs[0]=0;gtOffs[1]=nids*nids;gtOffs[2]=nids*nids*2;gtOffs[3]=nids*nids*3;
 		for (i=0;i<nids;i++) {
 			svec[i] = 0.;
 			//			double * offS = &invS[nids*i];
@@ -1350,7 +1350,8 @@
 	unsigned int useFreq = (*UseFreq);
 	unsigned int gt[nids];
 	unsigned int count[4],sumgt=0.;
-	double varhomweight[4] = {0.,1.,1.,1.}, centgt[4], homweight[4] = {0.,1.,0.,1.},p0=0.,q0=0.,maf=0.;
+	double centgt[4], homweight[4] = {0.,1.,0.,1.},p0=0.,q0=0.,maf=0.;
+//	double varhomweight[4] = {0.,1.,1.,1.}, centgt[4], homweight[4] = {0.,1.,0.,1.},p0=0.,q0=0.,maf=0.;
 	double den, fel;
 	char str;
 	unsigned int nbytes;
@@ -1631,7 +1632,7 @@
 void comp_qval(double *p, int *Length, double *out) {
 	int length = (*Length);
 	int i; 
-	double sum,max=-1,min,minvec[length];
+	double sum,max=-1,minvec[length];//,min;
 	for (i=0;i<length;i++) out[i]=0.;
 	for (i=0;i<length;i++) {
 		sum = i+1;
@@ -1643,7 +1644,7 @@
 		if (out[i] < minvec[i+1]) minvec[i]=out[i]; else minvec[i]=minvec[i+1];
 	}
 	for (i=0;i<length;i++) {
-		min = max;
+		//min = max;
 		if (out[i]<minvec[i]) out[i]=out[i]; else out[i]=minvec[i];
 	}
 }
@@ -1653,7 +1654,7 @@
 void r2new(char *indata, unsigned int *Nids, unsigned int *Nsnps, unsigned int *Nsnps1, unsigned int *snps1, unsigned int *Nsnps2, unsigned int *snps2, double *out) {
 	unsigned int i,j,m1,m2,idx;
 	unsigned int nids = (*Nids);
-	unsigned int nsnps = (*Nsnps);
+//	unsigned int nsnps = (*Nsnps);
 	unsigned int nsnps1 = (*Nsnps1);
 	unsigned int nsnps2 = (*Nsnps2);
 	unsigned int gt[2][nids],cgt[4][4],nAA,nAB,nBA,nBB,nDH;

Modified: pkg/GenABEL/src/GAlib/gwaa_cpp.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/gwaa_cpp.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/gwaa_cpp.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -154,7 +154,7 @@
 		//unsigned int nids = (*Nids);
 		//char str;
 		unsigned int count[3];
-		double meaids,p,pmax,qmax,maf,fmax,loglik0,loglik1,chi2lrt;
+		double meaids,p;
 		count[0]=count[1]=count[2]=0;
 		p = 0.;
 		for (i=0;i<9;i++) out[i] = 0.;
@@ -175,6 +175,7 @@
 		out[4] = count[1];
 		out[5] = count[2];
 		if (meaids>0) {
+			double qmax, maf, pmax, loglik0, loglik1, chi2lrt, fmax;
 			out[6] = SNPHWE(count[1],count[0],count[2]);
 			pmax = out[2];
 			qmax = 1.-pmax;

Modified: pkg/GenABEL/src/GAlib/interactions_rare_recesive_alleles.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/interactions_rare_recesive_alleles.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/interactions_rare_recesive_alleles.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -106,8 +106,8 @@
 window_current = snp_number - central_snp_position;
 if(window_current > window) window_current=window;
 
-if(central_snp_position >= snp_number || central_snp_position <0) {Rprintf("snp_snp_interaction_results::push_chi2: error: central_snp_position is out of bound"); return -1;}
-if(window_snp_position > window_current || window_snp_position<0) {Rprintf("snp_snp_interaction_results::push_chi2: error: window is out of bound"); return -1;}	
+if(central_snp_position >= snp_number) {Rprintf("snp_snp_interaction_results::push_chi2: error: central_snp_position is out of bound"); return -1;}
+if(window_snp_position > window_current) {Rprintf("snp_snp_interaction_results::push_chi2: error: window is out of bound"); return -1;}	
 chi2_results[central_snp_position][window_snp_position] = chi2;
 //std::cout<<"snp_snp_interaction_results::push_chi2 end\n";
 return 0;
@@ -618,8 +618,8 @@
 
 UNPROTECT(1);
 
-delete snp1;
-delete snp2;
+delete [] snp1;
+delete [] snp2;
 
 return(results_R);
 } //end of interaction_rare_recesive_allele_C_

Modified: pkg/GenABEL/src/GAlib/mematrix.h
===================================================================
--- pkg/GenABEL/src/GAlib/mematrix.h	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/mematrix.h	2013-11-19 18:17:38 UTC (rev 1401)
@@ -11,7 +11,7 @@
 	int nelements;
 	DT * data;
 
-	mematrix() {nrow=ncol=nelements=0;}
+	mematrix() {nrow=ncol=nelements=0;data=NULL;}
 	mematrix(int nr, int nc);
 	mematrix(const mematrix &M);
 	~mematrix() {if (nelements>0) delete [] data;}

Modified: pkg/GenABEL/src/GAlib/reg1.h
===================================================================
--- pkg/GenABEL/src/GAlib/reg1.h	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/reg1.h	2013-11-19 18:17:38 UTC (rev 1401)
@@ -152,6 +152,7 @@
 	double sigma2;
 	coxph_reg(coxph_data cdata, int maxiter, double eps, double tol_chol)
 	{
+		sigma2 = 0;
 		beta.reinit(cdata.X.nrow,1);
 		sebeta.reinit(cdata.X.nrow,1);
 		mematrix<double> newoffset = cdata.offset;

Modified: pkg/GenABEL/src/GAlib/reg1data.h
===================================================================
--- pkg/GenABEL/src/GAlib/reg1data.h	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/GAlib/reg1data.h	2013-11-19 18:17:38 UTC (rev 1401)
@@ -82,6 +82,7 @@
 
 	coxph_data(regdata regdat) 
 	{
+		maxiter = 0;
 		nids = regdat.nids;
 		ncov = regdat.ncov;
 		if (regdat.noutcomes != 2)

Modified: pkg/GenABEL/src/ITERlib/iterator_functions.cpp
===================================================================
--- pkg/GenABEL/src/ITERlib/iterator_functions.cpp	2013-11-19 16:01:40 UTC (rev 1400)
+++ pkg/GenABEL/src/ITERlib/iterator_functions.cpp	2013-11-19 18:17:38 UTC (rev 1401)
@@ -276,6 +276,8 @@
                 delete [] xg1;
                 delete [] xg2;
 
+
+
         }
 
 #ifdef __cplusplus



More information about the Genabel-commits mailing list