src/c++/lib/variant/Variant.cpp
/**
 * Add observation for RefVar allele from a read.
 *
 * @param rv the allele
 * @param is_rev true if observation is on reverse strand
 * @param left_boundary position of preceding variant to the left (if any)
 * @param pqual phred-scaled base quality for rv
 * @return the rightmost position this RefVar could be placed
 */
Add observation for RefVar allele from a read.
Add observation for RefVar allele from a read .
int64_t VariantCandidateList::addRefVarObservation(RefVar rv, bool is_rev, int64_t left_boundary, int pqual)
{
    if (rv.end >= rv.start && rv.alt == ".")
    {
        for (auto pos = (size_t)rv.start; pos < std::min(_impl->reference.size(), (const unsigned long)rv.end + 1);
             ++pos)
        {
            _impl->reference_pileups[pos].addObs(is_rev, pqual);
        }
        return rv.end;
    }
    int64_t rightmost = std::max(rv.start, rv.end);
    if (rv.alt != ".")
    {
        variant::rightShift(_impl->reference, rv);
        rightmost = std::max(rv.start, rv.end);
        variant::leftShift(_impl->reference, rv, left_boundary);
        variant::trimLeft(_impl->reference.substr(rv.start, rv.end - rv.start + 1), rv, false);
        for (auto pos = (size_t)rv.start; pos < std::min(_impl->reference.size(), (size_t)rightmost + 1); ++pos)
        {
            _impl->nonreference_pileups[pos].addObs(is_rev, pqual);
        }
        const std::string key = rv.repr();
        auto var_it = _impl->variants.find(key);
        if (var_it == _impl->variants.end())
        {
            var_it = _impl->variants.emplace(key, std::unique_ptr<Variant>(new Variant())).first;
            var_it->second->set_start((int)rv.start);
            var_it->second->set_end((int)rv.end);
            var_it->second->set_alt(rv.alt);
            var_it->second->set_leftmost((int)rv.start);
            var_it->second->set_rightmost((int)rightmost);
        }
        auto pileup_it = _impl->variant_pileups.find(key);
        if (pileup_it == _impl->variant_pileups.end())
        {
            pileup_it = _impl->variant_pileups.emplace(key, PileupData()).first;
        }
        pileup_it->second.addObs(is_rev, pqual);
    }
    return rightmost;
}
int64_t VariantCandidateList :: addRefVarObservation ( RefVar rv , bool is_rev , int64_t left_boundary , int pqual ) { if ( rv . end >= rv . start && rv . alt == " " ) { for ( auto pos = ( size_t ) rv . start ; pos < std :: min ( _impl -> reference . size ( ) , ( const unsigned long ) rv . end + 1 ) ; ++ pos ) { _impl -> reference_pileups [ pos ] . addObs ( is_rev , pqual ) ; } return rv . end ; } int64_t rightmost = std :: max ( rv . start , rv . end ) ; if ( rv . alt != " " ) { variant :: rightShift ( _impl -> reference , rv ) ; rightmost = std :: max ( rv . start , rv . end ) ; variant :: leftShift ( _impl -> reference , rv , left_boundary ) ; variant :: trimLeft ( _impl -> reference . substr ( rv . start , rv . end - rv . start + 1 ) , rv , false ) ; for ( auto pos = ( size_t ) rv . start ; pos < std :: min ( _impl -> reference . size ( ) , ( size_t ) rightmost + 1 ) ; ++ pos ) { _impl -> nonreference_pileups [ pos ] . addObs ( is_rev , pqual ) ; } const std :: string key = rv . repr ( ) ; auto var_it = _impl -> variants . find ( key ) ; if ( var_it == _impl -> variants . end ( ) ) { var_it = _impl -> variants . emplace ( key , std :: unique_ptr < Variant > ( new Variant ( ) ) ) . first ; var_it -> second -> set_start ( ( int ) rv . start ) ; var_it -> second -> set_end ( ( int ) rv . end ) ; var_it -> second -> set_alt ( rv . alt ) ; var_it -> second -> set_leftmost ( ( int ) rv . start ) ; var_it -> second -> set_rightmost ( ( int ) rightmost ) ; } auto pileup_it = _impl -> variant_pileups . find ( key ) ; if ( pileup_it == _impl -> variant_pileups . end ( ) ) { pileup_it = _impl -> variant_pileups . emplace ( key , PileupData ( ) ) . first ; } pileup_it -> second . addObs ( is_rev , pqual ) ; } return rightmost ; }
Add observation for RefVar allele from a read.
Add observation for RefVar allele from a read .
// update reference information -- "." indicates reference support for entire span of RefVar // add as non-ref obs // add to canonical variant pileup