seq_map.cpp

来自「ncbi源码」· C++ 代码 · 共 1,029 行 · 第 1/3 页

CPP
1,029
字号
}bool CSeqMap::x_GetRefMinusStrand(const CSegment& seg) const{    return seg.m_RefMinusStrand;}CSeqMap::TSegment_CI CSeqMap::Begin(CScope* scope) const{    return TSegment_CI(CConstRef<CSeqMap>(this), scope, 0);}CSeqMap::TSegment_CI CSeqMap::End(CScope* scope) const{    return TSegment_CI(CConstRef<CSeqMap>(this), scope, GetLength(scope));}CSeqMap::TSegment_CI CSeqMap::FindSegment(TSeqPos pos, CScope* scope) const{    return TSegment_CI(CConstRef<CSeqMap>(this), scope, pos);}CSeqMap::const_iterator CSeqMap::begin(CScope* scope) const{    return Begin(scope);}CSeqMap::const_iterator CSeqMap::end(CScope* scope) const{    return End(scope);}CSeqMap::const_iterator CSeqMap::find(TSeqPos pos, CScope* scope) const{    return FindSegment(pos, scope);}CSeqMap::TSegment_CI CSeqMap::BeginResolved(CScope* scope, size_t maxResolveCount,                                            TFlags flags) const{    return begin_resolved(scope, maxResolveCount, flags);}CSeqMap::TSegment_CI CSeqMap::EndResolved(CScope* scope, size_t maxResolveCount,                                          TFlags flags) const{    return end_resolved(scope, maxResolveCount, flags);}CSeqMap::TSegment_CI CSeqMap::FindResolved(TSeqPos pos, CScope* scope,                                           size_t maxResolveCount,                                           TFlags flags) const{    return find_resolved(pos, scope, maxResolveCount, flags);}CSeqMap::TSegment_CI CSeqMap::FindResolved(TSeqPos pos, CScope* scope,                                           ENa_strand strand,                                           size_t maxResolveCount,                                           TFlags flags) const{    return find_resolved(pos, scope, strand, maxResolveCount, flags);}CSeqMap::const_iterator CSeqMap::begin_resolved(CScope* scope,                                                size_t maxResolveCount,                                                TFlags flags) const{    return TSegment_CI(CConstRef<CSeqMap>(this), scope, 0,                       maxResolveCount, flags);}CSeqMap::const_iterator CSeqMap::end_resolved(CScope* scope,                                              size_t maxResolveCount,                                              TFlags flags) const{    return TSegment_CI(CConstRef<CSeqMap>(this), scope,                       GetLength(scope),                       maxResolveCount, flags);}CSeqMap::const_iterator CSeqMap::find_resolved(TSeqPos pos, CScope* scope,                                               size_t maxResolveCount,                                               TFlags flags) const{    return TSegment_CI(CConstRef<CSeqMap>(this), scope, pos,                       maxResolveCount, flags);}CSeqMap::const_iterator CSeqMap::find_resolved(TSeqPos pos, CScope* scope,                                               ENa_strand strand,                                               size_t maxResolveCount,                                               TFlags flags) const{    return TSegment_CI(CConstRef<CSeqMap>(this), scope,                       pos, strand,                       maxResolveCount, flags);}CSeqMap::TSegment_CICSeqMap::ResolvedRangeIterator(CScope* scope,                               ENa_strand strand,                               TSeqPos from,                               TSeqPos length,                               size_t maxResolveCount,                               TFlags flags) const{    if ( IsReverse(strand) ) {        from = GetLength(scope) - from - length;    }    return TSegment_CI(CConstRef<CSeqMap>(this), scope,                       SSeqMapSelector()                       .SetRange(from, length)                       .SetResolveCount(maxResolveCount)                       .SetFlags(flags),                       strand);}CSeqMap::TSegment_CICSeqMap::ResolvedRangeIterator(CScope* scope,                               TSeqPos from,                               TSeqPos length,                               ENa_strand strand,                               size_t maxResolveCount,                               TFlags flags) const{    return TSegment_CI(CConstRef<CSeqMap>(this), scope,                       SSeqMapSelector()                       .SetRange(from, length)                       .SetResolveCount(maxResolveCount)                       .SetFlags(flags),                       strand);}bool CSeqMap::CanResolveRange(CScope* scope,                              TSeqPos from,                              TSeqPos length,                              ENa_strand strand) const{    try {        TSegment_CI seg(CConstRef<CSeqMap>(this), scope,                        SSeqMapSelector()                        .SetRange(from, length)                        .SetResolveCount(size_t(-1))                        .SetFlags(fDefaultFlags),                        strand);        for ( ; seg; ++seg);    }    catch (exception) {        return false;    }    return true;}void CSeqMap::DebugDump(CDebugDumpContext /*ddc*/,                        unsigned int /*depth*/) const{#if 0    ddc.SetFrame("CSeqMap");    CObject::DebugDump( ddc, depth);    DebugDumpValue(ddc, "m_FirstUnresolvedPos", m_FirstUnresolvedPos);    if (depth == 0) {        DebugDumpValue(ddc, "m_Data.size()", m_Data.size());    } else {        DebugDumpValue(ddc, "m_Data.type",            "vector<CRef<CSegment>>");        DebugDumpRangeCRef(ddc, "m_Data",            m_Data.begin(), m_Data.end(), depth);    }#endif}CConstRef<CSeqMap> CSeqMap::CreateSeqMapForBioseq(const CBioseq& seq){    CConstRef<CSeqMap> ret;    const CSeq_inst& inst = seq.GetInst();    if ( inst.IsSetSeq_data() ) {        ret.Reset(new CSeqMap(inst.GetSeq_data(),                              inst.GetLength()));    }    else if ( inst.IsSetExt() ) {        const CSeq_ext& ext = inst.GetExt();        switch (ext.Which()) {        case CSeq_ext::e_Seg:            ret.Reset(new CSeqMap_Seq_locs(ext.GetSeg(),                                           ext.GetSeg().Get()));            break;        case CSeq_ext::e_Ref:            ret.Reset(new CSeqMap(ext.GetRef()));            break;        case CSeq_ext::e_Delta:            ret.Reset(new CSeqMap_Delta_seqs(ext.GetDelta()));            break;        case CSeq_ext::e_Map:            //### Not implemented            NCBI_THROW(CSeqMapException, eUnimplemented,                       "CSeq_ext::e_Map -- not implemented");        default:            //### Not implemented            NCBI_THROW(CSeqMapException, eUnimplemented,                       "CSeq_ext::??? -- not implemented");        }    }    else if ( inst.GetRepr() == CSeq_inst::eRepr_virtual ) {        // Virtual sequence -- no data, no segments        // The total sequence is gap        ret.Reset(new CSeqMap(inst.GetLength()));    }    else {        if ( inst.GetRepr() != CSeq_inst::eRepr_not_set ) {            NCBI_THROW(CSeqMapException, eDataError,                       "CSeq_inst.repr of sequence without data "                       "should be not_set");        }        if ( inst.IsSetLength() && inst.GetLength() != 0 ) {            NCBI_THROW(CSeqMapException, eDataError,                       "CSeq_inst.length of sequence without data "                       "should be 0");        }        ret.Reset(new CSeqMap(TSeqPos(0)));    }    const_cast<CSeqMap&>(*ret).m_Mol = inst.GetMol();    if ( inst.IsSetLength() ) {        const_cast<CSeqMap&>(*ret).m_SeqLength = inst.GetLength();    }    return ret;}CConstRef<CSeqMap> CSeqMap::CreateSeqMapForSeq_loc(const CSeq_loc& loc,                                                   CScope* scope){    CConstRef<CSeqMap> ret(new CSeqMap(loc));    if ( scope ) {        CSeqMap::const_iterator i(            ret->BeginResolved(scope, size_t(-1), fFindData));        for ( ; i; ++i ) {            _ASSERT(i.GetType() == eSeqData);            switch ( i.GetRefData().Which() ) {            case CSeq_data::e_Ncbi2na:            case CSeq_data::e_Ncbi4na:            case CSeq_data::e_Ncbi8na:            case CSeq_data::e_Ncbipna:            case CSeq_data::e_Iupacna:                const_cast<CSeqMap&>(*ret).m_Mol = CSeq_inst::eMol_na;                break;            case CSeq_data::e_Ncbi8aa:            case CSeq_data::e_Ncbieaa:            case CSeq_data::e_Ncbipaa:            case CSeq_data::e_Ncbistdaa:            case CSeq_data::e_Iupacaa:                const_cast<CSeqMap&>(*ret).m_Mol = CSeq_inst::eMol_aa;                break;            default:                const_cast<CSeqMap&>(*ret).m_Mol = CSeq_inst::eMol_not_set;            }        }    }    return ret;}CConstRef<CSeqMap> CSeqMap::CreateSeqMapForStrand(CConstRef<CSeqMap> seqMap,                                                  ENa_strand strand){    if ( IsReverse(strand) ) {        CRef<CSeqMap> ret(new CSeqMap());        ret->x_AddEnd();        ret->x_AddSegment(eSeqSubMap,                          const_cast<CSeqMap*>(seqMap.GetPointer()),                          0, kInvalidSeqPos, strand);        ret->x_AddEnd();        ret->m_Mol = seqMap->m_Mol;        ret->m_SeqLength = seqMap->m_SeqLength;        seqMap = ret;    }    return seqMap;}CSeqMap::CSegment& CSeqMap::x_AddSegment(ESegmentType type, TSeqPos len){    m_Segments.push_back(CSegment(type, len));    return m_Segments.back();}CSeqMap::CSegment& CSeqMap::x_AddSegment(ESegmentType type, TSeqPos len,                                         const CObject* object){    CSegment& ret = x_AddSegment(type, len);    ret.m_RefObject.Reset(object);    return ret;}CSeqMap::CSegment& CSeqMap::x_AddSegment(ESegmentType type,                                         const CObject* object,                                         TSeqPos refPos,                                         TSeqPos len,                                         ENa_strand strand){    CSegment& ret = x_AddSegment(type, len, object);    ret.m_RefPosition = refPos;    ret.m_RefMinusStrand = IsReverse(strand);    return ret;}void CSeqMap::x_AddEnd(void){    TSeqPos pos = m_Segments.empty()? 0: kInvalidSeqPos;    x_AddSegment(eSeqEnd, 0).m_Position = pos;}CSeqMap::CSegment& CSeqMap::x_AddGap(TSeqPos len){    return x_AddSegment(eSeqGap, len);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?