//**********************************************************************************************************************
vector<string> SffInfoCommand::setParameters(){
try {
- CommandParameter psff("sff", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(psff);
- CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(poligos);
- CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
- CommandParameter psfftxt("sfftxt", "String", "", "", "", "", "",false,false); parameters.push_back(psfftxt);
- CommandParameter pflow("flow", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pflow);
- CommandParameter ptrim("trim", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(ptrim);
- CommandParameter pfasta("fasta", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pfasta);
- CommandParameter pqfile("name", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pqfile);
- CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs);
- CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs);
- CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pldiffs);
- CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(psdiffs);
- CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs);
- CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
- CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+ CommandParameter psff("sff", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(psff);
+ CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(poligos);
+ CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(paccnos);
+ CommandParameter psfftxt("sfftxt", "String", "", "", "", "", "","",false,false); parameters.push_back(psfftxt);
+ CommandParameter pflow("flow", "Boolean", "", "T", "", "", "","flow",false,false); parameters.push_back(pflow);
+ CommandParameter ptrim("trim", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(ptrim);
+ CommandParameter pfasta("fasta", "Boolean", "", "T", "", "", "","fasta",false,false); parameters.push_back(pfasta);
+ CommandParameter pqfile("qfile", "Boolean", "", "T", "", "", "","qfile",false,false); parameters.push_back(pqfile);
+ CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ppdiffs);
+ CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pbdiffs);
+ CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pldiffs);
+ CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(psdiffs);
+ CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ptdiffs);
+ CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+ CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
vector<string> myArray;
for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
exit(1);
}
}
+
//**********************************************************************************************************************
-string SffInfoCommand::getOutputFileNameTag(string type, string inputName=""){
- try {
- string outputFileName = "";
- map<string, vector<string> >::iterator it;
+string SffInfoCommand::getOutputPattern(string type) {
+ try {
+ string pattern = "";
- //is this a type this command creates
- it = outputTypes.find(type);
- if (it == outputTypes.end()) { m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
- else {
- if (type == "fasta") { outputFileName = "fasta"; }
- else if (type == "flow") { outputFileName = "flow"; }
- else if (type == "sfftxt") { outputFileName = "sff.txt"; }
- else if (type == "sff") { outputFileName = "sff"; }
- else if (type == "qfile") { outputFileName = "qual"; }
- else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; }
- }
- return outputFileName;
- }
- catch(exception& e) {
- m->errorOut(e, "SffInfoCommand", "getOutputFileNameTag");
- exit(1);
- }
+ if (type == "fasta") { pattern = "[filename],fasta-[filename],[tag],fasta"; }
+ else if (type == "flow") { pattern = "[filename],flow"; }
+ else if (type == "sfftxt") { pattern = "[filename],sff.txt"; }
+ else if (type == "sff") { pattern = "[filename],[group],sff"; }
+ else if (type == "qfile") { pattern = "[filename],qual-[filename],[tag],qual"; }
+ else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
+
+ return pattern;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SffInfoCommand", "getOutputPattern");
+ exit(1);
+ }
}
-
-
//**********************************************************************************************************************
SffInfoCommand::SffInfoCommand(){
try {
SffInfoCommand::SffInfoCommand(string option) {
try {
abort = false; calledHelp = false;
- hasAccnos = false;
+ hasAccnos = false; hasOligos = false;
split = 1;
//allow user to run help
string rootName = outputDir + m->getRootName(m->getSimpleName(input));
if(rootName.find_last_of(".") == rootName.npos){ rootName += "."; }
- string sfftxtFileName = outputDir + m->getRootName(m->getSimpleName(input)) + getOutputFileNameTag("sfftxt");
- string outFlowFileName = outputDir + m->getRootName(m->getSimpleName(input)) + getOutputFileNameTag("flow");
- if (trim) {
- outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + getOutputFileNameTag("fasta");
- outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + getOutputFileNameTag("qfile");
- }else{
- outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw." + getOutputFileNameTag("fasta");
- outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw." + getOutputFileNameTag("qfile");
- }
-
+ map<string, string> variables;
+ variables["[filename]"] = rootName;
+ string sfftxtFileName = getOutputFileName("sfftxt",variables);
+ string outFlowFileName = getOutputFileName("flow",variables);
+ if (!trim) { variables["[tag]"] = "raw"; }
+ outFastaFileName = getOutputFileName("fasta",variables);
+ outQualFileName = getOutputFileName("qfile",variables);
+
if (sfftxt) { m->openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint); outputNames.push_back(sfftxtFileName); outputTypes["sfftxt"].push_back(sfftxtFileName); }
if (fasta) { m->openOutputFile(outFastaFileName, outFasta); outputNames.push_back(outFastaFileName); outputTypes["fasta"].push_back(outFastaFileName); }
if (qual) { m->openOutputFile(outQualFileName, outQual); outputNames.push_back(outQualFileName); outputTypes["qfile"].push_back(outQualFileName); }
//create new common headers for each file with the correct number of reads
adjustCommonHeader(header);
- map<string, string> uniqueSffNames;// so we don't add the same sff multiple times
map<string, string>::iterator it;
set<string> namesToRemove;
for(int i=0;i<filehandles.size();i++){
m->mothurRemove(filehandles[i][j]);
m->mothurRemove(filehandlesHeaders[i][j]);
namesToRemove.insert(filehandles[i][j]);
- }else{
- it = uniqueSffNames.find(filehandles[i][j]);
- if (it == uniqueSffNames.end()) {
- uniqueSffNames[filehandles[i][j]] = barcodeNameVector[i];
- }
- }
+ }
}
}
}
int SffInfoCommand::findGroup(Header header, seqRead read, int& barcode, int& primer) {
try {
//find group read belongs to
- TrimOligos trimOligos(pdiffs, bdiffs, ldiffs, sdiffs, primers, barcodes, rbarcodes, revPrimer, linker, spacer);
+ TrimOligos trimOligos(pdiffs, bdiffs, ldiffs, sdiffs, primers, barcodes, revPrimer, linker, spacer);
int success = 1;
string trashCode = "";
else{ currentSeqsDiffs += success; }
}
- if(rbarcodes.size() != 0){
- success = trimOligos.stripRBarcode(currSeq, currQual, barcode);
- if(success > bdiffs) { trashCode += 'b'; }
- else{ currentSeqsDiffs += success; }
- }
-
if(numSpacers != 0){
success = trimOligos.stripSpacer(currSeq, currQual);
if(success > sdiffs) { trashCode += 's'; }
fileRoot = m->getRootName(fileRoot);
}
- string outFlowFileName = outputDir + fileRoot + getOutputFileNameTag("flow");
- if (trim) {
- outFastaFileName = outputDir + fileRoot + getOutputFileNameTag("fasta");
- outQualFileName = outputDir + fileRoot + getOutputFileNameTag("qfile");
- }else{
- outFastaFileName = outputDir + fileRoot + "raw." + getOutputFileNameTag("fasta");
- outQualFileName = outputDir + fileRoot + "raw." + getOutputFileNameTag("qfile");
- }
+ map<string, string> variables;
+ variables["[filename]"] = fileRoot;
+ string sfftxtFileName = getOutputFileName("sfftxt",variables);
+ string outFlowFileName = getOutputFileName("flow",variables);
+ if (!trim) { variables["[tag]"] = "raw"; }
+ outFastaFileName = getOutputFileName("fasta",variables);
+ outQualFileName = getOutputFileName("qfile",variables);
if (fasta) { m->openOutputFile(outFastaFileName, outFasta); outputNames.push_back(outFastaFileName); outputTypes["fasta"].push_back(outFastaFileName); }
if (qual) { m->openOutputFile(outQualFileName, outQual); outputNames.push_back(outQualFileName); outputTypes["qfile"].push_back(outQualFileName); }
}
else if(type == "BARCODE"){
inOligos >> group;
-
- //barcode lines can look like BARCODE atgcatgc groupName - for 454 seqs
- //or BARCODE atgcatgc atgcatgc groupName - for illumina data that has forward and reverse info
- string temp = "";
- while (!inOligos.eof()) {
- char c = inOligos.get();
- if (c == 10 || c == 13){ break; }
- else if (c == 32 || c == 9){;} //space or tab
- else { temp += c; }
- }
- //then this is illumina data with 4 columns
- if (temp != "") {
- string reverseBarcode = reverseOligo(group); //reverse barcode
- group = temp;
-
- //check for repeat barcodes
- map<string, int>::iterator itBar = rbarcodes.find(reverseBarcode);
- if (itBar != rbarcodes.end()) { m->mothurOut("barcode " + reverseBarcode + " is in your oligos file already."); m->mothurOutEndLine(); }
-
- rbarcodes[reverseBarcode]=indexBarcode;
- }
-
//check for repeat barcodes
map<string, int>::iterator itBar = barcodes.find(oligo);
if (itBar != barcodes.end()) { m->mothurOut("barcode " + oligo + " is in your oligos file already."); m->mothurOutEndLine(); }
barcodes[oligo]=indexBarcode; indexBarcode++;
barcodeNameVector.push_back(group);
-
}else if(type == "LINKER"){
linker.push_back(oligo);
}else if(type == "SPACER"){
}
ofstream temp;
- string thisFilename = outputDir + m->getRootName(m->getSimpleName(currentFileName)) + comboGroupName + "." + getOutputFileNameTag("sff");
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(currentFileName));
+ variables["[group]"] = comboGroupName;
+ string thisFilename = getOutputFileName("sff",variables);
if (uniqueNames.count(thisFilename) == 0) {
outputNames.push_back(thisFilename);
outputTypes["sff"].push_back(thisFilename);
numFPrimers = primers.size();
numLinkers = linker.size();
numSpacers = spacer.size();
- noMatchFile = outputDir + m->getRootName(m->getSimpleName(currentFileName)) + "scrap." + getOutputFileNameTag("sff");
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(currentFileName));
+ variables["[group]"] = "scrap";
+ noMatchFile = getOutputFileName("sff",variables);
m->mothurRemove(noMatchFile);
bool allBlank = true;