seq_loc_cvt.cpp

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

CPP
970
字号
        break;    }    case CSeq_loc::e_Empty:    {        TRangeIterator mit = BeginRanges(CSeq_id_Handle::GetHandle(src.GetEmpty()),                                         TRange::GetWhole().GetFrom(),                                         TRange::GetWhole().GetTo(),                                         loc_index);        for ( ; mit; ++mit) {            CSeq_loc_Conversion& cvt = *mit->second;            cvt.Reset();            if ( cvt.GoodSrcId(src.GetEmpty()) ) {                (*dst)->SetEmpty(cvt.GetDstId());                res = true;                break;            }        }        break;    }    case CSeq_loc::e_Whole:    {        const CSeq_id& src_id = src.GetWhole();        // Convert to the allowed master seq interval        CSeq_interval whole_int;        whole_int.SetId().Assign(src_id);        whole_int.SetFrom(0);        CBioseq_Handle bh = m_Scope->GetBioseqHandle(src_id,            CScope::eGetBioseq_All);        whole_int.SetTo(bh.GetBioseqLength());        res = ConvertInterval(whole_int, dst, loc_index);        break;    }    case CSeq_loc::e_Int:    {        res = ConvertInterval(src.GetInt(), dst, loc_index);        break;    }    case CSeq_loc::e_Pnt:    {        res = ConvertPoint(src.GetPnt(), dst, loc_index);        break;    }    case CSeq_loc::e_Packed_int:    {        const CPacked_seqint::Tdata& src_ints = src.GetPacked_int().Get();        CPacked_seqint::Tdata& dst_ints = (*dst)->SetPacked_int().Set();        ITERATE ( CPacked_seqint::Tdata, i, src_ints ) {            CRef<CSeq_loc> dst_int(new CSeq_loc);            bool mapped = ConvertInterval(**i, &dst_int, loc_index);            if (mapped) {                if ( dst_int->IsInt() ) {                    dst_ints.push_back(CRef<CSeq_interval>(&dst_int->SetInt()));                }                else if ( dst_int->IsPacked_int() ) {                    CPacked_seqint::Tdata& splitted = dst_int->SetPacked_int().Set();                    dst_ints.merge(splitted);                }                else {                    _ASSERT("this cannot happen" && 0);                }            }            m_Partial |= !mapped;            res |= mapped;        }        break;    }    case CSeq_loc::e_Packed_pnt:    {        const CPacked_seqpnt& src_pack_pnts = src.GetPacked_pnt();        const CPacked_seqpnt::TPoints& src_pnts = src_pack_pnts.GetPoints();        CRef<CSeq_loc> tmp(new CSeq_loc);        // using mix, not point, since mappings may have        // different strand, fuzz etc.        CSeq_loc_mix::Tdata& locs = tmp->SetMix().Set();        ITERATE ( CPacked_seqpnt::TPoints, i, src_pnts ) {            bool mapped = false;            TRangeIterator mit = BeginRanges(                CSeq_id_Handle::GetHandle(src_pack_pnts.GetId()),                *i, *i,                loc_index);            for ( ; mit; ++mit) {                CSeq_loc_Conversion& cvt = *mit->second;                cvt.Reset();                if ( !cvt.GoodSrcId(src_pack_pnts.GetId()) ) {                    continue;                }                TSeqPos dst_pos = cvt.ConvertPos(*i);                if ( dst_pos != kInvalidSeqPos ) {                    CRef<CSeq_loc> pnt(new CSeq_loc);                    pnt->SetPnt(*cvt.GetDstPoint());                    _ASSERT(pnt);                    locs.push_back(pnt);                    m_TotalRange += cvt.GetTotalRange();                    mapped = true;                    break;                }            }            m_Partial |= !mapped;            res |= mapped;        }        break;    }    case CSeq_loc::e_Mix:    {        const CSeq_loc_mix::Tdata& src_mix = src.GetMix().Get();        CRef<CSeq_loc> dst_loc;        CSeq_loc_mix::Tdata& dst_mix = (*dst)->SetMix().Set();        ITERATE ( CSeq_loc_mix::Tdata, i, src_mix ) {            dst_loc.Reset(new CSeq_loc);            if ( Convert(**i, &dst_loc, loc_index) ) {                _ASSERT(dst_loc);                dst_mix.push_back(dst_loc);                res = true;            }        }        m_Partial |= !res;        break;    }    case CSeq_loc::e_Equiv:    {        const CSeq_loc_equiv::Tdata& src_equiv = src.GetEquiv().Get();        CRef<CSeq_loc> dst_loc;        CSeq_loc_equiv::Tdata& dst_equiv = (*dst)->SetEquiv().Set();        ITERATE ( CSeq_loc_equiv::Tdata, i, src_equiv ) {            if ( Convert(**i, &dst_loc, loc_index) ) {                dst_equiv.push_back(dst_loc);                res = true;            }        }        m_Partial |= !res;        break;    }    case CSeq_loc::e_Bond:    {        const CSeq_bond& src_bond = src.GetBond();        // using mix, not bond, since mappings may have        // different strand, fuzz etc.        (*dst)->SetBond();        CRef<CSeq_point> pntA;        CRef<CSeq_point> pntB;        {{            TRangeIterator mit = BeginRanges(                CSeq_id_Handle::GetHandle(src_bond.GetA().GetId()),                src_bond.GetA().GetPoint(), src_bond.GetA().GetPoint(),                loc_index);            for ( ; mit  &&  !bool(pntA); ++mit) {                CSeq_loc_Conversion& cvt = *mit->second;                cvt.Reset();                if (cvt.ConvertPoint(src_bond.GetA())) {                    pntA = cvt.GetDstPoint();                    m_TotalRange += cvt.GetTotalRange();                    res = true;                }            }        }}        if ( src_bond.IsSetB() ) {            TRangeIterator mit = BeginRanges(                CSeq_id_Handle::GetHandle(src_bond.GetB().GetId()),                src_bond.GetB().GetPoint(), src_bond.GetB().GetPoint(),                loc_index);            for ( ; mit  &&  !bool(pntB); ++mit) {                CSeq_loc_Conversion& cvt = *mit->second;                cvt.Reset();                if (!bool(pntB)  &&  cvt.ConvertPoint(src_bond.GetB())) {                    pntB = cvt.GetDstPoint();                    m_TotalRange += cvt.GetTotalRange();                    res = true;                }            }        }        CSeq_bond& dst_bond = (*dst)->SetBond();        if ( bool(pntA)  ||  bool(pntB) ) {            if ( bool(pntA) ) {                dst_bond.SetA(*pntA);            }            else {                dst_bond.SetA().Assign(src_bond.GetA());            }            if ( bool(pntB) ) {                dst_bond.SetB(*pntB);            }            else if ( src_bond.IsSetB() ) {                dst_bond.SetB().Assign(src_bond.GetB());            }        }        m_Partial |= (!bool(pntA)  ||  !bool(pntB));        break;    }    default:        NCBI_THROW(CAnnotException, eBadLocation,                   "Unsupported location type");    }    return res;}void CSeq_loc_Conversion_Set::Convert(const CSeq_align& src,                                      CRef<CSeq_align>* dst){    CRef<CSeq_align_Mapper> mapper(new CSeq_align_Mapper(src));    mapper->Convert(*this);    *dst = mapper->GetDstAlign();}END_SCOPE(objects)END_NCBI_SCOPE/** ---------------------------------------------------------------------------* $Log: seq_loc_cvt.cpp,v $* Revision 1000.5  2004/06/01 19:24:09  gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.29** Revision 1.29  2004/05/26 14:29:20  grichenk* Redesigned CSeq_align_Mapper: preserve non-mapping intervals,* fixed strands handling, improved performance.** Revision 1.28  2004/05/21 21:42:13  gorelenk* Added PCH ncbi_pch.hpp** Revision 1.27  2004/05/10 18:26:37  grichenk* Fixed 'not used' warnings** Revision 1.26  2004/04/13 15:59:35  grichenk* Added CScope::GetBioseqHandle() with id resolving flag.** Revision 1.25  2004/03/30 21:21:09  grichenk* Reduced number of includes.** Revision 1.24  2004/03/30 15:42:33  grichenk* Moved alignment mapper to separate file, added alignment mapping* to CSeq_loc_Mapper.** Revision 1.23  2004/03/16 15:47:28  vasilche* Added CBioseq_set_Handle and set of EditHandles** Revision 1.22  2004/02/23 15:23:16  grichenk* Removed unused members** Revision 1.21  2004/02/19 19:25:09  vasilche* Hidded implementation of CAnnotObject_Ref.* Added necessary access methods.** Revision 1.20  2004/02/19 17:18:44  vasilche* Formatting + use CRef<> assignment directly.** Revision 1.19  2004/02/06 16:07:27  grichenk* Added CBioseq_Handle::GetSeq_entry_Handle()* Fixed MapLocation()** Revision 1.18  2004/02/05 22:49:19  grichenk* Added default cases in switches** Revision 1.17  2004/02/05 20:18:37  grichenk* Fixed std-segs processing** Revision 1.16  2004/02/02 14:44:54  vasilche* Removed several compilation warnings.** Revision 1.15  2004/01/30 15:25:45  grichenk* Fixed alignments mapping and sorting** Revision 1.14  2004/01/28 22:09:35  grichenk* Added CSeq_align_Mapper initialization for e_Disc** Revision 1.13  2004/01/28 20:54:36  vasilche* Fixed mapping of annotations.** Revision 1.12  2004/01/23 22:13:48  ucko* Fix variable shadowing that some compilers treated as an error.** Revision 1.11  2004/01/23 16:14:48  grichenk* Implemented alignment mapping** Revision 1.10  2004/01/02 16:06:53  grichenk* Skip location mapping for seq-aligns** Revision 1.9  2003/12/04 20:04:24  grichenk* Fixed bugs in seq-loc converters.** Revision 1.8  2003/11/10 18:11:04  grichenk* Moved CSeq_loc_Conversion_Set to seq_loc_cvt** Revision 1.7  2003/11/04 16:21:37  grichenk* Updated CAnnotTypes_CI to map whole features instead of splitting* them by sequence segments.** Revision 1.6  2003/10/29 19:55:47  vasilche* Avoid making 'whole' features on 'whole' segment partial (by Aleksey Grichenko)** Revision 1.5  2003/09/30 16:22:03  vasilche* Updated internal object manager classes to be able to load ID2 data.* SNP blobs are loaded as ID2 split blobs - readers convert them automatically.* Scope caches results of requests for data to data loaders.* Optimized CSeq_id_Handle for gis.* Optimized bioseq lookup in scope.* Reduced object allocations in annotation iterators.* CScope is allowed to be destroyed before other objects using this scope are* deleted (feature iterators, bioseq handles etc).* Optimized lookup for matching Seq-ids in CSeq_id_Mapper.* Added 'adaptive' option to objmgr_demo application.** Revision 1.4  2003/09/05 17:29:40  grichenk* Structurized Object Manager exceptions** Revision 1.3  2003/08/27 14:29:52  vasilche* Reduce object allocations in feature iterator.** Revision 1.2  2003/08/15 19:19:16  vasilche* Fixed memory leak in string packing hooks.* Fixed processing of 'partial' flag of features.* Allow table packing of non-point SNP.* Allow table packing of SNP with long alleles.** Revision 1.1  2003/08/14 20:05:19  vasilche* Simple SNP features are stored as table internally.* They are recreated when needed using CFeat_CI.** ===========================================================================*/

⌨️ 快捷键说明

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