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


C++ OutputFile::openFile方法代码示例

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


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

示例1: outputTree

auto_ptr<AlignmentSteps> RootedClusterTree::treeFromDistMatrix(RootedGuideTree* phyloTree,DistMatrix* distMat, Alignment *alignPtr,
                                           int seq1, int nSeqs, string& phylipName)
{
    OutputFile phylipPhyTreeFile;
    auto_ptr<AlignmentSteps> progSteps;
    try
    {
        // Test to see if the inputs are valid
        if(seq1 < 1 || nSeqs < 1)
        {
            cerr << "Invalid inputs into treeFromDistMatrix \n"
                 << "seq1 = " << seq1 << " nSeqs = " << nSeqs << "\n"
                 << "Need to end program!\n";
            exit(1);
            return progSteps;
        }

        float dist;
        string path;
        verbose = false;
        firstSeq = seq1;
        lastSeq = firstSeq + nSeqs - 1;

        SeqInfo info;
        info.firstSeq = firstSeq;
        info.lastSeq = lastSeq;
        info.numSeqs = nSeqs;

        utilityObject->getPath(userParameters->getSeqName(), &path);

        if(nSeqs >= 2)
        {
            string name = phylipName;
            if(!phylipPhyTreeFile.openFile(&name,
                             "\nEnter name for new GUIDE TREE           file  ", &path, "dnd",
                             "Guide tree"))
            {
                return progSteps;
            }
            phylipName = name;
        }
        else
        {
            return progSteps;
        }

        RootedTreeOutput outputTree(&info);

        ofstream* ptrToFile = phylipPhyTreeFile.getPtrToFile();

        if (nSeqs == 2)
        {
            dist = (*distMat)(firstSeq, firstSeq + 1) / 2.0;
            if(ptrToFile->is_open())
            {
                (*ptrToFile) <<  "(" << alignPtr->getName(firstSeq) << ":"
                             << setprecision(5)
                             << dist << "," << alignPtr->getName(firstSeq + 1) << ":"
                             << setprecision(5) << dist <<");\n";
            }
            progSteps.reset(new AlignmentSteps);
            vector<int> groups;
            groups.resize(nSeqs + 1, 0);
            groups[1] = 1;
            groups[2] = 2;
        }
        else
        {
            UPGMAAlgorithm clusAlgorithm;
            progSteps = clusAlgorithm.generateTree(phyloTree, distMat, &info, false);
            outputTree.printPhylipTree(phyloTree, ptrToFile, alignPtr, distMat);
        }
        return progSteps;
    }
    catch(const exception &ex)
    {
        cerr << "ERROR: Error has occured in treeFromDistMatrix. "
             << "Need to terminate program.\n"
             << ex.what();
        exit(1);
    }
    catch(...)
    {
        cerr << "ERROR: Error has occured in treeFromDistMatrix. "
             << "Need to terminate program.\n";
        exit(1);
    }
}
开发者ID:AnumQ,项目名称:protein,代码行数:88,代码来源:RootedClusterTree.cpp


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