Loading src/BUSData.h +7 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,11 @@ struct BUSHeader { std::string text; std::vector<BUSTranscript> transcripts; std::vector<std::vector<int32_t>> ecs; uint32_t version; uint32_t bclen; uint32_t umilen; BUSHeader() : version(0), bclen(0), umilen(0) {} }; struct BUSData { Loading @@ -26,8 +31,8 @@ struct BUSData { int32_t ec; uint32_t count; uint32_t flags; BUSData() : barcode(0), UMI(0), ec(-1), count(0), flags(0) {} uint32_t pad; BUSData() : barcode(0), UMI(0), ec(-1), count(0), flags(0), pad(0) {} }; uint64_t stringToBinary(const std::string &s, uint32_t &flag); Loading src/common.h +1 −1 Original line number Diff line number Diff line #ifndef KALLISTO_COMMON_H #define KALLISTO_COMMON_H #define KALLISTO_VERSION "0.45.1" #define KALLISTO_VERSION "0.46.0" #include <string> #include <vector> Loading src/main.cpp +119 −2 Original line number Diff line number Diff line Loading @@ -600,6 +600,106 @@ void ParseOptionsBus(int argc, char **argv, ProgramOptions& opt) { } bool ParseTechnology(const std::string &techstr, std::vector<BUSOptionSubstr> &values, std::vector<int> &files, std::vector<std::string> &errorList, std::vector<BUSOptionSubstr> &bcValues) { int lastIndex = 0; //the last place in the string a colon and punctuation was found int currValue = 1; //tells us the index of the three sequences needed barcode, umi, sequence vector<int> numbers; //stores the numbers in a pairs const char punctuationCompare = ','; const char colonCompare = ':'; bool colon; bool duplicate = false; std::string stringVal; int val; for(int i = 1; i < techstr.length(); i++) { colon = false; if(techstr[i] == colonCompare) { colon = true; } if(techstr[i] == punctuationCompare || colon) { stringVal = techstr.substr(lastIndex, i-lastIndex); try { val = stoi(stringVal); numbers.push_back(val); if(numbers.size() == 1) { if(!files.empty()) { for(int j = 0; j < files.size(); j++) { if(val == files[j]) { duplicate = true; break; } } if(!duplicate) { files.push_back(val); } else { duplicate = false; } } else { files.push_back(val); } } lastIndex = i + 1; } catch(const std:: invalid_argument& ia) { errorList.push_back("Error: Invalid argument"); return true; } if(colon) { if(numbers.size() != 3) { errorList.push_back("Error: Wrong number of pairs provided"); return true; } } } if(numbers.size() == 3) { if(currValue == 1) { bcValues.push_back(BUSOptionSubstr(numbers[0], numbers[1], numbers[2])); } else { values.push_back(BUSOptionSubstr(numbers[0], numbers[1], numbers[2])); } numbers.clear(); } if(colon) { currValue++; } } if (files.empty()) { errorList.push_back(std::string("Error: parsing technology string \"") + techstr + "\""); return true; } std::sort(files.begin(), files.end()); for(int k = 0; k < files.size()-1; k++) { if(files[k]+1 != files[k+1]) { errorList.push_back("Error: files aren't correctly referenced"); return true; } } stringVal = techstr.substr(lastIndex, techstr.length()-lastIndex); if(numbers.size() == 2) { try { val = stoi(stringVal); numbers.push_back(val); values.push_back(BUSOptionSubstr(numbers[0], numbers[1], numbers[2])); numbers.clear(); } catch(const std:: invalid_argument& ia) { errorList.push_back("Error: Invalid argument"); return true; } } else { errorList.push_back("Error: Wrong number of pairs provided"); return true; } if(currValue != 3) { errorList.push_back("Error: Wrong number of substrings provided"); return true; } return false; } void ParseOptionsH5Dump(int argc, char **argv, ProgramOptions& opt) { int peek_flag = 0; Loading Loading @@ -762,10 +862,27 @@ bool CheckOptionsBus(ProgramOptions& opt) { busopt.umi = BUSOptionSubstr(0,6,16); busopt.bc.push_back(BUSOptionSubstr(0,0,6)); } else { cerr << "Unknown technology: " << opt.technology << endl; vector<int> files; vector<BUSOptionSubstr> values; vector<BUSOptionSubstr> bcValues; vector<std::string> errorList; bool invalid = ParseTechnology(opt.technology, values, files, errorList, bcValues); if(!invalid) { busopt.nfiles = files.size(); for(int i = 0; i < bcValues.size(); i++) { busopt.bc.push_back(bcValues[i]); } busopt.umi = values[0]; busopt.seq = values[1]; } else { for(int j = 0; j < errorList.size(); j++) { cerr << errorList[j] << endl; } cerr << "Unable to create technology: " << opt.technology << endl; ret = false; } } } if (ret && opt.files.size() % opt.busOptions.nfiles != 0) { cerr << "Error: Number of files (" << opt.files.size() << ") does not match number of input files required by " Loading Loading
src/BUSData.h +7 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,11 @@ struct BUSHeader { std::string text; std::vector<BUSTranscript> transcripts; std::vector<std::vector<int32_t>> ecs; uint32_t version; uint32_t bclen; uint32_t umilen; BUSHeader() : version(0), bclen(0), umilen(0) {} }; struct BUSData { Loading @@ -26,8 +31,8 @@ struct BUSData { int32_t ec; uint32_t count; uint32_t flags; BUSData() : barcode(0), UMI(0), ec(-1), count(0), flags(0) {} uint32_t pad; BUSData() : barcode(0), UMI(0), ec(-1), count(0), flags(0), pad(0) {} }; uint64_t stringToBinary(const std::string &s, uint32_t &flag); Loading
src/common.h +1 −1 Original line number Diff line number Diff line #ifndef KALLISTO_COMMON_H #define KALLISTO_COMMON_H #define KALLISTO_VERSION "0.45.1" #define KALLISTO_VERSION "0.46.0" #include <string> #include <vector> Loading
src/main.cpp +119 −2 Original line number Diff line number Diff line Loading @@ -600,6 +600,106 @@ void ParseOptionsBus(int argc, char **argv, ProgramOptions& opt) { } bool ParseTechnology(const std::string &techstr, std::vector<BUSOptionSubstr> &values, std::vector<int> &files, std::vector<std::string> &errorList, std::vector<BUSOptionSubstr> &bcValues) { int lastIndex = 0; //the last place in the string a colon and punctuation was found int currValue = 1; //tells us the index of the three sequences needed barcode, umi, sequence vector<int> numbers; //stores the numbers in a pairs const char punctuationCompare = ','; const char colonCompare = ':'; bool colon; bool duplicate = false; std::string stringVal; int val; for(int i = 1; i < techstr.length(); i++) { colon = false; if(techstr[i] == colonCompare) { colon = true; } if(techstr[i] == punctuationCompare || colon) { stringVal = techstr.substr(lastIndex, i-lastIndex); try { val = stoi(stringVal); numbers.push_back(val); if(numbers.size() == 1) { if(!files.empty()) { for(int j = 0; j < files.size(); j++) { if(val == files[j]) { duplicate = true; break; } } if(!duplicate) { files.push_back(val); } else { duplicate = false; } } else { files.push_back(val); } } lastIndex = i + 1; } catch(const std:: invalid_argument& ia) { errorList.push_back("Error: Invalid argument"); return true; } if(colon) { if(numbers.size() != 3) { errorList.push_back("Error: Wrong number of pairs provided"); return true; } } } if(numbers.size() == 3) { if(currValue == 1) { bcValues.push_back(BUSOptionSubstr(numbers[0], numbers[1], numbers[2])); } else { values.push_back(BUSOptionSubstr(numbers[0], numbers[1], numbers[2])); } numbers.clear(); } if(colon) { currValue++; } } if (files.empty()) { errorList.push_back(std::string("Error: parsing technology string \"") + techstr + "\""); return true; } std::sort(files.begin(), files.end()); for(int k = 0; k < files.size()-1; k++) { if(files[k]+1 != files[k+1]) { errorList.push_back("Error: files aren't correctly referenced"); return true; } } stringVal = techstr.substr(lastIndex, techstr.length()-lastIndex); if(numbers.size() == 2) { try { val = stoi(stringVal); numbers.push_back(val); values.push_back(BUSOptionSubstr(numbers[0], numbers[1], numbers[2])); numbers.clear(); } catch(const std:: invalid_argument& ia) { errorList.push_back("Error: Invalid argument"); return true; } } else { errorList.push_back("Error: Wrong number of pairs provided"); return true; } if(currValue != 3) { errorList.push_back("Error: Wrong number of substrings provided"); return true; } return false; } void ParseOptionsH5Dump(int argc, char **argv, ProgramOptions& opt) { int peek_flag = 0; Loading Loading @@ -762,10 +862,27 @@ bool CheckOptionsBus(ProgramOptions& opt) { busopt.umi = BUSOptionSubstr(0,6,16); busopt.bc.push_back(BUSOptionSubstr(0,0,6)); } else { cerr << "Unknown technology: " << opt.technology << endl; vector<int> files; vector<BUSOptionSubstr> values; vector<BUSOptionSubstr> bcValues; vector<std::string> errorList; bool invalid = ParseTechnology(opt.technology, values, files, errorList, bcValues); if(!invalid) { busopt.nfiles = files.size(); for(int i = 0; i < bcValues.size(); i++) { busopt.bc.push_back(bcValues[i]); } busopt.umi = values[0]; busopt.seq = values[1]; } else { for(int j = 0; j < errorList.size(); j++) { cerr << errorList[j] << endl; } cerr << "Unable to create technology: " << opt.technology << endl; ret = false; } } } if (ret && opt.files.size() % opt.busOptions.nfiles != 0) { cerr << "Error: Number of files (" << opt.files.size() << ") does not match number of input files required by " Loading