vector<string> setParameters();
string getCommandName() { return "chimera.perseus"; }
string getCommandCategory() { return "Sequence Processing"; }
- string getOutputFileNameTag(string, string);
+
string getHelpString();
+ string getOutputPattern(string);
string getCitation() { return "Quince C, Lanzen A, Davenport RJ, Turnbaugh PJ (2011). Removing noise from pyrosequenced amplicons. BMC Bioinformatics 12:38.\nEdgar,R.C., Haas,B.J., Clemente,J.C., Quince,C. and Knight,R. (2011), UCHIME improves sensitivity and speed of chimera detection. Bioinformatics 27:2194.\nhttp://www.mothur.org/wiki/Chimera.perseus\n"; }
string getDescription() { return "detect chimeric sequences"; }
linePair(int i, int j) : start(i), end(j) {}
};
- bool abort, hasName, hasCount;
+ bool abort, hasName, hasCount, dups;
string fastafile, groupfile, countfile, outputDir, namefile;
int processors, alignLength;
double cutoff, alpha, beta;
vector<seqData> readFiles(string inputFile, CountTable* ct);
vector<seqData> loadSequences(string);
int deconvoluteResults(map<string, string>&, string, string);
- int driverGroups(string, string, int, int, vector<string>);
- int createProcessesGroups(string, string, vector<string>, string, string, string);
+ int driverGroups(string, string, string, int, int, vector<string>);
+ int createProcessesGroups(string, string, string, vector<string>, string, string, string);
+ string removeNs(string);
};
/**************************************************************************************************/
string groupfile;
string outputFName;
string accnos;
+ string countlist;
MothurOut* m;
int start;
int end;
- bool hasName, hasCount;
+ bool hasName, hasCount, dups;
int threadID, count, numChimeras;
double alpha, beta, cutoff;
vector<string> groups;
perseusData(){}
- perseusData(bool hn, bool hc, double a, double b, double c, string o, string f, string n, string g, string ac, vector<string> gr, MothurOut* mout, int st, int en, int tid) {
+ perseusData(bool dps, bool hn, bool hc, double a, double b, double c, string o, string f, string n, string g, string ac, string ctlist, vector<string> gr, MothurOut* mout, int st, int en, int tid) {
alpha = a;
beta = b;
cutoff = c;
namefile = n;
groupfile = g;
outputFName = o;
+ countlist = ctlist;
accnos = ac;
m = mout;
start = st;
groups = gr;
hasName = hn;
hasCount = hc;
+ dups = dps;
count = 0;
numChimeras = 0;
}
int totalSeqs = 0;
int numChimeras = 0;
+
+ ofstream outCountList;
+ if (pDataArray->hasCount && pDataArray->dups) { pDataArray->m->openOutputFile(pDataArray->countlist, outCountList); }
- for (int i = pDataArray->start; i < pDataArray->end; i++) {
+ for (int u = pDataArray->start; u < pDataArray->end; u++) {
int start = time(NULL); if (pDataArray->m->control_pressed) { if (pDataArray->hasCount) { delete cparser; } { delete parser; } pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); return 0; }
- pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Checking sequences from group " + pDataArray->groups[i] + "..."); pDataArray->m->mothurOutEndLine();
+ pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Checking sequences from group " + pDataArray->groups[u] + "..."); pDataArray->m->mothurOutEndLine();
//vector<seqData> sequences = loadSequences(parser, groups[i]); - same function below
////////////////////////////////////////////////////////////////////////////////////////
int alignLength = 0;
vector<seqData> sequences;
if (pDataArray->hasCount) {
- vector<Sequence> thisGroupsSeqs = cparser->getSeqs(pDataArray->groups[i]);
- map<string, int> counts = cparser->getCountTable(pDataArray->groups[i]);
+ vector<Sequence> thisGroupsSeqs = cparser->getSeqs(pDataArray->groups[u]);
+ map<string, int> counts = cparser->getCountTable(pDataArray->groups[u]);
map<string, int>::iterator it;
for (int i = 0; i < thisGroupsSeqs.size(); i++) {
it = counts.find(thisGroupsSeqs[i].getName());
if (it == counts.end()) { error = true; pDataArray->m->mothurOut("[ERROR]: " + thisGroupsSeqs[i].getName() + " is in your fasta file and not in your count file, please correct."); pDataArray->m->mothurOutEndLine(); }
else {
+ string newSeq = "";
+ string tempSeq = thisGroupsSeqs[i].getUnaligned();
+ for (int j = 0; j < tempSeq.length(); j++) { if (tempSeq[j] != 'N') { newSeq += tempSeq[j]; } }
+ thisGroupsSeqs[i].setAligned(newSeq);
+
sequences.push_back(seqData(thisGroupsSeqs[i].getName(), thisGroupsSeqs[i].getUnaligned(), it->second));
if (thisGroupsSeqs[i].getUnaligned().length() > alignLength) { alignLength = thisGroupsSeqs[i].getUnaligned().length(); }
}
}
}else{
- vector<Sequence> thisGroupsSeqs = parser->getSeqs(pDataArray->groups[i]);
- map<string, string> nameMap = parser->getNameMap(pDataArray->groups[i]);
+ vector<Sequence> thisGroupsSeqs = parser->getSeqs(pDataArray->groups[u]);
+ map<string, string> nameMap = parser->getNameMap(pDataArray->groups[u]);
map<string, string>::iterator it;
for (int i = 0; i < thisGroupsSeqs.size(); i++) {
if (it == nameMap.end()) { error = true; pDataArray->m->mothurOut("[ERROR]: " + thisGroupsSeqs[i].getName() + " is in your fasta file and not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); }
else {
int num = pDataArray->m->getNumNames(it->second);
+ string newSeq = "";
+ string tempSeq = thisGroupsSeqs[i].getUnaligned();
+ for (int j = 0; j < tempSeq.length(); j++) { if (tempSeq[j] != 'N') { newSeq += tempSeq[j]; } }
+ thisGroupsSeqs[i].setAligned(newSeq);
+
sequences.push_back(seqData(thisGroupsSeqs[i].getName(), thisGroupsSeqs[i].getUnaligned(), num));
if (thisGroupsSeqs[i].getUnaligned().length() > alignLength) { alignLength = thisGroupsSeqs[i].getUnaligned().length(); }
}
//int numSeqs = driver((outputFName + groups[i]), sequences, (accnos+groups[i]), numChimeras); - same function below
////////////////////////////////////////////////////////////////////////////////////////
- string chimeraFileName = pDataArray->outputFName+pDataArray->groups[i];
- string accnosFileName = pDataArray->accnos+pDataArray->groups[i];
+ string chimeraFileName = pDataArray->outputFName+pDataArray->groups[u];
+ string accnosFileName = pDataArray->accnos+pDataArray->groups[u];
vector<vector<double> > correctModel(4); //could be an option in the future to input own model matrix
for(int j=0;j<4;j++){ correctModel[j].resize(4); }
////////////////////////////////////////////////////////////////////////////////////////
totalSeqs += numSeqs;
+
+ if (pDataArray->dups) {
+ if (!pDataArray->m->isBlank(accnosFileName)) {
+ ifstream in;
+ pDataArray->m->openInputFile(accnosFileName, in);
+ string name;
+ if (pDataArray->hasCount) {
+ while (!in.eof()) {
+ in >> name; pDataArray->m->gobble(in);
+ outCountList << name << '\t' << pDataArray->groups[u] << endl;
+ }
+ in.close();
+ }else {
+ map<string, string> thisnamemap = parser->getNameMap(pDataArray->groups[u]);
+ map<string, string>::iterator itN;
+ ofstream out;
+ pDataArray->m->openOutputFile(accnosFileName+".temp", out);
+ while (!in.eof()) {
+ in >> name; pDataArray->m->gobble(in);
+ itN = thisnamemap.find(name);
+ if (itN != thisnamemap.end()) {
+ vector<string> tempNames; pDataArray->m->splitAtComma(itN->second, tempNames);
+ for (int j = 0; j < tempNames.size(); j++) { out << tempNames[j] << endl; }
+
+ }else { pDataArray->m->mothurOut("[ERROR]: parsing cannot find " + name + ".\n"); pDataArray->m->control_pressed = true; }
+ }
+ out.close();
+ in.close();
+ pDataArray->m->renameFile(accnosFileName+".temp", accnosFileName);
+ }
+
+ }
+ }
//append files
pDataArray->m->appendFiles(chimeraFileName, pDataArray->outputFName); pDataArray->m->mothurRemove(chimeraFileName);
pDataArray->m->appendFiles(accnosFileName, pDataArray->accnos); pDataArray->m->mothurRemove(accnosFileName);
- pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences from group " + pDataArray->groups[i] + "."); pDataArray->m->mothurOutEndLine();
+ pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences from group " + pDataArray->groups[u] + "."); pDataArray->m->mothurOutEndLine();
if (pDataArray->m->control_pressed) { if (pDataArray->hasCount) { delete cparser; } { delete parser; } pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); return 0; }
}
+ if (pDataArray->hasCount && pDataArray->dups) { outCountList.close(); }
+
pDataArray->count = totalSeqs;
if (pDataArray->hasCount) { delete cparser; } { delete parser; }
return totalSeqs;