- ifstream oligosFile;
- m->openInputFile(oligoFileName, oligosFile);
-
- string type, oligo, group;
-
- int indexPrimer = 0;
- int indexBarcode = 0;
-
- while(!oligosFile.eof()){
-
- oligosFile >> type; //get the first column value of the row - is it a comment or a feature we are interested in?
-
- if (m->debug) { m->mothurOut("[DEBUG]: type = " + type + ".\n"); }
-
- if(type[0] == '#'){ //igore the line because there's a comment
- while (!oligosFile.eof()) { char c = oligosFile.get(); if (c == 10 || c == 13){ break; } }
- m->gobble(oligosFile);// get rest of line if there's any crap there
- }
- else{ //there's a feature we're interested in
- m->gobble(oligosFile);
- for(int i=0;i<type.length();i++){ type[i] = toupper(type[i]); } //make type case insensitive
-
- oligosFile >> oligo; //get the DNA sequence for the feature
-
- for(int i=0;i<oligo.length();i++){ //make type case insensitive and change any U's to T's
- oligo[i] = toupper(oligo[i]);
- if(oligo[i] == 'U') { oligo[i] = 'T'; }
- }
-
- if (m->debug) { m->mothurOut("[DEBUG]: oligos = " + oligo + ".\n"); }
-
- if(type == "FORWARD"){ //if the feature is a forward primer...
- group = "";
-
- while (!oligosFile.eof()) { // get rest of line in case there is a primer name = will have the name of the primer
- char c = oligosFile.get();
- if (c == 10 || c == 13){ break; }
- else if (c == 32 || c == 9){;} //space or tab
- else { group += c; }
- }
-
- //have we seen this primer already?
- map<string, int>::iterator itPrimer = primers.find(oligo);
- if (itPrimer != primers.end()) { m->mothurOut("primer " + oligo + " is in your oligos file already."); m->mothurOutEndLine(); }
-
- primers[oligo]=indexPrimer; indexPrimer++;
- primerNameVector.push_back(group);
-
- }
- else if(type == "REVERSE"){
- string oligoRC = reverseOligo(oligo);
- revPrimer.push_back(oligoRC);
- }
- else if(type == "BARCODE"){
- oligosFile >> group;
-
- //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(); }
-
- if (m->debug) { m->mothurOut("[DEBUG]: group = " + group + ".\n"); }
-
- barcodes[oligo]=indexBarcode; indexBarcode++;
- barcodeNameVector.push_back(group);
- }else if(type == "LINKER"){
- linker.push_back(oligo);
- }else if(type == "SPACER"){
- spacer.push_back(oligo);
- }
- else{
- m->mothurOut(type + " is not recognized as a valid type. Choices are forward, reverse, and barcode. Ignoring " + oligo + "."); m->mothurOutEndLine();
- }
- }
-
- m->gobble(oligosFile);
- }
- oligosFile.close();
-
- if(barcodeNameVector.size() == 0 && primerNameVector[0] == ""){ allFiles = 0; }
-
- //add in potential combos
- if(barcodeNameVector.size() == 0){
- barcodes[""] = 0;
- barcodeNameVector.push_back("");
- }
-
- if(primerNameVector.size() == 0){
- primers[""] = 0;
- primerNameVector.push_back("");
- }
-
-
- outFlowFileNames.resize(barcodeNameVector.size());
+ bool allBlank = false;
+ oligos.read(oligoFileName);
+
+ if (m->control_pressed) { return 0; } //error in reading oligos
+
+ if (oligos.hasPairedBarcodes()) {
+ pairedOligos = true;
+ numFPrimers = oligos.getPairedPrimers().size();
+ numBarcodes = oligos.getPairedBarcodes().size();
+ }else {
+ pairedOligos = false;
+ numFPrimers = oligos.getPrimers().size();
+ numBarcodes = oligos.getBarcodes().size();
+ }
+
+ numLinkers = oligos.getLinkers().size();
+ numSpacers = oligos.getSpacers().size();
+ numRPrimers = oligos.getReversePrimers().size();
+
+ vector<string> groupNames = oligos.getGroupNames();
+ if (groupNames.size() == 0) { allFiles = 0; allBlank = true; }
+
+
+ outFlowFileNames.resize(oligos.getBarcodeNames().size());