diff --git a/BasicDefinitions.h b/BasicDefinitions.h index 2e3d8b6..1d19ac5 100644 --- a/BasicDefinitions.h +++ b/BasicDefinitions.h @@ -38,6 +38,7 @@ class Individuals; extern SNPs ALL_SNPS; extern Individuals ALL_SAMPLES; extern ofstream MATCH_FILE; +map FILE_MAP; enum ErrorType{RECOMB=0,MI=1}; const int HET=2; diff --git a/GERMLINE.cpp b/GERMLINE.cpp index 65bc506..da95384 100644 --- a/GERMLINE.cpp +++ b/GERMLINE.cpp @@ -7,6 +7,7 @@ using namespace std; ofstream MATCH_FILE; +map FILE_MAP; size_t num_samples; unsigned long num_matches; SNPs ALL_SNPS; @@ -45,6 +46,19 @@ void GERMLINE::mine( string params ) if ( BINARY_OUT ) MATCH_FILE.open( ( out + ".bmatch" ).c_str() , ios::binary ); else MATCH_FILE.open( ( out + ".match" ).c_str() ); + + // Instantiate pointers to files with append access + // we want one pointer per sample? + // num_samples incremented in Individuals::addIndividual + // This is called in PEDIndividualsExtractor which is + // called in getIndividuals + stringstream sstm; + for (int i=0;igetID()]; + fout_temp.write( (char*) &pid[0] , sizeof( unsigned int ) ); + fout_temp.write( (char*) &pid[1] , sizeof( unsigned int ) ); + fout_temp.write( (char*) &sid[0] , sizeof( unsigned int ) ); + fout_temp.write( (char*) &sid[1] , sizeof( unsigned int ) ); + // fout.write( (char*) &dif , sizeof( int ) ); + // fout.write( (char*) &hom[0] , sizeof( bool ) ); + // fout.write( (char*) &hom[1] , sizeof( bool ) ); } else { - fout << node[0]->getID() << '\t'; - fout << node[1]->getID() << '\t'; - fout << ALL_SNPS.getSNP(snp_start).getChr() << '\t'; - fout << ALL_SNPS.getSNP(snp_start).getPhysPos() << ' '; - fout << ALL_SNPS.getSNP(snp_end).getPhysPos() << '\t'; - fout << ALL_SNPS.getSNP(snp_start).getSNPID() << ' '; - fout << ALL_SNPS.getSNP(snp_end).getSNPID() << '\t'; - fout << ( snp_end - snp_start + 1) << '\t'; - fout << setiosflags(ios::fixed) << setprecision(2) << distance << '\t'; - if ( genetic ) fout << "cM" << '\t'; else fout << "MB" << '\t'; - fout << dif; - for ( int n = 0 ; n < 2 ; n++ ) - if ( hom[n] ) fout << '\t' << 1; else fout << '\t' << 0; + // line_elements = line.split("\t") + // return "\t".join(line_elements[:4]) + ofstream fout_temp = *FILE_MAP[node[0]->getNumericID()]; + fout_temp << node[0]->getID() << '\t'; + fout_temp << node[1]->getID() << '\t'; + fout_temp << ALL_SNPS.getSNP(snp_start).getChr() << '\t'; + fout_temp << ALL_SNPS.getSNP(snp_start).getPhysPos() << ' '; + fout_temp << ALL_SNPS.getSNP(snp_end).getPhysPos() << '\t'; + // fout << ALL_SNPS.getSNP(snp_start).getSNPID() << ' '; + // fout << ALL_SNPS.getSNP(snp_end).getSNPID() << '\t'; + // fout << ( snp_end - snp_start + 1) << '\t'; + // fout << setiosflags(ios::fixed) << setprecision(2) << distance << '\t'; + // if ( genetic ) fout << "cM" << '\t'; else fout << "MB" << '\t'; + // fout << dif; + // for ( int n = 0 ; n < 2 ; n++ ) + // if ( hom[n] ) fout << '\t' << 1; else fout << '\t' << 0; fout << endl; } num_matches++;