示例#1
0
bool HitPolicy::compareByScoreTStart(const PacBio::BAM::BamRecord & a, const PacBio::BAM::BamRecord & b) const {
    assert(a.Impl().HasTag(AS) and b.Impl().HasTag(AS));
    assert(a.FullName() == b.FullName());
    const int aScore = a.Impl().TagValue(AS).ToInt32();
    const int bScore = b.Impl().TagValue(AS).ToInt32();
    if (aScore == bScore)
        return a.ReferenceStart() < b.ReferenceEnd();
    return Score(aScore, _sign).WorseThan(Score(bScore, _sign));
}
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);
}
示例#3
0
void FASTASequence::Copy(const PacBio::BAM::BamRecord & record) {
    FASTASequence::Copy(record.Impl().Name(), record.Sequence());
}