当前位置: 首页>>代码示例>>C++>>正文


C++ auto_ptr::GetMatch方法代码示例

本文整理汇总了C++中auto_ptr::GetMatch方法的典型用法代码示例。如果您正苦于以下问题:C++ auto_ptr::GetMatch方法的具体用法?C++ auto_ptr::GetMatch怎么用?C++ auto_ptr::GetMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在auto_ptr的用法示例。


在下文中一共展示了auto_ptr::GetMatch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HighlightPattern

bool Sequence::HighlightPattern(const string& prositePattern, const MoleculeHighlightMap& restrictTo) const
{
    bool retval = true;
    try {

        // update CRegexp if not the same pattern as before
        static auto_ptr < CRegexp > regexp;
        static string previousPrositePattern;
        static int nGroups;
        if (!regexp.get() || prositePattern != previousPrositePattern) {

            // convert from ProSite syntax
            string regexPattern;
            if (!Prosite2Regex(prositePattern, &regexPattern, &nGroups))
                throw "error converting ProSite to regex syntax";

            // create pattern buffer
            TRACEMSG("creating CRegexp with pattern '" << regexPattern << "'");
            regexp.reset(new CRegexp(regexPattern, CRegexp::fCompile_ungreedy));

            previousPrositePattern = prositePattern;
        }

        // do the search, finding all non-overlapping matches
        int i, start = 0;
        while (start < (int)Length()) {

            // do the search
            string ignore = regexp->GetMatch(sequenceString, start, 0, CRegexp::fMatch_default, true);
            if (regexp->NumFound() <= 0)
                break;

//            TRACEMSG("got match, num (sub)patterns: " << regexp->NumFound());
//            for (i=0; i<regexp->NumFound(); ++i)
//                TRACEMSG("    " << i << ": " << (regexp->GetResults(i)[0] + 1) << '-' << regexp->GetResults(i)[1]);

            // check to see if this entire match is within the restricted set
            bool addMatch = true;
            if (restrictTo.size() > 0) {
                MoleculeHighlightMap::const_iterator r = restrictTo.find(identifier);
                if (r != restrictTo.end()) {
                    for (i=1; i<regexp->NumFound(); ++i) {
                        for (int j=regexp->GetResults(i)[0]; j<=regexp->GetResults(i)[1]-1; ++j) {
                            if (!r->second[j]) {
                                addMatch = false;
                                break;
                            }
                        }
                        if (!addMatch)
                            break;
                    }
                } else
                    addMatch = false;
            }

            // parse the match subpatterns, highlight each subpattern range
            if (addMatch)
                for (i=1; i<regexp->NumFound(); ++i)
                    GlobalMessenger()->AddHighlights(this, regexp->GetResults(i)[0], regexp->GetResults(i)[1] - 1);

            // start next search after the end of this one
            start = regexp->GetResults(regexp->NumFound() - 1)[1];
        }

    } catch (const char *err) {
        ERRORMSG("Sequence::HighlightPattern() - " << err);
        retval = false;
    } catch (exception& e) {
        ERRORMSG("Sequence::HighlightPattern() - caught exception: " << e.what());
        retval = false;
    }

    return retval;
}
开发者ID:DmitrySigaev,项目名称:ncbi,代码行数:74,代码来源:sequence_set.cpp


注:本文中的auto_ptr::GetMatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。