Example #1
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;
}
Example #2
0
// combines the two alleles into a complex variant, updates important data
void Allele::mergeAllele(const Allele& newAllele, AlleleType newType) {
    //cout << stringForAllele(*this) << endl << stringForAllele(newAllele) << endl;
    type = newType;
    alternateSequence += newAllele.alternateSequence;
    length += newAllele.length; // hmmm
    basesRight = newAllele.basesRight;
    baseQualities.insert(baseQualities.end(), newAllele.baseQualities.begin(), newAllele.baseQualities.end());
    currentBase = base();
    // XXX note that we don't add Q values for intermingled gaps in combined alleles
    if (newAllele.type != ALLELE_REFERENCE) {
        quality = min(newAllele.quality, quality);
        lnquality = max(newAllele.lnquality, lnquality);
        //quality = minQuality(baseQualities);
        //lnquality = log(quality);
    } else {
        quality = averageQuality(baseQualities);
        lnquality = log(quality);
        basesRight += newAllele.referenceLength;
    }
    if (newAllele.type != ALLELE_REFERENCE) {
        repeatRightBoundary = newAllele.repeatRightBoundary;
    }
    cigar = mergeCigar(cigar, newAllele.cigar);
    referenceLength = referenceLengthFromCigar();
    //cout << stringForAllele(*this) << endl << endl;
}
Example #3
0
// combines the two alleles into a complex variant, updates important data
void Allele::mergeAllele(const Allele& newAllele, AlleleType newType) {
    //cerr << stringForAllele(*this) << endl << stringForAllele(newAllele) << endl;
    type = newType;
    alternateSequence += newAllele.alternateSequence;
    length += newAllele.length; // hmmm
    basesRight = newAllele.basesRight;
    baseQualities.insert(baseQualities.end(), newAllele.baseQualities.begin(), newAllele.baseQualities.end());
    currentBase = base();
    quality = averageQuality(baseQualities);
    lnquality = phred2ln(quality);
    basesRight += newAllele.referenceLength;
    if (newAllele.type != ALLELE_REFERENCE) {
        repeatRightBoundary = newAllele.repeatRightBoundary;
    }
    cigar = mergeCigar(cigar, newAllele.cigar);
    referenceLength = referenceLengthFromCigar();
}