- ifstream inOligos;
- m->openInputFile(oligoFile, inOligos);
-
- string type, oligo, roligo, group;
- bool hasPrimer = false; bool hasPairedBarcodes = false; pairedOligos = false;
-
- int indexPrimer = 0;
- int indexBarcode = 0;
- int indexPairedPrimer = 0;
- int indexPairedBarcode = 0;
- set<string> uniquePrimers;
- set<string> 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<type.length();i++){ type[i] = toupper(type[i]); }
-
- inOligos >> oligo;
-
- if (m->debug) { m->mothurOut("[DEBUG]: reading - " + oligo + ".\n"); }
-
- for(int i=0;i<oligo.length();i++){
- oligo[i] = toupper(oligo[i]);
- if(oligo[i] == 'U') { oligo[i] = 'T'; }
- }
-
- if(type == "FORWARD"){
- group = "";
-
- // get rest of line in case there is a primer name
- 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 { group += c; }
- }
-
- //check for repeat barcodes
- map<string, int>::iterator itPrime = primers.find(oligo);
- if (itPrime != primers.end()) { m->mothurOut("primer " + oligo + " is in your oligos file already."); m->mothurOutEndLine(); }
-
- if (m->debug) { if (group != "") { m->mothurOut("[DEBUG]: reading group " + group + ".\n"); }else{ m->mothurOut("[DEBUG]: no group for primer " + oligo + ".\n"); } }
-
- primers[oligo]=indexPrimer; indexPrimer++;
- primerNameVector.push_back(group);
- }
- else if (type == "PRIMER"){
- m->gobble(inOligos);
-
- inOligos >> roligo;
-
- for(int i=0;i<roligo.length();i++){
- roligo[i] = toupper(roligo[i]);
- if(roligo[i] == 'U') { roligo[i] = 'T'; }
- }
- roligo = reverseOligo(roligo);
-
- group = "";
-
- // get rest of line in case there is a primer name
- 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 { group += c; }
- }
-
- oligosPair newPrimer(oligo, roligo);
-
- if (m->debug) { m->mothurOut("[DEBUG]: primer pair " + newPrimer.forward + " " + newPrimer.reverse + ", and group = " + group + ".\n"); }
-
- //check for repeat barcodes
- string tempPair = oligo+roligo;
- if (uniquePrimers.count(tempPair) != 0) { m->mothurOut("primer pair " + newPrimer.forward + " " + newPrimer.reverse + " is in your oligos file already."); m->mothurOutEndLine(); }
- else { uniquePrimers.insert(tempPair); }
-
- if (m->debug) { if (group != "") { m->mothurOut("[DEBUG]: reading group " + group + ".\n"); }else{ m->mothurOut("[DEBUG]: no group for primer pair " + newPrimer.forward + " " + newPrimer.reverse + ".\n"); } }
-
- pairedPrimers[indexPairedPrimer]=newPrimer; indexPairedPrimer++;
- primerNameVector.push_back(group);
- hasPrimer = true;
- }
- else if(type == "REVERSE"){
- //Sequence oligoRC("reverse", oligo);
- //oligoRC.reverseComplement();
- string oligoRC = reverseOligo(oligo);
- revPrimer.push_back(oligoRC);
- }
- 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 || 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 != "") {
- hasPairedBarcodes = true;
- string reverseBarcode = group; //reverseOligo(group); //reverse barcode
- group = temp;
-
- for(int i=0;i<reverseBarcode.length();i++){
- reverseBarcode[i] = toupper(reverseBarcode[i]);
- if(reverseBarcode[i] == 'U') { reverseBarcode[i] = 'T'; }
- }
-
- reverseBarcode = reverseOligo(reverseBarcode);
- oligosPair newPair(oligo, reverseBarcode);
-
- if (m->debug) { m->mothurOut("[DEBUG]: barcode pair " + newPair.forward + " " + newPair.reverse + ", and group = " + group + ".\n"); }
- //check for repeat barcodes
- string tempPair = oligo+reverseBarcode;
- if (uniqueBarcodes.count(tempPair) != 0) { m->mothurOut("barcode pair " + newPair.forward + " " + newPair.reverse + " is in your oligos file already, disregarding."); m->mothurOutEndLine(); }
- else { uniqueBarcodes.insert(tempPair); }
-
- pairedBarcodes[indexPairedBarcode]=newPair; indexPairedBarcode++;
- barcodeNameVector.push_back(group);
- }else {
- //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"){
- spacer.push_back(oligo);
- }
- else{ m->mothurOut("[WARNING]: " + type + " is not recognized as a valid type. Choices are forward, reverse, and barcode. Ignoring " + oligo + "."); m->mothurOutEndLine(); }
- }
- m->gobble(inOligos);
- }
- inOligos.close();
-
- if (hasPairedBarcodes || hasPrimer) {