restriction_sites.cpp

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

CPP
651
字号
            // do the big search            CFindRSites::Find(vec, enzymes, results);            // add description to annot            annot->SetName("Restriction sites");            // deal with stored enzyme results            sort(results.begin(), results.end(), SEnzymeNameCompare());            if (args["sort_by_number_of_sites"].AsBoolean()) {                // do a stablesort so alphabetical order preserved                // within sets with the same number of sites                stable_sort(results.begin(), results.end(), SLessDefSites());            }            // count the number of definite and possible sites            int total_definite_sites = 0, total_possible_sites = 0;            int total_non_cutters = 0;            ITERATE (TResults, result, results) {                total_definite_sites += (*result)->GetDefiniteSites().size();                total_possible_sites += (*result)->GetPossibleSites().size();                if ((*result)->GetDefiniteSites().size()                    + (*result)->GetPossibleSites().size() == 0) {                    total_non_cutters++;                }            }            _TRACE("Found " << total_definite_sites << " definite and "                   << total_possible_sites << " possible sites");            // in order to build dialog efficiently,            // pre-allocate rows            int total_rows = total_definite_sites + total_possible_sites                + total_non_cutters;            m_Dialog->SetRows(row + total_rows);            ITERATE (TResults, result, results) {                                //                // add sites to dialog                //                int starting_row = row;                m_Dialog->SetCell(row, 2) = (*result)->GetEnzymeName();                string num_sites =                    NStr::IntToString((*result)->GetDefiniteSites().size());                if (!(*result)->GetPossibleSites().empty()) {                    num_sites += "+";                    num_sites +=                        NStr::IntToString((*result)                                          ->GetPossibleSites().size());                    num_sites += "?";                }                m_Dialog->SetCell(row, 3) = num_sites;                const vector<CRSite>& definite_sites                    = (*result)->GetDefiniteSites();                ITERATE (vector<CRSite>, site, definite_sites) {                    string& pos_str = m_Dialog->SetCell(row, 4);                    pos_str = NStr::IntToString(site->GetStart() + 1) + " - "                        + NStr::IntToString(site->GetEnd() + 1);                    string plus_cuts;                    const vector<int>& pcuts = site->GetPlusCuts();                    ITERATE (vector<int>, cut, pcuts) {                        if (!plus_cuts.empty()) {                            plus_cuts += ", ";                        }                        plus_cuts += NStr::IntToString(*cut);                    }                    m_Dialog->SetCell(row, 5) = plus_cuts;                    string minus_cuts;                    const vector<int>& mcuts = site->GetMinusCuts();                    ITERATE (vector<int>, cut, mcuts) {                        if (!minus_cuts.empty()) {                            minus_cuts += ", ";                        }                        minus_cuts += NStr::IntToString(*cut);                    }                    m_Dialog->SetCell(row, 6) = minus_cuts;                    ++row;                }                const vector<CRSite>& possible_sites                    = (*result)->GetPossibleSites();                ITERATE (vector<CRSite>, site, possible_sites) {                    string& pos_str = m_Dialog->SetCell(row, 4);                    pos_str = string("???")                        + NStr::IntToString(site->GetStart() + 1) + " - "                        + NStr::IntToString(site->GetEnd() + 1);                    string plus_cuts;                    const vector<int>& pcuts = site->GetPlusCuts();                    ITERATE (vector<int>, cut, pcuts) {                        if (!plus_cuts.empty()) {                            plus_cuts += ", ";                        }                        plus_cuts += NStr::IntToString(*cut);                    }                    m_Dialog->SetCell(row, 5) = plus_cuts;                    string minus_cuts;                    const vector<int>& mcuts = site->GetMinusCuts();                    ITERATE (vector<int>, cut, mcuts) {                        if (!minus_cuts.empty()) {                            minus_cuts += ", ";                        }                        minus_cuts += NStr::IntToString(*cut);                    }                    m_Dialog->SetCell(row, 6) = minus_cuts;                    ++row;                }                if (row == starting_row) {                    row++;                }                //                // add features to annot                //                s_AddSitesToAnnot(definite_sites, **result, *annot, loc);                s_AddSitesToAnnot(possible_sites, **result, *annot, loc, false);            }            // attach annot to doc            //const_cast<IDocument&>(doc).AttachAnnot(*annot);            //const_cast<IDocument&>(doc).UpdateAllViews(fDocumentChanged);            reply.AddObject(doc, *annot);        }        catch (exception& e) {            LOG_POST(Error << e.what());            string str = CPluginUtils::GetLabel(loc, &doc.GetScope());            LOG_POST(Error << "Error processing location " << str);        }#ifndef _DEBUG        catch (...) {            string str = CPluginUtils::GetLabel(loc, &doc.GetScope());            LOG_POST(Error << "Error processing location " << str);        }#endif    }    // update all views    //CDocManager::UpdateAllViews();    //    // prepare our dialog box    //    m_Dialog->SetLabel(string("A search for restriction sites for ")                       + NStr::IntToString(enzymes.size())                       + " enzymes produced:");    m_Dialog->Show();    reply.SetStatus(eMessageStatus_success);    reply.AddAction(CPluginReplyAction::e_Add_to_document);}void CAlgoPlugin_RestrictionSites::x_LoadREnzymeData(vector<CREnzyme>& enzymes,                                     CRebase::EEnzymesToLoad which_enzymes){    CNcbiApplication* app = CNcbiApplication::Instance();    _ASSERT(app);    CNcbiRegistry& registry = app->GetConfig();    string fname;    // By default the rebase "NAR format" file     // is assumed to be <std>/etc/rebase.nar.    // This can be overridden in gbench.ini, via the application registry    // variable [RESTRICTION_SITES] RebaseData.    fname = registry.GetString("RESTRICTION_SITES", "RebaseData", "");    if ( !fname.empty() ) {        fname += ", ";    }    fname += "<home>/etc/rebase.nar, <std>/etc/rebase.nar";    fname = CSystemPath::ResolvePathExisting(fname);    if ( fname.empty() ) {        throw runtime_error("Couldn't open REBASE file ");    }    ifstream refile(fname.c_str());    CRebase::ReadNARFormat(refile, enzymes, which_enzymes);}// helper function to decode a parameterCRebase::EEnzymesToLoadCAlgoPlugin_RestrictionSites::x_DecodeWhichEnzymes(const string& s){    if (s == "commercially available") {        return CRebase::eCommercial;    } else if (s == "prototypes") {        return CRebase::ePrototype;    } else if (s == "all") {        return CRebase::eAll;    } else {        throw runtime_error(string("Invalid \"which_enzymes\" string: ")                            + s);    }}END_NCBI_SCOPE/* * =========================================================================== * $Log: restriction_sites.cpp,v $ * Revision 1000.5  2004/06/01 20:55:43  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.32 * * Revision 1.32  2004/05/21 22:27:47  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.31  2004/05/03 13:05:42  dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.30  2004/03/05 17:35:37  dicuccio * Use sequence::GetId() instead of CSeq_id::GetStringDescr() * * Revision 1.29  2004/02/17 20:35:25  rsmith * moved core/settings.[ch]pp and core/system_path.[ch]pp to config and utils, respectively. * * Revision 1.28  2004/01/27 18:38:09  dicuccio * Code clean-up.  Use standard names for plugins.  Removed unnecessary #includes * * Revision 1.27  2004/01/07 15:50:39  dicuccio * Adjusted for API change in CPluginUtils::GetLabel().  Standardized exception * reporting in algorithms. * * Revision 1.26  2003/12/31 15:36:08  grichenk * Moved CompareLocations() from CSeq_feat to CSeq_loc, * renamed it to Compare(). * * Revision 1.25  2003/11/24 15:45:28  dicuccio * Renamed CVersion to CPluginVersion * * Revision 1.24  2003/11/18 17:48:38  dicuccio * Added standard processing of return values * * Revision 1.23  2003/11/04 17:49:23  dicuccio * Changed calling parameters for plugins - pass CPluginMessage instead of paired * CPluginCommand/CPluginReply * * Revision 1.22  2003/10/27 17:46:49  dicuccio * Removed dead #includes * * Revision 1.21  2003/10/17 19:10:42  dicuccio * Code clean-up.  Refactored feature building into a more modular function. * Fixed list sorting - replaced with sorting of a vector to work around lack of * support for list::sort(functor) in MSVC * * Revision 1.20  2003/10/17 18:07:47  jcherry * Sort Seq-locs in mix by location.  Remap features for possible sites too. * * Revision 1.19  2003/10/15 13:40:26  dicuccio * Mkae sure to set the 'id' for the seq-locs before calling RemapChildToParent() * * Revision 1.18  2003/10/14 16:24:02  dicuccio * Added correct remapping of scanned locations to the parent location.  Cleaned * up code to look for data file - added hierarchichal search through path in INI, * user's home directory, and finally system installed path. * * Revision 1.17  2003/10/07 13:47:00  dicuccio * Renamed CPluginURL* to CPluginValue* * * Revision 1.16  2003/09/25 17:21:35  jcherry * Added name to annot * * Revision 1.15  2003/09/04 14:05:24  dicuccio * Use IDocument instead of CDocument * * Revision 1.14  2003/09/03 14:46:53  rsmith * change namespace name from args to plugin_args to avoid clashes with variable names. * * Revision 1.13  2003/08/22 15:47:45  dicuccio * Added 'objects::' where necessary * * Revision 1.12  2003/08/21 19:24:16  jcherry * Moved restriction site finding to algo/sequence * * Revision 1.11  2003/08/21 18:38:32  jcherry * Overloaded CFindRSites::Find to take several sequence containers. * Added option to lump together enzymes with identical specificities. * * Revision 1.10  2003/08/21 12:03:07  dicuccio * Make use of new typedef in plugin_utils.hpp for argument values. * * Revision 1.9  2003/08/20 22:57:44  jcherry * Reimplemented restriction site finding using finite state machine * * Revision 1.8  2003/08/18 19:24:15  jcherry * Moved orf and seq_match to algo/sequence * * Revision 1.7  2003/08/15 16:57:17  jcherry * For consecutive enzymes with identical specificities, reuse * search results.  This saves a bunch of time. * * Revision 1.6  2003/08/15 16:33:40  jcherry * Fixed typo * * Revision 1.5  2003/08/15 15:26:12  jcherry * Changed so that restriction site searching (CFindRSites::Find) returns * a vector of CRefs rather than a vector of objects.  This speeds sorting. * * Revision 1.4  2003/08/14 18:33:32  jcherry * Use an rsite feature type (rather than a region). * Also include cleavage sites in feature location. * * Revision 1.3  2003/08/13 17:40:26  dicuccio * Formatting fixes.  Changes some pass-by-val to pass-by-reference.  Fixed * complement table * * Revision 1.2  2003/08/13 12:37:58  dicuccio * Partial compilation fixes for Windows * * Revision 1.1  2003/08/12 18:52:58  jcherry * Initial version * * =========================================================================== */

⌨️ 快捷键说明

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