align_merge.cpp

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

CPP
213
字号
/* * =========================================================================== * PRODUCTION $Log: align_merge.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 20:54:07  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2 * PRODUCTION * =========================================================================== *//*  $Id: align_merge.cpp,v 1000.1 2004/06/01 20:54:07 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:  Yuri Kapustin * * File Description: *    CAlgoPlugin_AlignMerge -- wraps global alignment algorithms */#include <ncbi_pch.hpp>#include "align_merge.hpp"#include <gui/core/version.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/utils/message_box.hpp>#include <gui/plugin/PluginInfo.hpp>#include <gui/plugin/PluginRequest.hpp>#include <gui/plugin/PluginReply.hpp>#include <gui/plugin/PluginCommand.hpp>#include <gui/plugin/PluginCommandSet.hpp>#include <gui/plugin/PluginArgSet.hpp>#include <objects/seqalign/Seq_align.hpp>#include <objtools/alnmgr/alnmix.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);// GetInfo()// static interface to retrieve plugin registration informationvoid CAlgoPlugin_AlignMerge::GetInfo(CPluginInfo& info){    info.Reset();    // version info macro    info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,                 string(__DATE__) + " " + string(__TIME__),                 "CAlgoPlugin_AlignMerge",                 "Alignments/Merge Alignments",                 "Create a pseudomultiple alignment from a set of alignments",                 "");    // command info    CPluginCommandSet& cmds = info.SetCommands();    CPluginCommand&    cmd = cmds.AddAlgoCommand(eAlgoCommand_run);    cmd.AddArgument("aligns", "Alignments to merge",                     CSeq_align::GetTypeInfo(),                     CPluginArg::TData::e_Array);    cmd.AddDefaultFlag("gen2est",                        "Genomic <-> EST Alignment", true);    cmd.AddDefaultFlag("no_objmgr",                        "Don't fetch sequences",     false);    cmd.AddDefaultFlag("calc_score",                        "Recalculate scores",        true);    cmd.AddDefaultFlag("force_trans",                        "Force translation",         false);    cmd.AddDefaultFlag("truncate",                        "Truncate overlapping segments", false);    cmd.AddDefaultFlag("neg_strand",                        "Assume all on negative strand", false);    cmd.AddDefaultFlag("gap_join",                        "Join gaps where possible",  true);    cmd.AddDefaultFlag("min_gap",                        "Compress gaps where possible", true);    cmd.AddDefaultFlag("score_sort",                        "Sort by scores",            true);    cmd.AddDefaultFlag("query_merge",                        "Merge query sequence only", false);    cmd.AddDefaultFlag("fill_unaligned",                        "Fill unaligned regions",    false);}void CAlgoPlugin_AlignMerge::RunCommand(CPluginMessage& msg){    const CPluginCommand& cmd = msg.GetRequest().GetCommand();    CPluginReply& reply = msg.SetReply();    reply.SetStatus(eMessageStatus_failed);    // retrieve our alignments    plugin_args::TAlignList aligns;    GetArgValue(cmd["aligns"], aligns);    CAlnMix::TAddFlags   add_flags = 0;    CAlnMix::TMergeFlags merge_flags = 0;    if (cmd["gen2est"].AsBoolean()) {        merge_flags |= CAlnMix::fGen2EST;    }    if (cmd["no_objmgr"].AsBoolean()) {        add_flags |= CAlnMix::fDontUseObjMgr;    }    if (cmd["calc_score"].AsBoolean()) {        add_flags |= CAlnMix::fCalcScore;    }    if (cmd["force_trans"].AsBoolean()) {        add_flags |= CAlnMix::fForceTranslation;    }    if (cmd["truncate"].AsBoolean()) {        merge_flags |= CAlnMix::fTruncateOverlaps;    }    if (cmd["neg_strand"].AsBoolean()) {        merge_flags |= CAlnMix::fNegativeStrand;    }    if (cmd["gap_join"].AsBoolean()) {        merge_flags |= CAlnMix::fGapJoin;    }    if (cmd["min_gap"].AsBoolean()) {        merge_flags |= CAlnMix::fMinGap;    }    if (cmd["score_sort"].AsBoolean()) {        merge_flags |= CAlnMix::fSortSeqsByScore;    }    if (cmd["query_merge"].AsBoolean()) {        merge_flags |= CAlnMix::fQuerySeqMergeOnly;    }    if (cmd["fill_unaligned"].AsBoolean()) {        merge_flags |= CAlnMix::fFillUnalignedRegions;    }    set< CConstRef<IDocument> > docs;    ITERATE (plugin_args::TAlignList, iter, aligns) {        docs.insert(iter->first);    }    if (docs.size() != 1) {        NcbiMessageBox("Failed to merge alignments:\n"                       "All alignments must be in the same document");        return;    }    try {        CConstRef<IDocument> doc = *docs.begin();        CAlnMix mix(doc->GetScope());        ITERATE (plugin_args::TAlignList, iter, aligns) {            mix.Add(*iter->second, add_flags);        }        mix.Merge(merge_flags);        CRef<CSeq_annot> annot(new CSeq_annot());        annot->SetName("Merged Alignment");        annot->SetData().SetAlign().push_back            (CRef<CSeq_align>(const_cast<CSeq_align*>(&mix.GetSeqAlign())));        reply.AddObject(*doc, *annot);        reply.AddAction(CPluginReplyAction::e_Add_to_document);        reply.SetStatus(eMessageStatus_success);    }    catch (CException& e) {        NcbiMessageBox("Failed to merge alignments:\n" +                       e.GetMsg());        return;    }#ifndef _DEBUG    catch (...) {        NcbiMessageBox("Failed to merge alignments:\n"                       "Unknown error.");        return;    }#endif}END_NCBI_SCOPE/* * =========================================================================== * $Log: align_merge.cpp,v $ * Revision 1000.1  2004/06/01 20:54:07  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2 * * Revision 1.2  2004/05/21 22:27:46  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.1  2004/01/27 18:39:05  dicuccio * Initial revision * * =========================================================================== */

⌨️ 快捷键说明

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