test_density_map.cpp

来自「ncbi源码」· C++ 代码 · 共 213 行

CPP
213
字号
/* * =========================================================================== * PRODUCTION $Log: test_density_map.cpp,v $ * PRODUCTION Revision 1000.0  2004/06/01 21:22:02  gouriano * PRODUCTION PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.2 * PRODUCTION * =========================================================================== *//*  $Id: test_density_map.cpp,v 1000.0 2004/06/01 21:22:02 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. * * =========================================================================== * * Authors:  Mike DiCuccio * * File Description: * */#include <ncbi_pch.hpp>#include <corelib/ncbiapp.hpp>#include <corelib/ncbienv.hpp>#include <corelib/ncbiargs.hpp>#include <corelib/ncbitime.hpp>#include <objmgr/object_manager.hpp>#include <objtools/data_loaders/genbank/gbloader.hpp>#include <objmgr/scope.hpp>#include <objmgr/bioseq_handle.hpp>#include <objmgr/seq_vector.hpp>#include <objmgr/feat_ci.hpp>#include <gui/objutils/density_map.hpp>using namespace ncbi;using namespace ncbi::objects;class CTestDensityMap : public CNcbiApplication{public:    void Init();    int Run();};void CTestDensityMap::Init(void){    // Prepare command line descriptions    auto_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);    // input file containing the SAGE data (default = stdin)    arg_desc->AddKey("id", "Accession", "Accession to test",                     CArgDescriptions::eString);    arg_desc->AddDefaultKey("iters", "Iterations", "Iterations to test",                            CArgDescriptions::eInteger, "10");    arg_desc->AddDefaultKey("window", "WindowSize", "Number of bases per bin",                            CArgDescriptions::eInteger, "10000");    // Pass argument descriptions to the application    //    SetupArgDescriptions(arg_desc.release());}int CTestDensityMap::Run(void){    CArgs args = GetArgs();    string id_str = args["id"].AsString();    int iters = args["iters"].AsInteger();    int window = args["window"].AsInteger();    CSeq_id id(id_str);    if (id.Which() == CSeq_id::e_not_set) {        LOG_POST(Fatal << "can't interpret id = " << id_str);    }    CRef<CObjectManager> obj_mgr(new CObjectManager());    obj_mgr->RegisterDataLoader(*new CGBDataLoader(), CObjectManager::eDefault);    CScope scope(*obj_mgr);    scope.AddDefaults();    CBioseq_Handle handle = scope.GetBioseqHandle(id);    //    // first pass: retrieves all features.  We can ignore this pass    //    SAnnotSelector sel;    sel.SetAnnotType(CSeq_annot::TData::e_Ftable)        .SetOverlapType(SAnnotSelector::eOverlap_TotalRange)        .SetResolveMethod(SAnnotSelector::eResolve_All)        .SetDataSource("")        .SetFeatType(CSeqFeatData::e_Gene)        ;            CFeat_CI iter(handle, 0, 0, sel);    cout << "iterations:   " << iters << endl;    cout << "seq size:     " << handle.GetSeqVector().size() << endl;    cout << "window:       " << window << endl;    cout << id_str << ":    " << iter.GetSize() << " features" << endl;    CStopWatch sw;    sw.Start();    TSeqPos sum = 0;    int i;    for (i = 0;  i < iters;  ++i) {        CFeat_CI iter(handle, 0, 0, sel);        sum += iter.GetSize();    }    double e1 = sw.Elapsed();    cout << "overhead time: " << e1 << " seconds" << endl;    cout << "overhead/iter: " << e1 / double(iters) << endl;    cout << endl;    sw.Start();    TSeqPos max = 0;    vector<TSeqPos> bins;    for (i = 0;  i < iters;  ++i) {        sum += max = CDensityMap<int>::GetDensityMap(handle, 0, 0, window, sel, bins);    }    double e2 = sw.Elapsed();    cout << "density map:   " << bins.size() << endl;    cout << "map max:       " << max << endl;    cout << "map time:      " << e2 << " seconds" << endl;    cout << "map time/iter: " << (e2) / double(iters) << endl;    cout << endl;        sw.Start();        CDensityMap<int> new_bins(handle, window);    for (i = 0; i < iters; ++i ) {        new_bins.Clear();        new_bins.AddFeatures(handle, sel);    }    double e3 = sw.Elapsed();        cout << "new bins:      " << new_bins.GetBins() << endl;    cout << "new bins max:  " << new_bins.GetMax() << endl;    cout << "new bins time: " << e3 << " seconds" << endl;    cout << "new time/iter: " << (e3) / double(iters) << endl;     return 0;}int main(int argc, const char* argv[]){    return CTestDensityMap().AppMain(argc, argv, 0, eDS_Default, 0);}/* * =========================================================================== * $Log: test_density_map.cpp,v $ * Revision 1000.0  2004/06/01 21:22:02  gouriano * PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.2 * * Revision 1.2  2004/05/21 22:27:44  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.1  2004/05/09 23:59:55  dicuccio * Standardized names of demo and test applications.  Cleaned up LIB * specifications to eliminate unneeded libraries after splitting libgui_utils * into libgui_utils and libgui_objutils * * Revision 1.6  2004/05/06 18:00:11  gorelenk * Fixed include to density_map.hpp * * Revision 1.5  2004/04/13 17:38:46  grichenk * Fixed enumerator usage. * * Revision 1.4  2004/03/23 21:07:55  gorelenk * Corrected compilation errors. * * Revision 1.3  2004/02/09 21:02:46  rsmith * compare new and old CDensityMap implementations. * * Revision 1.2  2004/01/07 17:39:03  vasilche * Fixed include path to genbank loader. * * Revision 1.1  2003/08/15 19:05:42  dicuccio * Initial revision * * =========================================================================== */

⌨️ 快捷键说明

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