temp = validParameter.validFile(parameters, "name", true);
if (temp == "not found") { nameFile = ""; }
- else if(temp == "not open") { abort = true; }
+ else if(temp == "not open") { nameFile = ""; abort = true; }
else { nameFile = temp; }
temp = validParameter.validFile(parameters, "qthreshold", false); if (temp == "not found") { temp = "0"; }
#endif
if (m->control_pressed) { return 0; }
-
+
if(allFiles){
map<string, string> uniqueFastaNames;// so we don't add the same groupfile multiple times
map<string, string>::iterator it;
//output group counts
m->mothurOutEndLine();
int total = 0;
+ if (groupCounts.size() != 0) { m->mothurOut("Group count: \n"); }
for (map<string, int>::iterator it = groupCounts.begin(); it != groupCounts.end(); it++) {
- total += it->second; m->mothurOut("Group " + it->first + " contains " + toString(it->second) + " sequences."); m->mothurOutEndLine();
+ total += it->second; m->mothurOut(it->first + "\t" + toString(it->second)); m->mothurOutEndLine();
}
if (total != 0) { m->mothurOut("Total of all groups is " + toString(total)); m->mothurOutEndLine(); }
outGroupsFile << currSeq.getName() << '\t' << thisGroup << endl;
+ if (nameFile != "") {
+ map<string, string>::iterator itName = nameMap.find(currSeq.getName());
+ if (itName != nameMap.end()) {
+ vector<string> thisSeqsNames;
+ m->splitAtChar(itName->second, thisSeqsNames, ',');
+ for (int k = 1; k < thisSeqsNames.size(); k++) { //start at 1 to skip self
+ outGroupsFile << thisSeqsNames[k] << '\t' << thisGroup << endl;
+ }
+ }else { m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); }
+ }
+
map<string, int>::iterator it = groupCounts.find(thisGroup);
if (it == groupCounts.end()) { groupCounts[thisGroup] = 1; }
else { groupCounts[it->first]++; }
}
}
else{
+ if(nameFile != ""){ //needs to be before the currSeq name is changed
+ map<string, string>::iterator itName = nameMap.find(currSeq.getName());
+ if (itName != nameMap.end()) { scrapNameFile << itName->first << '\t' << itName->second << endl; }
+ else { m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); }
+ }
currSeq.setName(currSeq.getName() + '|' + trashCode);
currSeq.setUnaligned(origSeq);
currSeq.setAligned(origSeq);
if(qFileName != ""){
currQual.printQScores(scrapQualFile);
}
- if(nameFile != ""){
- map<string, string>::iterator itName = nameMap.find(currSeq.getName());
- if (itName != nameMap.end()) { scrapNameFile << itName->first << '\t' << itName->second << endl; }
- else { m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); }
- }
}
count++;
}
ofstream temp;
m->openOutputFile(trimFASTAFileName, temp); temp.close();
m->openOutputFile(scrapFASTAFileName, temp); temp.close();
- m->openOutputFile(trimQualFileName, temp); temp.close();
- m->openOutputFile(scrapQualFileName, temp); temp.close();
- m->openOutputFile(trimNameFileName, temp); temp.close();
- m->openOutputFile(scrapNameFileName, temp); temp.close();
+ if(qFileName != ""){
+ m->openOutputFile(trimQualFileName, temp); temp.close();
+ m->openOutputFile(scrapQualFileName, temp); temp.close();
+ }
+ if (nameFile != "") {
+ m->openOutputFile(trimNameFileName, temp); temp.close();
+ m->openOutputFile(scrapNameFileName, temp); temp.close();
+ }
driverCreateTrim(filename, qFileName, trimFASTAFileName, scrapFASTAFileName, trimQualFileName, scrapQualFileName, trimNameFileName, scrapNameFileName, groupFile, fastaFileNames, qualFileNames, nameFileNames, lines[0], qLines[0]);
if(qFileName != ""){
qualFileName = outputDir + m->getRootName(m->getSimpleName(qFileName)) + comboGroupName + ".qual";
- if (uniqueNames.count(fastaFileName) == 0) {
+ if (uniqueNames.count(qualFileName) == 0) {
outputNames.push_back(qualFileName);
outputTypes["qfile"].push_back(qualFileName);
}
if(nameFile != ""){
nameFileName = outputDir + m->getRootName(m->getSimpleName(nameFile)) + comboGroupName + ".names";
- if (uniqueNames.count(fastaFileName) == 0) {
+ if (uniqueNames.count(nameFileName) == 0) {
outputNames.push_back(nameFileName);
outputTypes["name"].push_back(nameFileName);
}