+ //read version
+ int length = positions2[1] - positions2[0];
+ char* buf5 = new char[length];
+
+ MPI_File_read_at(inMPI2, positions2[0], buf5, length, MPI_CHAR, &status);
+ delete buf5;
+
+ //read numKmers
+ length = positions2[2] - positions2[1];
+ char* buf = new char[length];
+
+ MPI_File_read_at(inMPI2, positions2[1], buf, length, MPI_CHAR, &status);
+
+ string tempBuf = buf;
+ if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); }
+ delete buf;
+
+ istringstream iss (tempBuf,istringstream::in);
+ iss >> numKmers;
+
+ //initialze probabilities
+ wordGenusProb.resize(numKmers);
+
+ for (int j = 0; j < wordGenusProb.size(); j++) { wordGenusProb[j].resize(genusNodes.size()); }
+
+ int kmer, name;
+ vector<int> numbers; numbers.resize(numKmers);
+ float prob;
+ vector<float> zeroCountProb; zeroCountProb.resize(numKmers);
+ WordPairDiffArr.resize(numKmers);
+
+ //read version
+ length = positions[1] - positions[0];
+ char* buf6 = new char[length];
+
+ MPI_File_read_at(inMPI2, positions[0], buf6, length, MPI_CHAR, &status);
+ delete buf6;
+
+ //read file
+ for(int i=1;i<num;i++){
+ //read next sequence
+ length = positions[i+1] - positions[i];
+ char* buf4 = new char[length];
+
+ MPI_File_read_at(inMPI, positions[i], buf4, length, MPI_CHAR, &status);
+
+ tempBuf = buf4;
+ if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); }
+ delete buf4;
+
+ istringstream iss (tempBuf,istringstream::in);
+ float probTemp;
+ iss >> zeroCountProb[i] >> numbers[i] >> probTemp;
+ WordPairDiffArr[i].prob = probTemp;
+
+ }
+
+ MPI_File_close(&inMPI);
+
+ for(int i=2;i<num2;i++){
+ //read next sequence
+ length = positions2[i+1] - positions2[i];
+ char* buf4 = new char[length];
+
+ MPI_File_read_at(inMPI2, positions2[i], buf4, length, MPI_CHAR, &status);
+
+ tempBuf = buf4;
+ if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); }
+ delete buf4;
+
+ istringstream iss (tempBuf,istringstream::in);
+
+ iss >> kmer;
+
+ //set them all to zero value
+ for (int i = 0; i < genusNodes.size(); i++) {
+ wordGenusProb[kmer][i] = log(zeroCountProb[kmer] / (float) (genusTotals[i]+1));
+ }
+
+ //get probs for nonzero values
+ for (int i = 0; i < numbers[kmer]; i++) {
+ iss >> name >> prob;
+ wordGenusProb[kmer][name] = prob;
+ }
+
+ }
+ MPI_File_close(&inMPI2);
+ MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
+ #else
+ //read version
+ string line = m->getline(in); m->gobble(in);
+
+ in >> numKmers; m->gobble(in);
+ //cout << threadID << '\t' << line << '\t' << numKmers << &in << '\t' << &inNum << '\t' << genusNodes.size() << endl;
+ //initialze probabilities
+ wordGenusProb.resize(numKmers);
+
+ for (int j = 0; j < wordGenusProb.size(); j++) { wordGenusProb[j].resize(genusNodes.size()); }
+
+ int kmer, name, count; count = 0;
+ vector<int> num; num.resize(numKmers);
+ float prob;
+ vector<float> zeroCountProb; zeroCountProb.resize(numKmers);
+ WordPairDiffArr.resize(numKmers);
+
+ //read version
+ string line2 = m->getline(inNum); m->gobble(inNum);
+ float probTemp;
+ //cout << threadID << '\t' << line2 << '\t' << this << endl;
+ while (inNum) {
+ inNum >> zeroCountProb[count] >> num[count] >> probTemp;
+ WordPairDiffArr[count].prob = probTemp;
+ count++;
+ m->gobble(inNum);
+ //cout << threadID << '\t' << count << endl;
+ }
+ inNum.close();
+ //cout << threadID << '\t' << "here1 " << &wordGenusProb << '\t' << &num << endl; //
+ //cout << threadID << '\t' << &genusTotals << '\t' << endl;
+ //cout << threadID << '\t' << genusNodes.size() << endl;
+ while(in) {
+ in >> kmer;
+ //cout << threadID << '\t' << kmer << endl;
+ //set them all to zero value
+ for (int i = 0; i < genusNodes.size(); i++) {
+ wordGenusProb[kmer][i] = log(zeroCountProb[kmer] / (float) (genusTotals[i]+1));
+ }
+ //cout << threadID << '\t' << num[kmer] << "here" << endl;
+ //get probs for nonzero values
+ for (int i = 0; i < num[kmer]; i++) {
+ in >> name >> prob;
+ wordGenusProb[kmer][name] = prob;
+ }
+
+ m->gobble(in);