bool FilterCriteria::Satisfy(const PacBio::BAM::BamRecord& record) const
{
    assert(record.IsMapped() and record.Impl().HasTag(AS));
    DNALength alnLength = static_cast<DNALength>(
        record.Sequence(PacBio::BAM::Orientation::NATIVE, true, true).size());
    PacBio::BAM::Cigar cigar = record.CigarData();

    uint32_t nMatch = 0, nMismatch = 0, nIns = 0, nDel = 0;
    for (auto op : cigar) {
        uint32_t n = op.Length();
        switch (op.Type()) {
            case PacBio::BAM::CigarOperationType::SEQUENCE_MATCH:
                nMatch += n;
                break;
            case PacBio::BAM::CigarOperationType::SEQUENCE_MISMATCH:
                nMismatch += n;
                break;
            case PacBio::BAM::CigarOperationType::ALIGNMENT_MATCH:
                nMismatch += n;
                break;
            case PacBio::BAM::CigarOperationType::INSERTION:
                nIns += n;
                break;
            case PacBio::BAM::CigarOperationType::DELETION:
                nDel += n;
                break;
            default:
                break;
        }
    }
    //TODO: Use = X instead of M in blasr.

    float pctSimilarity = 100 * nMatch / static_cast<float>(alnLength);
    float pctAccuracy = 100 * nMatch / static_cast<float>(nMismatch + nMatch + nIns + nDel);
    Score s(static_cast<float>(record.Impl().TagValue("AS").ToInt32()), ScoreSign::NEGATIVE);
    return Satisfy(alnLength, pctSimilarity, pctAccuracy, s);
}
Esempio n. 2
0
void FASTASequence::Copy(const PacBio::BAM::BamRecord & record) {
    FASTASequence::Copy(record.Impl().Name(), record.Sequence());
}