blob_splitter_maker.cpp

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

CPP
599
字号
/* * =========================================================================== * PRODUCTION $Log: blob_splitter_maker.cpp,v $ * PRODUCTION Revision 1000.2  2004/06/01 19:24:50  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10 * PRODUCTION * =========================================================================== *//*  $Id: blob_splitter_maker.cpp,v 1000.2 2004/06/01 19:24:50 gouriano Exp $* ===========================================================================**                            PUBLIC DOMAIN NOTICE*               National Center for Biotechnology Information**  This software/database is a "United States Government Work" under the*  terms of the United States Copyright Act.  It was written as part of*  the author's official duties as a United States Government employee and*  thus cannot be copyrighted.  This software/database is freely available*  to the public for use. The National Library of Medicine and the U.S.*  Government have not placed any restriction on its use or reproduction.**  Although all reasonable efforts have been taken to ensure the accuracy*  and reliability of the software and data, the NLM and the U.S.*  Government do not and cannot warrant the performance or results that*  may be obtained by using this software or data. The NLM and the U.S.*  Government disclaim all warranties, express or implied, including*  warranties of performance, merchantability or fitness for any particular*  purpose.**  Please cite the author in any work or product based on this material.** ===========================================================================** Author:  Eugene Vasilchenko** File Description:*   Application for splitting blobs withing ID1 cache** ===========================================================================*/#include <ncbi_pch.hpp>#include <objmgr/split/blob_splitter_impl.hpp>#include <serial/objostr.hpp>#include <serial/serial.hpp>#include <serial/iterator.hpp>#include <objects/general/Object_id.hpp>#include <objects/seqloc/Seq_id.hpp>#include <objects/seqloc/Seq_loc.hpp>#include <objects/seqset/Seq_entry.hpp>#include <objects/seqset/Bioseq_set.hpp>#include <objects/seq/Bioseq.hpp>#include <objects/seq/Seq_annot.hpp>#include <objects/seq/Annot_id.hpp>#include <objects/seq/Annot_descr.hpp>#include <objects/seq/Annotdesc.hpp>#include <objects/seqalign/Seq_align.hpp>#include <objects/seqfeat/Seq_feat.hpp>#include <objects/seqres/Seq_graph.hpp>#include <objects/seqsplit/ID2S_Split_Info.hpp>#include <objects/seqsplit/ID2S_Chunk_Id.hpp>#include <objects/seqsplit/ID2S_Chunk.hpp>#include <objects/seqsplit/ID2S_Chunk_Data.hpp>#include <objects/seqsplit/ID2S_Chunk_Info.hpp>#include <objects/seqsplit/ID2S_Chunk_Content.hpp>#include <objects/seqsplit/ID2S_Seq_annot_Info.hpp>#include <objects/seqsplit/ID2S_Feat_type_Info.hpp>#include <objects/seqsplit/ID2_Seq_loc.hpp>#include <objects/seqsplit/ID2_Id_Range.hpp>#include <objects/seqsplit/ID2_Seq_range.hpp>#include <objects/seqsplit/ID2_Interval.hpp>#include <objects/seqsplit/ID2_Packed_Seq_ints.hpp>#include <objmgr/split/blob_splitter.hpp>#include <objmgr/split/object_splitinfo.hpp>#include <objmgr/split/annot_piece.hpp>#include <objmgr/split/asn_sizer.hpp>#include <objmgr/split/chunk_info.hpp>BEGIN_NCBI_SCOPEBEGIN_SCOPE(objects)template<class C>inlineC& NonConst(const C& c){    return const_cast<C&>(c);}/////////////////////////////////////////////////////////////////////////////// CBlobSplitterImpl/////////////////////////////////////////////////////////////////////////////CBlobSplitterImpl::CBlobSplitterImpl(const SSplitterParams& params)    : m_Params(params){}CBlobSplitterImpl::~CBlobSplitterImpl(void){}void CBlobSplitterImpl::Reset(void){    m_SplitBlob.Reset();    m_Skeleton.Reset(new CSeq_entry);    m_NextBioseq_set_Id = 1;    m_Bioseqs.clear();    m_Pieces.reset();    m_Chunks.clear();}void CBlobSplitterImpl::MakeID2SObjects(void){    m_Split_Info.Reset(new CID2S_Split_Info);    ITERATE ( TChunks, it, m_Chunks ) {        if ( it->first == 0 ) {            AttachToSkeleton(it->second);        }        else {            MakeID2Chunk(it->first, it->second);        }    }    m_SplitBlob.Reset(*m_Skeleton, *m_Split_Info);    ITERATE ( TID2Chunks, it, m_ID2_Chunks ) {        m_SplitBlob.AddChunk(it->first, *it->second);    }}struct SOneSeqAnnots{    typedef set<SAnnotTypeSelector> TTypeSet;    typedef COneSeqRange TTotalLocation;    void Add(const SAnnotTypeSelector& type, const COneSeqRange& loc)        {            m_TotalType.insert(type);            m_TotalLocation.Add(loc);        }    TTypeSet m_TotalType;    TTotalLocation m_TotalLocation;};struct SSplitAnnotInfo{    typedef vector<SAnnotTypeSelector> TTypeSet;    typedef CSeqsRange TLocation;    TTypeSet m_TypeSet;    TLocation m_Location;};struct SAllAnnots{    typedef map<CSeq_id_Handle, SOneSeqAnnots> TAllAnnots;    typedef vector<SAnnotTypeSelector> TTypeSet;    typedef map<TTypeSet, CSeqsRange> TSplitAnnots;    void Add(const CSeq_annot& annot)        {            switch ( annot.GetData().Which() ) {            case CSeq_annot::C_Data::e_Ftable:                Add(annot.GetData().GetFtable());                break;            case CSeq_annot::C_Data::e_Align:                Add(annot.GetData().GetAlign());                break;            case CSeq_annot::C_Data::e_Graph:                Add(annot.GetData().GetGraph());                break;            }        }    void Add(const CSeq_annot::C_Data::TGraph& objs)        {            SAnnotTypeSelector type(CSeq_annot::C_Data::e_Graph);            ITERATE ( CSeq_annot::C_Data::TGraph, it, objs ) {                CSeqsRange loc;                loc.Add(**it);                Add(type, loc);            }        }    void Add(const CSeq_annot::C_Data::TAlign& objs)        {            SAnnotTypeSelector type(CSeq_annot::C_Data::e_Align);            ITERATE ( CSeq_annot::C_Data::TAlign, it, objs ) {                CSeqsRange loc;                loc.Add(**it);                Add(type, loc);            }        }    void Add(const CSeq_annot::C_Data::TFtable& objs)        {            ITERATE ( CSeq_annot::C_Data::TFtable, it, objs ) {                SAnnotTypeSelector type((*it)->GetData().GetSubtype());                CSeqsRange loc;                loc.Add(**it);                Add(type, loc);            }        }    void Add(const SAnnotTypeSelector& sel, const CSeqsRange& loc)        {            ITERATE ( CSeqsRange, it, loc ) {                m_AllAnnots[it->first].Add(sel, it->second);            }        }    void SplitInfo(void)        {            ITERATE ( TAllAnnots, it, m_AllAnnots ) {                TTypeSet type_set;                ITERATE(SOneSeqAnnots::TTypeSet, tit, it->second.m_TotalType) {                    type_set.push_back(*tit);                }                m_SplitAnnots[type_set].Add(it->first,                                            it->second.m_TotalLocation);            }        }    TAllAnnots m_AllAnnots;    TSplitAnnots m_SplitAnnots;};typedef set<int> TWhole_set;TWhole_set seq_gis;typedef set<CSeqsRange::TRange> TGiInt_set;typedef map<int, TGiInt_set> TInt_set;TGiInt_set seq_ints;CRef<CID2_Seq_loc> MakeLoc(int gi, const TGiInt_set& int_set){    CRef<CID2_Seq_loc> loc(new CID2_Seq_loc);    if ( int_set.size() == 1 ) {        CID2_Interval& interval = loc->SetInterval();        interval.SetGi(gi);        const CSeqsRange::TRange& range = *int_set.begin();        interval.SetStart(range.GetFrom());        interval.SetLength(range.GetLength());    }    else {        CID2_Packed_Seq_ints& seq_ints = loc->SetPacked_ints();        seq_ints.SetGi(gi);        ITERATE ( TGiInt_set, it, int_set ) {            CRef<CID2_Seq_range> add(new CID2_Seq_range);            const CSeqsRange::TRange& range = *it;            add->SetStart(range.GetFrom());            add->SetLength(range.GetLength());            seq_ints.SetIntervals().push_back(add);        }    }    return loc;}void AddLoc(CRef<CID2_Seq_loc>& loc, const CRef<CID2_Seq_loc>& add){    if ( !loc ) {        loc = add;    }    else {        if ( !loc->IsLoc_set() ) {            CRef<CID2_Seq_loc> loc_set(new CID2_Seq_loc);            loc_set->SetLoc_set().push_back(loc);            loc = loc_set;        }        loc->SetLoc_set().push_back(add);    }}void AddLoc(CRef<CID2_Seq_loc>& loc, const TInt_set& int_set){    ITERATE ( TInt_set, it, int_set ) {        AddLoc(loc, MakeLoc(it->first, it->second));    }}void AddLoc(CRef<CID2_Seq_loc>& loc, int gi_start, int gi_count)

⌨️ 快捷键说明

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