errorCode decodeDecimalValue(EXIStream* strm, Decimal* dec_val) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; boolean sign; UnsignedInteger integr_part = 0; UnsignedInteger fract_part = 0; UnsignedInteger fract_part_rev = 0; unsigned int e; DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (decimal)")); // TODO: implement checks on type overflow TRY(decodeBoolean(strm, &sign)); TRY(decodeUnsignedInteger(strm, &integr_part)); TRY(decodeUnsignedInteger(strm, &fract_part)); dec_val->exponent = 0; fract_part_rev = 0; while(fract_part > 0) { fract_part_rev = fract_part_rev*10 + fract_part%10; fract_part = fract_part/10; dec_val->exponent -= 1; } if(sign == TRUE) // negative number dec_val->mantissa = -1; else dec_val->mantissa = 1; dec_val->mantissa *= integr_part; e = dec_val->exponent; if(e != 0) { while(e) { dec_val->mantissa *= 10; e++; } dec_val->mantissa += fract_part_rev; } return EXIP_OK; }
errorCode decodeIntegerValue(EXIStream* strm, Integer* sint_val) { // TODO: If there is associated schema datatype handle differently! // TODO: check if the result fit into int type errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; boolean bool_val = 0; UnsignedInteger val; DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (int)")); TRY(decodeBoolean(strm, &bool_val)); TRY(decodeUnsignedInteger(strm, &val)); if(bool_val == 0) // A sign value of zero (0) is used to represent positive integers *sint_val = (Integer) val; else if(bool_val == 1) // A sign value of one (1) is used to represent negative integers { val += 1; *sint_val = -((Integer) val); } else return EXIP_UNEXPECTED_ERROR; return EXIP_OK; }
void gkLibrary::gkLibrary_setFeature(char *fea, char *val) { // Unitigger options if (strcasecmp(fea, "forceBOGunitigger") == 0) forceBOGunitigger = decodeBoolean("forceBOGunitigger", val); else if (strcasecmp(fea, "isNotRandom") == 0) isNotRandom = decodeBoolean("isNotRandom", val); // Alignment options else if (strcasecmp(fea, "doNotTrustHomopolymerRuns") == 0) doNotTrustHomopolymerRuns = decodeBoolean("doNotTrustHomopolymerRuns", val); // OBT options else if (strcasecmp(fea, "doTrim_initialNone") == 0) doTrim_initialNone = decodeBoolean("doTrim_initialNone", val); else if (strcasecmp(fea, "doTrim_initialMerBased") == 0) doTrim_initialMerBased = decodeBoolean("doTrim_initialMerBased", val); else if (strcasecmp(fea, "doTrim_initialFlowBased") == 0) doTrim_initialFlowBased = decodeBoolean("doTrim_initialFlowBased", val); else if (strcasecmp(fea, "doTrim_initialQualityBased") == 0) doTrim_initialQualityBased = decodeBoolean("doTrim_initialQualityBased", val); else if (strcasecmp(fea, "doRemoveDuplicateReads") == 0) doRemoveDuplicateReads = decodeBoolean("doRemoveDuplicateReads", val); else if (strcasecmp(fea, "doTrim_finalLargestCovered") == 0) doTrim_finalLargestCovered = decodeBoolean("doTrim_finalLargestCovered", val); else if (strcasecmp(fea, "doTrim_finalEvidenceBased") == 0) doTrim_finalEvidenceBased = decodeBoolean("doTrim_finalEvidenceBased", val); else if (strcasecmp(fea, "doTrim_finalBestEdge") == 0) doTrim_finalBestEdge = decodeBoolean("doTrim_finalBestEdge", val); else if (strcasecmp(fea, "doRemoveSpurReads") == 0) doRemoveSpurReads = decodeBoolean("doRemoveSpurReads", val); else if (strcasecmp(fea, "doRemoveChimericReads") == 0) doRemoveChimericReads = decodeBoolean("doRemoveChimericReads", val); else if (strcasecmp(fea, "doCheckForSubReads") == 0) doCheckForSubReads = decodeBoolean("doCheckForSubReads", val); // COMPATIBILITY OPTIONS else if (strcasecmp(fea, "doMerBasedTrimming") == 0) { fprintf(stderr, "COMPATIBILITY doMerBasedTrimming\n"); if (decodeBoolean("doMerBasedTrimming", val) == 1) { fprintf(stderr, "COMPATIBILITY doMerBasedTrimming\n"); doTrim_initialNone = 0; doTrim_initialMerBased = 1; doTrim_initialFlowBased = 0; doTrim_initialQualityBased = 0; doTrim_finalLargestCovered = 1; doTrim_finalEvidenceBased = 0; doTrim_finalBestEdge = 0; } } else if (strcasecmp(fea, "doNotQVTrim") == 0) { fprintf(stderr, "COMPATIBILITY doNotQVTrim\n"); if (decodeBoolean("doNotQVTrim", val) == 1) { fprintf(stderr, "COMPATIBILITY doNotQVTrim\n"); doTrim_initialNone = 0; doTrim_initialMerBased = 0; doTrim_initialFlowBased = 1; doTrim_initialQualityBased = 0; doTrim_finalLargestCovered = 0; doTrim_finalEvidenceBased = 1; doTrim_finalBestEdge = 0; } } else if (strcasecmp(fea, "goodBadQVThreshold") == 0) { fprintf(stderr, "COMPATIBILITY doNotOverlapTrim\n"); } else if (strcasecmp(fea, "doNotOverlapTrim") == 0) { fprintf(stderr, "COMPATIBILITY doNotOverlapTrim\n"); if (decodeBoolean("doNotOverlapTrim", val) == 1) { fprintf(stderr, "COMPATIBILITY doNotOverlapTrim\n"); doTrim_initialNone = 0; doTrim_initialMerBased = 0; doTrim_initialFlowBased = 0; doTrim_initialQualityBased = 0; doTrim_finalLargestCovered = 0; doTrim_finalEvidenceBased = 0; doTrim_finalBestEdge = 0; } } else if (strcasecmp(fea, "doConsensusCorrection") == 0) doConsensusCorrection = decodeBoolean("doConsensusCorrection", val); // Gatekeeper options else if (strcasecmp(fea, "forceShortReadFormat") == 0) forceShortReadFormat = decodeBoolean("forceShortReadFormat", val); // Illumina options, just to make it not complain about unknown features else if ((strcasecmp(fea, "illuminaFastQType") == 0) || (strcasecmp(fea, "illuminaOrientation") == 0) || (strcasecmp(fea, "illuminaQSequence") == 0) || (strcasecmp(fea, "illuminaSequence") == 0)) // These are now errors, handled by AS_GKP_illumina.C. ; else if ((strcasecmp(fea, "fastqQualityValues") == 0) || (strcasecmp(fea, "fastqOrientation") == 0) || (strcasecmp(fea, "fastqMates") == 0) || (strcasecmp(fea, "fastqReads") == 0)) ; // Library options (orientation is not a feature, it's part of the library) else if (strcasecmp(fea, "constantInsertSize") == 0) constantInsertSize = decodeBoolean("constantInsertSize", val); else fprintf(stderr, "gkLibrary_decodeFeatures()-- found feature '%s' but don't understand it.\n", fea); }
errorCode decodeDateTimeValue(EXIStream* strm, EXIType dtType, EXIPDateTime* dt_val) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; Integer year; unsigned int monDay = 0; unsigned int timeVal = 0; boolean presence = FALSE; dt_val->presenceMask = 0; DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (dateTime)")); if(dtType == VALUE_TYPE_DATE_TIME || dtType == VALUE_TYPE_DATE || dtType == VALUE_TYPE_YEAR) { /* Year component */ TRY(decodeIntegerValue(strm, &year)); dt_val->dateTime.tm_year = (int)year - 100; } else { dt_val->dateTime.tm_year = INT_MIN; } if(dtType == VALUE_TYPE_DATE_TIME || dtType == VALUE_TYPE_DATE || dtType == VALUE_TYPE_MONTH) { /* MonthDay component */ TRY(decodeNBitUnsignedInteger(strm, 9, &monDay)); dt_val->dateTime.tm_mon = monDay / 32 - 1; dt_val->dateTime.tm_mday = monDay % 32; } else { dt_val->dateTime.tm_mon = INT_MIN; dt_val->dateTime.tm_mday = INT_MIN; } if(dtType == VALUE_TYPE_DATE_TIME || dtType == VALUE_TYPE_TIME) { /* Time component */ TRY(decodeNBitUnsignedInteger(strm, 17, &timeVal)); dt_val->dateTime.tm_hour = (timeVal / 64) / 64; dt_val->dateTime.tm_min = (timeVal / 64) % 64; dt_val->dateTime.tm_sec = timeVal % 64; /* FractionalSecs presence component */ TRY(decodeBoolean(strm, &presence)); if(presence) { UnsignedInteger fSecs = 0; unsigned int tmp = 0; dt_val->presenceMask = dt_val->presenceMask | FRACT_PRESENCE; dt_val->fSecs.offset = 0; dt_val->fSecs.value = 0; /* FractionalSecs component */ TRY(decodeUnsignedInteger(strm, &fSecs)); while(fSecs != 0) { tmp = fSecs % 10; dt_val->fSecs.offset++; if(tmp != 0) { dt_val->fSecs.value = dt_val->fSecs.value*10 + tmp; } fSecs = fSecs / 10; } dt_val->fSecs.offset -= 1; } } else { dt_val->dateTime.tm_hour = INT_MIN; dt_val->dateTime.tm_min = INT_MIN; dt_val->dateTime.tm_sec = INT_MIN; } /* TimeZone presence component */ TRY(decodeBoolean(strm, &presence)); if(presence) { unsigned int tzone = 0; dt_val->presenceMask = dt_val->presenceMask | TZONE_PRESENCE; TRY(decodeNBitUnsignedInteger(strm, 11, &tzone)); dt_val->TimeZone = tzone; } return EXIP_OK; }