⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 seq_loc.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        return;    }    switch ( Which() ) {        case CSeq_loc::e_Int:            SetInt().SetPartialRight(val);        case CSeq_loc::e_Pnt:            SetPnt().SetPartialRight(val);        case CSeq_loc::e_Mix:            SetMix().SetPartialRight(val);        default :            break;    }}// Appends a label suitable for display (e.g., error messages)// label must point to an existing string object// Method just returns if label is nullvoid CSeq_loc::GetLabel(string* label) const{    s_GetLabel(*this, 0, label, true);}// assign the 'id' field of each sub-interval to the supplied idvoid CSeq_loc::SetId(CSeq_id& id){    x_InvalidateCache();    switch (Which()) {    case e_Int:        SetInt().SetId(id);        break;    case e_Pnt:        SetPnt().SetId(id);        break;    case e_Packed_int:        NON_CONST_ITERATE (CPacked_seqint::Tdata, iter, SetPacked_int().Set()) {            (*iter)->SetId(id);        }        break;    case e_Packed_pnt:        SetPacked_pnt().SetId(id);        break;    case e_Mix:        NON_CONST_ITERATE (CSeq_loc_mix::Tdata, iter, SetMix().Set()) {            (*iter)->SetId(id);        }        break;    case e_Whole:        SetWhole(id);        break;    case e_Empty:        SetEmpty(id);        break;    case e_Equiv:        NON_CONST_ITERATE (CSeq_loc_equiv::Tdata, iter, SetEquiv().Set()) {            (*iter)->SetId(id);        }        break;    case e_Bond:        if (GetBond().IsSetA()) {            SetBond().SetA().SetId(id);        }        if (GetBond().IsSetB()) {            SetBond().SetB().SetId(id);        }        break;    case e_Feat:        LOG_POST(Error << "unhandled loc type in CSeq_loc::SetId(): e_Feat");        break;    default:        LOG_POST(Error << "unhandled loc type in CSeq_loc::SetId(): "                 << Which());        break;    }}bool CSeq_loc::Equals(const CSerialObject& object, ESerialRecursionMode how) const{    if ( typeid(object) != typeid(*this) ) {        ERR_POST(Fatal <<            "CSeq_loc::Assign() -- Assignment of incompatible types: " <<            typeid(*this).name() << " = " << typeid(object).name());    }    return CSerialObject::Equals(object, how);}void CSeq_loc::x_CheckId(const CSeq_id*& id) const{    switch ( Which() ) {    case CSeq_loc::e_not_set:    case CSeq_loc::e_Null:        {            x_UpdateId(id, 0);            break;        }    case CSeq_loc::e_Empty:        {            x_UpdateId(id, &GetEmpty());            break;        }    case CSeq_loc::e_Whole:        {            x_UpdateId(id, &GetWhole());            break;        }    case CSeq_loc::e_Int:        {            const CSeq_interval& loc = GetInt();            x_UpdateId(id, &loc.GetId());            break;        }    case CSeq_loc::e_Pnt:        {            const CSeq_point& pnt = GetPnt();            x_UpdateId(id, &pnt.GetId());            break;        }    case CSeq_loc::e_Packed_int:        {            // Check ID of each interval            const CPacked_seqint& ints = GetPacked_int();            ITERATE ( CPacked_seqint::Tdata, ii, ints.Get() ) {                const CSeq_interval& loc = **ii;                x_UpdateId(id, &loc.GetId());            }            break;        }    case CSeq_loc::e_Packed_pnt:        {            const CPacked_seqpnt& pnts = GetPacked_pnt();            x_UpdateId(id, &pnts.GetId());            break;        }    case CSeq_loc::e_Mix:        {            // Check ID of each sub-location.            const CSeq_loc_mix& mix = GetMix();            ITERATE( CSeq_loc_mix::Tdata, li, mix.Get() ) {                (*li)->CheckId(id);            }            break;        }    case CSeq_loc::e_Bond:        {            const CSeq_bond& bond = GetBond();            if ( bond.CanGetA() ) {                x_UpdateId(id, &bond.GetA().GetId());            }            if ( bond.CanGetB() ) {                x_UpdateId(id, &bond.GetB().GetId());            }            break;        }            case CSeq_loc::e_Equiv:        {            // Doesn't make much sense to test equiv, but ...            ITERATE(CSeq_loc_equiv::Tdata, li, GetEquiv().Get()) {                (*li)->CheckId(id);            }            break;        }    case CSeq_loc::e_Feat:    default:        {            NCBI_THROW(CException, eUnknown,                       "CSeq_loc::CheckId -- "                       "unsupported location type");        }    }}void CSeq_loc::x_ChangeToMix(const CSeq_loc& other){    CRef<CSeq_loc> self(new CSeq_loc);    self->Assign(*this);    CSeq_loc_mix& mix = SetMix();    mix.AddSeqLoc(*self);    mix.AddSeqLoc(other);}void CSeq_loc::x_ChangeToPackedInt(const CSeq_loc& other){    _ASSERT(IsInt());    _ASSERT(other.IsInt()  ||  other.IsPacked_int());        CConstRef<CSeq_interval> self(&GetInt());    SetPacked_int().AddInterval(*self);    if ( other.IsInt() ) {        SetPacked_int().AddInterval(other.GetInt());    } else {  // other is packed int        SetPacked_int().AddIntervals(other.GetPacked_int());    }}void CSeq_loc::x_ChangeToPackedPnt(const CSeq_loc& other){    _ASSERT(IsPnt());    _ASSERT(other.IsPnt()  ||  other.IsPacked_pnt());    CRef<CSeq_point> pnt(&SetPnt());    CPacked_seqpnt& ppnt = SetPacked_pnt();    if ( pnt->IsSetStrand() ) {        ppnt.SetStrand(pnt->GetStrand());    }    if ( pnt->IsSetId() ) {        ppnt.SetId(pnt->SetId());    }    if ( pnt->IsSetFuzz() ) {        ppnt.SetFuzz(pnt->SetFuzz());    }    ppnt.AddPoint(pnt->GetPoint());    if ( other.IsPnt() ) {        ppnt.AddPoint(other.GetPnt().GetPoint());    } else { // other is packed point        ppnt.AddPoints(other.GetPacked_pnt().GetPoints());    }}template<typename T1, typename T2>bool s_CanAdd(const T1& obj1, const T2& obj2){    // test strands    {{        ENa_strand s1 = obj1.CanGetStrand() ? obj1.GetStrand() : eNa_strand_unknown;        ENa_strand s2 = obj2.CanGetStrand() ? obj2.GetStrand() : eNa_strand_unknown;        if ( s1 != s2 ) {            return false;        }    }}    // test ids    {{        const CSeq_id* id1 = obj1.CanGetId() ? &obj1.GetId() : 0;        const CSeq_id* id2 = obj2.CanGetId() ? &obj2.GetId() : 0;        if ( ((id1 != id2)  &&  (id1 == 0  ||  id2 == 0))  ||             !id1->Match(*id2) ) {            return false;        }    }}    // test fuzz    {{        const CInt_fuzz* f1 = obj1.CanGetFuzz() ? &obj1.GetFuzz() : 0;        const CInt_fuzz* f2 = obj2.CanGetFuzz() ? &obj2.GetFuzz() : 0;        if ( ((f1 != f2)  &&  (f1 == 0  ||  f2 == 0))  ||             !f1->Equals(*f2) ) {            return false;        }    }}    return true;}bool s_CanAdd(const CSeq_loc& loc1, const CSeq_loc& loc2){    switch ( loc1.Which() ) {    case CSeq_loc::e_Pnt:        {            switch ( loc2.Which() ) {            case CSeq_loc::e_Pnt:                return s_CanAdd(loc1.GetPnt(), loc2.GetPnt());            case CSeq_loc::e_Packed_pnt:                return s_CanAdd(loc1.GetPnt(), loc2.GetPacked_pnt());            }            break;        }    case CSeq_loc::e_Packed_pnt:        {            switch ( loc2.Which() ) {            case CSeq_loc::e_Pnt:                return s_CanAdd(loc1.GetPacked_pnt(), loc2.GetPnt());            case CSeq_loc::e_Packed_pnt:                return s_CanAdd(loc1.GetPacked_pnt(), loc2.GetPacked_pnt());            }            break;        }    default:        {            return false;        }    }    return false;}void CSeq_loc::Add(const CSeq_loc& other){    x_InvalidateCache();    switch ( Which() ) {    case CSeq_loc::e_not_set:        {            Assign(other);            break;        }    case CSeq_loc::e_Null:        {            // ??? skip if other is null?            x_ChangeToMix(other);            break;        }    case CSeq_loc::e_Empty:        {            // ??? skip if other is empty and ids match?            x_ChangeToMix(other);            break;        }        break;    case CSeq_loc::e_Whole:        {            x_ChangeToMix(other);            break;        }    case CSeq_loc::e_Int:        {            if ( other.IsInt()  ||  other.IsPacked_int() ) {                x_ChangeToPackedInt(other);            } else {                x_ChangeToMix(other);            }        }        break;    case CSeq_loc::e_Pnt:        {            if ( s_CanAdd(*this, other) ) {                x_ChangeToPackedPnt(other);            } else {                x_ChangeToMix(other);            }            break;        }    case CSeq_loc::e_Packed_int:        {            if ( other.IsInt() ) {                SetPacked_int().AddInterval(other.GetInt());            } else if ( other.IsPacked_int() ) {                SetPacked_int().AddIntervals(other.GetPacked_int());            } else {                x_ChangeToMix(other);            }            break;        }    case CSeq_loc::e_Packed_pnt:        {            if ( s_CanAdd(*this, other) ) {                if ( other.IsPnt() ) {                    SetPacked_pnt().AddPoint(other.GetPnt().GetPoint());                } else if ( other.IsPacked_pnt() ) {                    SetPacked_pnt().AddPoints(other.GetPacked_pnt().GetPoints());                }            } else {                x_ChangeToMix(other);            }            break;        }    case CSeq_loc::e_Mix:        {            SetMix().AddSeqLoc(other);            break;        }    case CSeq_loc::e_Equiv:        {            SetEquiv().Add(other);            break;        }    case CSeq_loc::e_Bond:        {            x_ChangeToMix(other);            break;        }    case CSeq_loc::e_Feat:    default:        {            NCBI_THROW(CException, eUnknown,                       "CSeq_loc::Add -- "                       "unsupported location type");        }    }}END_objects_SCOPE // namespace ncbi::objects::END_NCBI_SCOPE/* * ============================================================================= * $Log: Seq_loc.cpp,v $ * Revision 1000.3  2004/06/01 19:34:35  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R6.42 * * Revision 6.42  2004/05/19 17:26:25  gorelenk * Added include of PCH - ncbi_pch.hpp * * Revision 6.41  2004/05/07 12:51:13  shomrat * Removed return from function returning void * * Revision 6.40  2004/05/06 16:55:00  shomrat * Added methods to set partial left and right * * Revision 6.39  2004/03/25 15:59:06  gouriano * Added possibility to copy and compare serial object non-recursively * * Revision 6.38  2004/01/29 19:58:52  shomrat * Adding missing cache invalidation * * Revision 6.37  2004/01/28 17:18:11  shomrat * Added methods to ease the construction of objects * * Revision 6.36  2003/11/21 14:45:05  grichenk * Replaced runtime_error with CException * * Revision 6.35  2003/10/15 15:50:36  ucko * CSeq_loc_CI: expose fuzz (if present). * * Revision 6.34  2003/10/14 16:48:53  dicuccio * Added SetId() function.  Added correct printing of packed seq-points in * Getlabel() * * Revision 6.33  2003/09/22 18:38:14  grichenk * Fixed circular seq-locs processing by TestForOverlap() * * Revision 6.32  2003/09/17 18:39:01  grichenk * + GetStart(), GetEnd(), GetCircularLength() * * Revision 6.31  2003/07/21 15:32:11  vasilche * Fixed access to uninitialized member. * * Revision 6.30  2003/06/18 16:00:07  vasilche * Fixed GetTotalRange() in multithreaded app. * * Revision 6.29  2003/06/13 17:21:20  grichenk * Added seq-id caching for single-id seq-locs * * Revision 6.28  2003/04/02 15:17:47  grichenk * Added flag for CSeq_loc_CI to skip/include empty locations. * * Revision 6.27  2003/03/11 15:55:44  kuznets * iterate -> ITERATE * * Revision 6.26  2003/02/24 18:52:13  vasilche * Added clearing of old data in assign. * * Revision 6.25  2003/02/06 22:23:29  vasilche * Added CSeq_id::Assign(), CSeq_loc::Assign(). * Added int CSeq_id::Compare() (not safe). * Added caching of CSeq_loc::GetTotalRange(). * * Revision 6.24  2003/02/04 15:15:15  grichenk * Overrided Assign() for CSeq_loc and CSeq_id * * Revision 6.23  2003/01/24 20:11:33  vasilche * Fixed trigraph warning on GCC. * * Revision 6.22  2003/01/22 20:17:33  vasilche * Optimized CSeq_loc::GetTotalRange(). * * Revision 6.21  2002/12/30 19:37:02  vasilche * Rewrote CSeq_loc::GetTotalRange() to avoid using CSeq_loc_CI - * it's too expensive. * * Revision 6.20  2002/12/23 17:19:27  grichenk * Added GetSeq_loc() to CSeq_loc_CI * * Revision 6.19  2002/12/19 20:24:54  grichenk * Updated usage of CRange<> * * Revision 6.18  2002/12/06 15:36:04  grichenk * Added overlap type for annot-iterators * * Revision 6.17  2002/10/03 20:22:50  ucko * Drop duplicate default arg. spec. for s_GetLabel. * * Revision 6.16  2002/10/03 18:53:03  clausen * Removed extra whitespace * * Revision 6.15  2002/10/03 16:36:09  clausen * Added GetLabel() * * Revision 6.14  2002/09/12 21:19:02  kans * added IsPartialLeft and IsPartialRight * * Revision 6.13  2002/06/06 20:35:28  clausen * Moved methods using object manager to objects/util * * Revision 6.12  2002/05/31 13:33:02  grichenk * GetLength() -- return 0 for e_Null locations * * Revision 6.11  2002/05/06 03:39:12  vakatov * OM/OM1 renaming * * Revision 6.10  2002/05/03 21:28:18  ucko * Introduce T(Signed)SeqPos. * * Revision 6.9  2002/04/22 20:08:31  grichenk * Redesigned GetTotalRange() using CSeq_loc_CI * * Revision 6.8  2002/04/17 15:39:08  grichenk * Moved CSeq_loc_CI to the seq-loc library * * Revision 6.7  2002/01/16 18:56:32  grichenk * Removed CRef<> argument from choice variant setter, updated sources to * use references instead of CRef<>s * * Revision 6.6  2002/01/10 18:21:26  clausen * Added IsOneBioseq, GetStart, and GetId * * Revision 6.5  2001/10/22 11:40:32  clausen * Added Compare() implementation * * Revision 6.4  2001/01/03 18:59:09  vasilche * Added missing include. * * Revision 6.3  2001/01/03 16:39:05  vasilche * Added CAbstractObjectManager - stub for object manager. * CRange extracted to separate file. * * Revision 6.2  2000/12/26 17:28:55  vasilche * Simplified and formatted code. * * Revision 6.1  2000/11/17 21:35:10  vasilche * Added GetLength() method to CSeq_loc class. * * * ===========================================================================*/

⌨️ 快捷键说明

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