//********************************************************************************************************************** vector<seqData> ChimeraPerseusCommand::loadSequences(SequenceParser& parser, string group){ try { vector<Sequence> thisGroupsSeqs = parser.getSeqs(group); map<string, string> nameMap = parser.getNameMap(group); map<string, string>::iterator it; vector<seqData> sequences; bool error = false; for (int i = 0; i < thisGroupsSeqs.size(); i++) { if (m->control_pressed) { return sequences; } it = nameMap.find(thisGroupsSeqs[i].getName()); if (it == nameMap.end()) { error = true; m->mothurOut("[ERROR]: " + thisGroupsSeqs[i].getName() + " is in your fasta file and not in your namefile, please correct."); m->mothurOutEndLine(); } else { int num = m->getNumNames(it->second); sequences.push_back(seqData(thisGroupsSeqs[i].getName(), thisGroupsSeqs[i].getUnaligned(), num)); } } if (error) { m->control_pressed = true; } //sort by frequency sort(sequences.rbegin(), sequences.rend()); return sequences; } catch(exception& e) { m->errorOut(e, "ChimeraPerseusCommand", "loadSequences"); exit(1); } }
//********************************************************************************************************************** int SplitGroupCommand::runNameGroup(){ try { SequenceParser* parser; if (namefile == "") { parser = new SequenceParser(groupfile, fastafile); } else { parser = new SequenceParser(groupfile, fastafile, namefile); } if (m->control_pressed) { delete parser; return 0; } vector<string> namesGroups = parser->getNamesOfGroups(); SharedUtil util; util.setGroups(Groups, namesGroups); string fastafileRoot = outputDir + m->getRootName(m->getSimpleName(fastafile)); string namefileRoot = outputDir + m->getRootName(m->getSimpleName(namefile)); m->mothurOutEndLine(); for (int i = 0; i < Groups.size(); i++) { m->mothurOut("Processing group: " + Groups[i]); m->mothurOutEndLine(); map<string, string> variables; variables["[filename]"] = fastafileRoot; variables["[group]"] = Groups[i]; string newFasta = getOutputFileName("fasta",variables); variables["[filename]"] = namefileRoot; string newName = getOutputFileName("name",variables); parser->getSeqs(Groups[i], newFasta, "/ab=", "/", false); outputNames.push_back(newFasta); outputTypes["fasta"].push_back(newFasta); if (m->control_pressed) { delete parser; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (namefile != "") { parser->getNameMap(Groups[i], newName); outputNames.push_back(newName); outputTypes["name"].push_back(newName); } if (m->control_pressed) { delete parser; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } } delete parser; return 0; } catch(exception& e) { m->errorOut(e, "SplitGroupCommand", "runNameGroup"); exit(1); } }