-int GetMIMarksPackageCommand::readOligos(){
- try {
- ifstream inOligos;
- m->openInputFile(oligosfile, inOligos);
-
- string type, oligo, roligo, group;
- vector<string> primerNameVector, barcodeNameVector;
- 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; }
- }
-
- 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'; }
- }
-
- 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; }
- }
-
- primerNameVector.push_back(group);
- }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 != "") {
-
- 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<string>::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);
- }
-}
-//**********************************************************************************************************************