void TTable::Count(TStr CountColName, TStr Col){ if(!ColTypeMap.IsKey(Col)){TExcept::Throw("no such column " + Col);} TIntV CntCol(NumRows); switch(GetColType(Col)){ case INT:{ THash<TInt,TIntV> T; // can't really estimate the size of T for constructor hinting TIntV& Column = IntCols[GetColIdx(Col)]; GroupByIntCol(Col, T, TIntV(0), true); for(TRowIterator it = BegRI(); it < EndRI(); it++){ CntCol[it.GetRowIdx()] = T.GetDat(Column[it.GetRowIdx()]).Len(); } break; } case FLT:{ THash<TFlt,TIntV> T; TFltV& Column = FltCols[GetColIdx(Col)]; GroupByFltCol(Col, T, TIntV(0), true); for(TRowIterator it = BegRI(); it < EndRI(); it++){ CntCol[it.GetRowIdx()] = T.GetDat(Column[it.GetRowIdx()]).Len(); } break; } case STR:{ THash<TStr,TIntV> T; GroupByStrCol(Col, T, TIntV(0), true); for(TRowIterator it = BegRI(); it < EndRI(); it++){ CntCol[it.GetRowIdx()] = T.GetDat(GetStrVal(Col, it.GetRowIdx())).Len(); } } } // add count column IntCols.Add(CntCol); AddSchemaCol(CountColName, INT); ColTypeMap.AddDat(CountColName, TPair<TYPE,TInt>(INT, IntCols.Len()-1)); }
void GetParameter(int argc, const char* argv[], Option & opt) { if (argc <= 2 || argv == NULL) PrintSynopsis(); else { PrintOutVersion(); cout << "--INFO-- Input command:"; for (int i = 0; i < argc; i++) { cout << " " << argv[i]; } cout << endl; opt.refFile = argv[1]; cout << "--INFO-- The reference file is " << opt.refFile << endl; opt.bIndexExist = 0; string indexsf = ".sdindex"; if (opt.refFile.size() > indexsf.size() && opt.refFile.substr(opt.refFile.size() - indexsf.size()) == indexsf) { opt.bIndexExist = 1; } opt.readsFile = argv[2]; cout << "--INFO-- The reads file is " << opt.readsFile << "." << endl; if (GetIntVal(argc, argv, "-v", opt.mapOpt.nMaxMismatch) == 0) opt.mapOpt.nMaxMismatch = 2; if (GetStrVal(argc, argv, "-o", opt.outputFile) == 0) { string fileName; GetNameBeforeDot(opt.readsFile, fileName); opt.outputFile = fileName; opt.outputFile += ".sam"; } opt.bSaveIndex = 0; if (ChkStrExist(argc, argv, "-s")) { opt.bSaveIndex = 1; } if (GetStrVal(argc, argv, "-s", opt.indexFile) == 0 && opt.bSaveIndex == 1) { string fileName; GetNameBeforeDot(opt.refFile, fileName); opt.indexFile = fileName; opt.indexFile += indexsf; } GetReadLength(opt); } }
void GetParameter(int argc, const char* argv[], Option & opt) { LOG_INFO; if (argc <= 2 || argv == NULL) PrintSynopsis(); else { opt.refFile = argv[1]; cout << "The reference file is " << opt.refFile << endl; cout << opt.refFile.length() << endl; cout << opt.refFile.size() << endl; opt.bIndexExist = 0; cout << opt.refFile.size() << endl; cout << opt.refFile.substr(opt.refFile.size() - 6) << endl; cout << "hah" << endl; if (opt.refFile.size() > 6 && opt.refFile.substr(opt.refFile.size() - 6) == ".index") { opt.bIndexExist = 1; } opt.readsFile = argv[2]; cout << "The reads file is " << opt.readsFile << endl; if (GetIntVal(argc, argv, "-v", opt.mapOpt.nMaxMismatch) == 0) opt.mapOpt.nMaxMismatch = 2; if (GetStrVal(argc, argv, "-o", opt.outputFile) == 0) { string fileName; GetNameBeforeDot(opt.readsFile, fileName); opt.outputFile = fileName; opt.outputFile += ".sam"; } opt.bSaveIndex = 0; if (ChkStrExist(argc, argv, "-s")) { opt.bSaveIndex = 1; } if (GetStrVal(argc, argv, "-s", opt.indexFile) == 0 && opt.bSaveIndex == 1) { string fileName; GetNameBeforeDot(opt.refFile, fileName); opt.indexFile = fileName; opt.indexFile += ".index"; } } }
void TTable::GroupByStrCol(TStr GroupBy, THash<TStr,TIntV>& Grouping, const TIntV& IndexSet, TBool All) const{ if(!ColTypeMap.IsKey(GroupBy)){TExcept::Throw("no such column " + GroupBy);} if(GetColType(GroupBy) != STR){TExcept::Throw(GroupBy + " values are not of expected type string");} if(All){ // optimize for the common and most expensive case - itearte over all valid rows for(TRowIterator it = BegRI(); it < EndRI(); it++){ UpdateGrouping<TStr>(Grouping, it.GetStrAttr(GroupBy), it.GetRowIdx()); } } else{ // consider only rows in IndexSet for(TInt i = 0; i < IndexSet.Len(); i++){ if(IsRowValid(IndexSet[i])){ TInt RowIdx = IndexSet[i]; UpdateGrouping<TStr>(Grouping, GetStrVal(GroupBy, RowIdx), RowIdx); } } } }
void glutInitDisplayString(const char *string) { const char *p = string; int val; while(*p) { if(*p == ' ') p++; else if(memcmp(p, "acca", 4) == 0) { p = GetStrVal(p+4, &AccumSize, 1, 32); SetAttrib(AccumSize, GLUT_ACCUM); } else if(memcmp(p, "acc", 3) == 0) { p = GetStrVal(p+3, &AccumSize, 1, 32); SetAttrib(AccumSize, GLUT_ACCUM); } else if(memcmp(p, "depth", 5) == 0) { p = GetStrVal(p+5, &DepthSize, 12, 32); SetAttrib(DepthSize, GLUT_DEPTH); } else if(memcmp(p, "double", 6) == 0) { val = 1; p = GetStrVal(p+6, &val, 0, 1); SetAttrib(val, GLUT_DOUBLE); } else if(memcmp(p, "index", 5) == 0) { val = 1; p = GetStrVal(p+5, &val, 0, 1); SetAttrib(val, GLUT_INDEX); } else if(memcmp(p, "stencil", 7) == 0) { p = GetStrVal(p+7, &StencilSize, 0, 1); SetAttrib(StencilSize, GLUT_STENCIL); } else if(memcmp(p, "samples", 7) == 0) { NumSamples = 1; p = GetStrVal(p+7, &NumSamples, 0, 16); SetAttrib(NumSamples, GLUT_MULTISAMPLE); } else if(p = strchr(p, ' ')) p++; else break; } }