- for (int i=0; i<thisTypesFiles.size(); i++) {
-
- string output = "NA\t";
- if (k < files[thisTypesFiles[i]].size()) {
- string line = files[thisTypesFiles[i]][k];
- output = line.substr(0, line.find_first_of('\t'));
- output += '\t' + files[thisTypesFiles[i]][0] + '\t' + line.substr(line.find_first_of('\t'));
- }else{
- output += '\t' + files[thisTypesFiles[i]][0] + '\t';
- }
- out << output << endl;
+ for (map<string, string>::iterator itFileNameGroup = thisTypesFiles.begin(); itFileNameGroup != thisTypesFiles.end(); itFileNameGroup++) {
+
+ string thisfilename = itFileNameGroup->first;
+ map<int, int>::iterator itLine = lineToNumber.find(k);
+ if (itLine != lineToNumber.end()) {
+ string output = toString(itLine->second);
+ if (k < files[thisfilename].size()) {
+ string line = files[thisfilename][k];
+ output = line.substr(0, line.find_first_of('\t'));
+ output += '\t' + files[thisfilename][0] + '\t' + line.substr(line.find_first_of('\t'));
+ }else{
+ output += '\t' + files[thisfilename][0] + '\t';
+ for (int h = 0; h < numColumns; h++) {
+ output += "NA\t";
+ }
+ }
+ out << output << endl;
+ }else { m->mothurOut("[ERROR]: parsing results, cant find " + toString(k)); m->mothurOutEndLine(); }