[Genabel-commits] r703 - pkg/GenABEL/src/GAlib
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Mar 30 18:33:24 CEST 2011
Author: lckarssen
Date: 2011-03-30 18:33:24 +0200 (Wed, 30 Mar 2011)
New Revision: 703
Modified:
pkg/GenABEL/src/GAlib/convert_snp_illumina.cpp
pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp
Log:
Changed MAXSNPS to more reasonable values.
Modified: pkg/GenABEL/src/GAlib/convert_snp_illumina.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/convert_snp_illumina.cpp 2011-03-30 08:37:52 UTC (rev 702)
+++ pkg/GenABEL/src/GAlib/convert_snp_illumina.cpp 2011-03-30 16:33:24 UTC (rev 703)
@@ -6,7 +6,7 @@
*
**/
-#include <cstdlib>
+#include <cstdlib>
#include <string>
#include <iostream>
#include <fstream>
@@ -14,7 +14,7 @@
#include <stdio.h>
-using namespace std;
+using namespace std;
//STL
#include <vector>
@@ -24,7 +24,7 @@
#include <R.h>
-#define MAXSNPs 5000000
+#define MAXSNPs 2000000
/**
*
@@ -52,7 +52,7 @@
string data;
string tempstr;
-
+
vector<string> iid;
vector<string> chrom; string tmp_chrom;
vector<string> snpnam; string tmp_snpnam;
@@ -61,7 +61,7 @@
vector<string> coding; string tmp_coding,tmp_coding1;
vector<unsigned short int> intcoding;
vector<unsigned short int> strand; string tmp_strand;
- vector<string> codeset(ncodes);
+ vector<string> codeset(ncodes);
char tmp_chcoding [10];
for (int i=0;i<ncodes;i++) codeset[i].assign(allele_codes[i]);
@@ -73,8 +73,8 @@
if (loud) {
Rprintf("Reading genotypes from file '%s' ...\n",filename[0]);
- }
-
+ }
+
nsnps = 0;
unsigned long int lasti = 1;
@@ -115,13 +115,13 @@
snpnam.push_back(tmp_snpnam);
map.push_back(tmp_map);
if (strandid == 3) {
- if (!(datas >> tmp_strand)) error("Strand field is missing in line %i, SNP '%s'!\n",(nsnps+1),tmp_snpnam.c_str());
+ if (!(datas >> tmp_strand)) error("Strand field is missing in line %i, SNP '%s'!\n",(nsnps+1),tmp_snpnam.c_str());
if (tmp_strand == "u") strand.push_back(0);
else if (tmp_strand == "+") strand.push_back(1);
else if (tmp_strand == "-") strand.push_back(2);
else error("Bad strand coding ('%s'), only '+', '-' or 'u' is accepted!\n",tmp_strand.c_str());
} else strand.push_back(strandid);
-
+
unsigned long int idx = 0;
idx = 0;
@@ -191,7 +191,7 @@
if (tmp_gtype == NULL) {
error ("ran out of memory reading file '%s' line %li !");
}
-
+
idx = 0;
for (byte = 0; byte < nbytes; ++byte) {
@@ -200,7 +200,7 @@
switch (gnum[idx]+gnum[idx+1]) {
case 2:
- if (ca1 > ca2)
+ if (ca1 > ca2)
tmp_gtype[byte] = tmp_gtype[byte] | ((unsigned char)1 << offset[ind]);
else
tmp_gtype[byte] = tmp_gtype[byte] | ((unsigned char)3 << offset[ind]);
@@ -209,7 +209,7 @@
tmp_gtype[byte] = tmp_gtype[byte] | ((unsigned char)2 << offset[ind]);
break;
case 6:
- if (ca1 > ca2)
+ if (ca1 > ca2)
tmp_gtype[byte] = tmp_gtype[byte] | ((unsigned char)3 << offset[ind]);
else
tmp_gtype[byte] = tmp_gtype[byte] | ((unsigned char)1 << offset[ind]);
@@ -245,7 +245,7 @@
if (loud) {
Rprintf("Writing to file '%s' ...\n",outfilename[0]);
- }
+ }
outfile << "#GenABEL raw data version 0.1";
outfile << endl;
@@ -266,24 +266,24 @@
for (unsigned long int i=0;i<nsnps;i++) {
outfile.width(2);
- outfile.fill('0');
+ outfile.fill('0');
outfile << (unsigned int)intcoding[i] << " ";
}
outfile << endl;
for (unsigned long int i=0;i<nsnps;i++) {
outfile.width(2);
- outfile.fill('0');
+ outfile.fill('0');
outfile << (unsigned int)strand[i] << " ";
}
outfile << endl;
for (unsigned long int i=0;i<nsnps;i++) {
tmp_gtype = gtype[i];
-
+
for (byte = 0; byte < nbytes; ++byte) {
outfile.width(2);
- outfile.fill('0');
+ outfile.fill('0');
outfile << (unsigned int)tmp_gtype[byte];
outfile << " ";
}
@@ -291,13 +291,11 @@
delete [] tmp_gtype;
}
-
+
if (loud) {
Rprintf("... done.\n");
- }
+ }
}
}
-
-
Modified: pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp 2011-03-30 08:37:52 UTC (rev 702)
+++ pkg/GenABEL/src/GAlib/convert_snp_merlin.cpp 2011-03-30 16:33:24 UTC (rev 703)
@@ -8,7 +8,7 @@
*
**/
-#include <cstdlib>
+#include <cstdlib>
#include <string>
#include <iostream>
#include <fstream>
@@ -16,7 +16,7 @@
#include <stdio.h>
-using namespace std;
+using namespace std;
//STL
#include <vector>
@@ -26,7 +26,7 @@
#include <R.h>
-#define MAXIDS 100000
+#define MAXIDS 2000000
string replace_mrl(string in);
string replace_mach(string in);
@@ -56,7 +56,7 @@
long int linecount=0;
string data;
string token;
-
+
vector<string> iid; string tmp_iid;
vector<string> chrom; string tmp_chrom;
vector<string> snpnm; string tmp_snpnm;
@@ -66,7 +66,7 @@
vector<string> coding; string tmp_coding,tmp_coding1;
vector<int> intcoding;
vector<int> strand; string tmp_strand;
- vector<string> codeset(ncodes);
+ vector<string> codeset(ncodes);
char tmp_chcoding [10];
// char tmp_chcoding1 [10];
@@ -83,7 +83,7 @@
if (verbose) {
Rprintf("Reading map from file '%s' ...\n",mapfilename[0]);
- }
+ }
int mapline=0;
// read and ignore header line
@@ -132,7 +132,7 @@
///////////////////////////
// reading pedigree file //
///////////////////////////
-
+
int nsnps = chrom.size();
if (verbose) {
@@ -148,8 +148,8 @@
if (verbose) {
Rprintf("Reading genotypes from file '%s' ...\n",pedfilename[0]);
- }
-
+ }
+
linecount = 0;
double lasti = 1;
if (format==0) {
@@ -168,11 +168,11 @@
if (!(chgt[2*(linecount-1)] = new char [2*nsnps])) error ("ran out of memory ...\n");
if (!(chgt[2*(linecount-1)+1] = new char [2*nsnps])) error ("ran out of memory ...\n");
for (int snp = 0; snp < nsnps; snp++) {
- if (datas >> gdata) {chgt[2*(linecount-1)][snp] = gdata;}
+ if (datas >> gdata) {chgt[2*(linecount-1)][snp] = gdata;}
else {
error ("too few genotypes for person '%s' ('%s', line %li) !\n",tmp_iid.c_str(),pedfilename[0],linecount);
}
- if (datas >> gdata) {chgt[2*(linecount-1)+1][snp] = gdata;}
+ if (datas >> gdata) {chgt[2*(linecount-1)+1][snp] = gdata;}
else {
error ("too few genotypes for person '%s' ('%s', line %li) !\n",tmp_iid.c_str(),pedfilename[0],linecount);
}
@@ -202,11 +202,11 @@
if (!(chgt[2*(linecount-1)] = new char [2*nsnps])) error ("ran out of memory ...\n");
if (!(chgt[2*(linecount-1)+1] = new char [2*nsnps])) error ("ran out of memory ...\n");
for (int snp = 0; snp < nsnps; snp++) {
- if (datas >> gdata) {chgt[2*(linecount-1)][snp] = gdata;}
+ if (datas >> gdata) {chgt[2*(linecount-1)][snp] = gdata;}
else {
error ("too few genotypes for person '%s' ('%s', line %li) !\n",tmp_iid.c_str(),pedfilename[0],linecount);
}
- if (datas >> gdata) {chgt[2*(linecount-1)+1][snp] = gdata;}
+ if (datas >> gdata) {chgt[2*(linecount-1)+1][snp] = gdata;}
else {
error ("too few genotypes for person '%s' ('%s', line %li) !\n",tmp_iid.c_str(),pedfilename[0],linecount);
}
@@ -251,12 +251,12 @@
char allele1 = 0;
char allele2 = 0;
/**
- if (strandid==3) {
+ if (strandid==3) {
char at[10];
sprintf(at,"%s",coding[snp].c_str());
allele1 = at[0];
allele2 = at[1];
- }
+ }
**/
@@ -324,7 +324,7 @@
if (tmp_gtype == NULL) {
error ("ran out of memory reading file '%s' line %li !");
}
-
+
idx = 0;
for (byte = 0; byte < nbytes; ++byte) {
@@ -333,7 +333,7 @@
switch (gnum[idx]+gnum[idx+1]) {
case 2:
- if (ca1 > ca2)
+ if (ca1 > ca2)
tmp_gtype[byte] = tmp_gtype[byte] | ((unsigned char)1 << offset[ind]);
else
tmp_gtype[byte] = tmp_gtype[byte] | ((unsigned char)3 << offset[ind]);
@@ -342,7 +342,7 @@
tmp_gtype[byte] = tmp_gtype[byte] | ((unsigned char)2 << offset[ind]);
break;
case 6:
- if (ca1 > ca2)
+ if (ca1 > ca2)
tmp_gtype[byte] = tmp_gtype[byte] | ((unsigned char)3 << offset[ind]);
else
tmp_gtype[byte] = tmp_gtype[byte] | ((unsigned char)1 << offset[ind]);
@@ -378,7 +378,7 @@
if (verbose) {
Rprintf("Writing to file '%s' ...\n",outfilename[0]);
- }
+ }
outfile << "#GenABEL raw data version 0.1";
outfile << endl;
@@ -399,24 +399,24 @@
for (int i=0;i<nsnps;i++) {
outfile.width(2);
- outfile.fill('0');
+ outfile.fill('0');
outfile << intcoding[i] << " ";
}
outfile << endl;
for (int i=0;i<nsnps;i++) {
outfile.width(2);
- outfile.fill('0');
+ outfile.fill('0');
outfile << strand[i] << " ";
}
outfile << endl;
for (int i=0;i<nsnps;i++) {
tmp_gtype = gtype[i];
-
+
for (byte = 0; byte < nbytes; ++byte) {
outfile.width(2);
- outfile.fill('0');
+ outfile.fill('0');
outfile << (unsigned int)tmp_gtype[byte];
outfile << " ";
}
@@ -424,12 +424,10 @@
delete [] tmp_gtype;
}
-
+
if (verbose) {
Rprintf("... done.\n");
- }
-
+ }
+
}
}
-
-
More information about the Genabel-commits
mailing list