X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=getmimarkspackagecommand.cpp;h=67194cea33f77f8853e3668aa5ed39284ca0db26;hp=955cb794a2d5a579abd9da5358195713654ed9cb;hb=fefd5ee1517abd3bc38b469cb2dffc85a1571c7e;hpb=aca78ed4a47dff8672ea8fd93cef0dfbaf0f7495 diff --git a/getmimarkspackagecommand.cpp b/getmimarkspackagecommand.cpp index 955cb79..67194ce 100644 --- a/getmimarkspackagecommand.cpp +++ b/getmimarkspackagecommand.cpp @@ -9,6 +9,7 @@ #include "getmimarkspackagecommand.h" #include "groupmap.h" + //********************************************************************************************************************** vector GetMIMarksPackageCommand::setParameters(){ try { @@ -106,7 +107,7 @@ GetMIMarksPackageCommand::GetMIMarksPackageCommand(string option) { outputTypes["tsv"] = tempOutNames; //if the user changes the input directory command factory will send this info to us in the output parameter - string inputDir = validParameter.validFile(parameters, "inputdir", false); + inputDir = validParameter.validFile(parameters, "inputdir", false); if (inputDir == "not found"){ inputDir = ""; } else { @@ -192,12 +193,10 @@ int GetMIMarksPackageCommand::execute(){ if (abort == true) { if (calledHelp) { return 0; } return 2; } - if (oligosfile != "") { readOligos(); } + if (oligosfile != "") { Oligos oligos(oligosfile); Groups = oligos.getGroupNames(); } else if (file != "") { readFile(); } else { GroupMap groupmap(groupfile); groupmap.readMap(); Groups = groupmap.getNamesOfGroups(); } - for (set::iterator it = uniqueNames.begin(); it != uniqueNames.end(); it++) { Groups.push_back(*it); } - if (outputDir == "") { outputDir += m->hasPath(inputfile); } map variables; variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile)); @@ -332,155 +331,7 @@ int GetMIMarksPackageCommand::execute(){ } } //*************************************************************************************************************** -int GetMIMarksPackageCommand::readOligos(){ - try { - ifstream inOligos; - m->openInputFile(oligosfile, inOligos); - - string type, oligo, roligo, group; - vector primerNameVector, barcodeNameVector; - set uniquePrimers; - set uniqueBarcodes; - - while(!inOligos.eof()){ - - inOligos >> type; - - if (m->debug) { m->mothurOut("[DEBUG]: reading type - " + type + ".\n"); } - - if(type[0] == '#'){ - while (!inOligos.eof()) { char c = inOligos.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there - m->gobble(inOligos); - } - else{ - m->gobble(inOligos); - //make type case insensitive - for(int i=0;i> oligo; - - if (m->debug) { m->mothurOut("[DEBUG]: reading - " + oligo + ".\n"); } - - for(int i=0;igobble(inOligos); - - inOligos >> roligo; - - for(int i=0;i> 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 || c == -1){ 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 = group; //reverseOligo(group); //reverse barcode - group = temp; - - barcodeNameVector.push_back(group); - }else { - barcodeNameVector.push_back(group); - } - } - } - m->gobble(inOligos); - } - inOligos.close(); - - //add in potential combos - if(barcodeNameVector.size() == 0){ - barcodeNameVector.push_back(""); - } - - if(primerNameVector.size() == 0){ - primerNameVector.push_back(""); - } - - - for(int i = 0; i < barcodeNameVector.size(); i++){ - for(int j = 0; j < primerNameVector.size(); j++){ - - string primerName = primerNameVector[j]; - string barcodeName = barcodeNameVector[i]; - - if ((primerName == "ignore") || (barcodeName == "ignore")) { } //do nothing - else if ((primerName == "") && (barcodeName == "")) { } - else { - string comboGroupName = ""; - - if(primerName == ""){ - comboGroupName = barcodeNameVector[i]; - } - else{ - if(barcodeName == ""){ - comboGroupName = primerNameVector[j]; - } - else{ - comboGroupName = barcodeNameVector[i] + "." + primerNameVector[j]; - } - } - uniqueNames.insert(comboGroupName); - } - } - } - - - - if (m->debug) { int count = 0; for (set::iterator it = uniqueNames.begin(); it != uniqueNames.end(); it++) { m->mothurOut("[DEBUG]: " + toString(count) + " groupName = " + *it + "\n"); count++; } } - - - return true; - - } - catch(exception& e) { - m->errorOut(e, "GetMIMarksPackageCommand", "readOligos"); - exit(1); - } -} -//********************************************************************************************************************** + // going to have to rework this to allow for other options -- /* file option 1 @@ -506,7 +357,7 @@ int GetMIMarksPackageCommand::readOligos(){ int GetMIMarksPackageCommand::readFile(){ try { - //vector theseFiles; + Oligos oligos; inputfile = file; ifstream in; @@ -534,6 +385,14 @@ int GetMIMarksPackageCommand::readFile(){ if (m->debug) { m->mothurOut("[DEBUG]: group = " + group + ", thisFileName1 = " + thisFileName1 + ", thisFileName2 = " + thisFileName2 + ".\n"); } + if (inputDir != "") { + string path = m->hasPath(thisFileName2); + if (path == "") { thisFileName2 = inputDir + thisFileName2; } + + path = m->hasPath(thisFileName1); + if (path == "") { thisFileName1 = inputDir + thisFileName1; } + } + //check to make sure both are able to be opened ifstream in2; int openForward = m->openInputFile(thisFileName1, in2, "noerror"); @@ -603,13 +462,15 @@ int GetMIMarksPackageCommand::readFile(){ if ((pieces.size() == 2) && (openForward != 1) && (openReverse != 1)) { //good pair and sff or fastq and oligos oligosfile = thisFileName2; if (m->debug) { m->mothurOut("[DEBUG]: about to read oligos\n"); } - readOligos(); + oligos.read(oligosfile); }else if((pieces.size() == 3) && (openForward != 1) && (openReverse != 1)) { //good pair and paired read Groups.push_back(group); } } in.close(); + Groups = oligos.getGroupNames(); + inputfile = file; return 0;