Beispiel #1
0
bool CBioseq_Handle::ContainsSegment(CSeq_id_Handle id,
                                     size_t resolve_depth,
                                     EFindSegment limit_flag) const
{
    CBioseq_Handle h = GetScope().GetBioseqHandle(id);
    CConstRef<CSynonymsSet> syns;
    if ( h ) {
        syns = h.GetSynonyms();
    }
    SSeqMapSelector sel;
    sel.SetFlags(CSeqMap::fFindRef);
    if ( limit_flag == eFindSegment_LimitTSE ) {
        sel.SetLimitTSE(GetTopLevelEntry());
    }
    sel.SetResolveCount(resolve_depth);
    CSeqMap_CI it = GetSeqMap().BeginResolved(&GetScope(), sel);
    for ( ; it; ++it) {
        if ( syns ) {
            if ( syns->ContainsSynonym(it.GetRefSeqid()) ) {
                return true;
            }
        }
        else {
            if (it.GetRefSeqid() == id) {
                return true;
            }
        }
    }
    return false;
}
Beispiel #2
0
void CGapAnalysis::AddBioseqGaps(
    const CBioseq_Handle & bioseq_h,
    TAddFlag add_flags,
    TFlag fFlags,
    size_t max_resolve_count)
{
    // get CSeq_id of CBioseq
    TSeqIdConstRef pSeqId = bioseq_h.GetSeqId();
    const TSeqPos bioseq_len = bioseq_h.GetBioseqLength();

    // fFlags control  what we look at
    CSeqMap::TFlags seq_map_flags = 0;
    if( add_flags & fAddFlag_IncludeSeqGaps ) {
        seq_map_flags |= CSeqMap::fFindGap;
    }
    if( add_flags & fAddFlag_IncludeUnknownBases ) {
        seq_map_flags |= CSeqMap::fFindData;
    }

    TSeqPos end_of_last_segment = 0;  // exclusive
    bool all_segments_and_in_order = true;

    SSeqMapSelector selector;
    selector.SetFlags(seq_map_flags).SetResolveCount(max_resolve_count);
    CSeqMap_CI seqmap_ci(bioseq_h, selector);
    for( ; seqmap_ci; ++seqmap_ci ) {
        if( seqmap_ci.GetPosition() != end_of_last_segment ) {
            all_segments_and_in_order = false;
        }
        end_of_last_segment = seqmap_ci.GetEndPosition();

        CSeqMap::ESegmentType seg_type = seqmap_ci.GetType();
        switch(seg_type) {
        case CSeqMap::eSeqGap:
            _ASSERT(add_flags & fAddFlag_IncludeSeqGaps);
            AddGap(
                eGapType_SeqGap, pSeqId,
                seqmap_ci.GetLength(),
                bioseq_len,
                seqmap_ci.GetPosition(), seqmap_ci.GetEndPosition(),
                fFlags);
            break;
        case CSeqMap::eSeqData:
            _ASSERT(add_flags & fAddFlag_IncludeUnknownBases);
            x_AddGapsFromBases(
                seqmap_ci, pSeqId,
                bioseq_len, fFlags);
            break;
        default:
            NCBI_USER_THROW_FMT(
                "This segment type is not supported at this time: " <<
                static_cast<int>(seg_type) );
        }
    }

    if( end_of_last_segment != bioseq_len ) {
        all_segments_and_in_order = false;
    }
    if( ! all_segments_and_in_order ) {
        ERR_POST(
            Warning << "Not all segments on bioseq '"
            << pSeqId->AsFastaString() << "' were in order "
            "or some positions appear to have been skipped.  "
            "One possible reason is that there were far references for "
            "which no attempt was made to resolve due to max resolve count "
            "being reached.");
    }
}