Ejemplo n.º 1
0
// called prior to using the allele in analysis
void Allele::update(void) {
    quality = currentQuality();
    lnquality = phred2ln(quality);
    if (type == ALLELE_REFERENCE) {
        currentBase = string(1, *currentReferenceBase);
        basesLeft = bpLeft + referenceOffset();
        basesRight = bpRight - referenceOffset();
    } else {
        currentBase = base();
    }
}
Ejemplo n.º 2
0
string Allele::tojson(void) {
    stringstream out;
    if (!genotypeAllele) {
        out << "{\"id\":\"" << readID << "\""
            << ",\"type\":\"" << typeStr() << "\""
            << ",\"length\":" << ((type == ALLELE_REFERENCE) ? 1 : length)
            << ",\"position\":" << position 
            << ",\"strand\":\"" << (strand == STRAND_FORWARD ? "+" : "-") << "\"";
        if (type == ALLELE_REFERENCE ) {
            out << ",\"base\":\"" << alternateSequence.at(referenceOffset()) << "\""
                //<< ",\"reference\":\"" << allele.referenceSequence.at(referenceOffset) << "\""
                << ",\"quality\":" << currentQuality();
        } else {
            out << ",\"base\":\"" << alternateSequence << "\""
                //<< ",\"reference\":\"" << allele.referenceSequence << "\""
                << ",\"quality\":" << quality;
        }
        out << "}";

    } else {
        out << "{\"type\":\"" << typeStr() << "\"";
        switch (type) {
            case ALLELE_REFERENCE:
                out << "}";
                break;
            default:
                out << "\",\"length\":" << length 
                    << ",\"alt\":\"" << alternateSequence << "\"}";
                break;
        }
    }
    return out.str();
}
Ejemplo n.º 3
0
// quality at a given reference position
const short Allele::currentQuality(void) const {
    //cerr << readID << " " << position << "-" << position + length << " " << alternateSequence.size() << " vs " << baseQualities.size() << endl;
    switch (this->type) {
        case ALLELE_REFERENCE:
            // should check a different way... this is wrong
            // it will catch it all the time,
            if (currentBase.size() > 1) {
                return averageQuality(baseQualities);
            } else {
                int off = referenceOffset();
                if (off < 0 || off > baseQualities.size()) {
                    return 0;
                } else {
                    return baseQualities.at(off);
                }
            }
            break;
        case ALLELE_INSERTION:
        case ALLELE_DELETION:
        case ALLELE_SNP:
        case ALLELE_MNP:
        case ALLELE_COMPLEX:
            return quality;
            break;
    }
    return 0;
}
Ejemplo n.º 4
0
const bool Allele::masked(void) const {

    // guard against uninitialized indelMask
    if (indelMask.size() == 0)
        return false;

    if (genotypeAllele)
        return false;

    switch (this->type) {
        case ALLELE_GENOTYPE:
            return false;
            break;
        case ALLELE_REFERENCE:
            return indelMask.at(referenceOffset());
            break;
        case ALLELE_SNP:
            return indelMask.at(0);
            break;
        case ALLELE_INSERTION: // XXX presently these are masked by default...
        case ALLELE_DELETION:
        case ALLELE_MNP:
        case ALLELE_COMPLEX:
        case ALLELE_NULL:
            return true;
            break;
        default:
            break;
    }

}
Ejemplo n.º 5
0
// quality at a given reference position
const short Allele::currentQuality(void) const {
    switch (this->type) {
        case ALLELE_REFERENCE:
            assert(alternateSequence.size() == baseQualities.size());
            assert(referenceOffset() >= 0);
            TRY {
                return baseQualities.at(referenceOffset());
            } CATCH;
            break;
        case ALLELE_INSERTION:
        case ALLELE_DELETION:
        case ALLELE_SNP:
        case ALLELE_MNP:
        case ALLELE_COMPLEX:
            return quality;
            break;
    }
}