VecStr readObjsToVecStr(const std::vector<T> & vec){ VecStr ans; for(const auto & read : vec){ ans.emplace_back(read.seqBase_.seq_); } return ans; }
VecStr TableReader::extractCols(const VecStr & row, const VecStr & cols) const{ VecStr ret; ret.reserve(cols.size()); for(const auto & col : cols){ ret.emplace_back(row[header_.getColPos(col)]); } return ret; }
VecStr numVecToVecStr(const std::vector<T>& nums) { VecStr ans; ans.reserve(nums.size()); // std::generate_n(ans.begin(), nums.size(), [](const T & num) {return // estd::to_string(num);}); for (const auto& num : nums) { ans.emplace_back(estd::to_string(num)); } return ans; }
VecStr tokenizeString(const std::string& str, const std::string& delim, bool addEmptyToEnd = false) { VecStr output; if("whitespace" == delim){ std::stringstream tempStream(str); while (!tempStream.eof()) { std::string tempName; tempStream >> tempName; output.emplace_back(tempName); } }else{
TableReader::TableReader(const TableIOOpts & tabOpts): tabOpts_(tabOpts){ //inital header reader njh::files::checkExistenceThrow(tabOpts_.in_.inFilename_); std::string currentLine = njh::files::getFirstLine( tabOpts_.in_.inFilename_); auto toks = tokenizeString(currentLine, tabOpts_.inDelim_, true); VecStr columnNames; if (!tabOpts_.hasHeader_) { for (const auto i : iter::range(toks.size())) { columnNames.emplace_back("col." + leftPadNumStr(i, toks.size())); } } else { columnNames = toks; } header_ = table(columnNames); in_ = std::make_unique<InputStream>(tabOpts_.in_); if(tabOpts_.hasHeader_){ njh::files::crossPlatGetline(*in_, currentLine); } }
void addAsStrToVec(VecStr& vec, const std::vector<T>& items) { for (const auto& e : items) { vec.emplace_back(estd::to_string(e)); } }
void addAsStrToVec(VecStr& vec, const T& e) { vec.emplace_back(estd::to_string(e)); }