/** * Sets an interval. */ void GenomeInterval::set(std::string interval) { std::vector<std::string> v; split(v, ":-", interval); if (v.size()==1) { seq = v[0]; start1 = 1; end1 = (1<<29) - 1; } else if (v.size()==3) { seq = v[0]; if (!str2int32(v[1], start1) || !str2int32(v[2], end1)) { fprintf(stderr, "[%s:%d %s] Invalid genomic interval: %s\n", __FILE__,__LINE__,__FUNCTION__, interval.c_str()); exit(1); } } else { fprintf(stderr, "[%s:%d %s] Invalid genomic interval: %s\n", __FILE__,__LINE__,__FUNCTION__, interval.c_str()); exit(1); } }
/** * Constructor. */ BEDRecord::BEDRecord(kstring_t *s) { std::vector<std::string> fields; split(fields, "\t", s->s); chrom = fields[0]; str2int32(fields[1], beg1); str2int32(fields[2], end1); };
/** * Constructor. */ BEDRecord::BEDRecord(std::string& s) { std::vector<std::string> fields; split(fields, "\t", s.c_str()); chrom = fields[0]; str2int32(fields[1], beg1); ++beg1; //BED interval is 0 based half open str2int32(fields[2], end1); };
int is_frame_valid(s_audinfo_t *inf) { int ret = 0; u_framehead_t head; head.value = str2int32(inf->data, inf->ibn); if (head.bits_mp3.sync != 0xFFF || head.bits_mp3.id != 1 || head.bits_mp3.layer != 0x1 || head.bits_mp3.bitrate == 0xF || head.bits_mp3.samplerate == 0x3 ) { //printf("Not supported head"); return ret; } inf->parser.head.value = head.value; inf->parser.idx++; return ret; }
boost::shared_ptr<AbstractValue> prim(bool get) { boost::shared_ptr<AbstractValue> result; if ( get ) curr_tok = yylex(); switch ( curr_tok ) { case INT: { int32_t num; if ( !str2int32(num, (*globalLexTable)[yylval].text) ) throw "Error int convertion"; AbstractType* type = globalTypeTable->prototype("int"); result = boost::shared_ptr<AbstractValue>(type->create()); (( NumberValue<int32_t, VINT32>*)result.get())->setValue(num); curr_tok = yylex(); } break; case DOUBLE: { double num; if ( !str2double(num, (*globalLexTable)[yylval].text) ) throw "Error double convertion"; AbstractType* type = globalTypeTable->prototype("float"); result = boost::shared_ptr<AbstractValue>(type->create()); (( NumberValue<double, VDOUBLE>*)result.get())->setValue(num); curr_tok = yylex(); } break; case STRING: { AbstractType* type = globalTypeTable->prototype("string"); result = boost::shared_ptr<AbstractValue>(type->create()); ((StringValue*)result.get())->setValue((*globalLexTable)[yylval].text); } break; case ID: { std::string id = (*globalLexTable)[yylval].text; if ( !globalValueTable->exists(id) ) throw "Undefined identifier"; AbstractValue* value = globalValueTable->value(id); if (( curr_tok = yylex()) == ASSIGNMENT ) { boost::shared_ptr<AbstractValue> val = expr(true); AbstractMethod* method = value->getMethod("operator="); method->setParam(1, value); method->setParam(2, val.get()); result = (*method)(); } else result = value->clone(); } break; case MINUS: { result = prim(true); AbstractMethod* method = result.get()->getMethod("operator-u"); method->setParam(1, result.get()); result = (*method)(); } break; case LP: result = expr(true); if ( curr_tok != RP ) throw "Expected ')'"; curr_tok = yylex(); break; default: throw "Primary expected"; } return result; }