locus_link.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:7k
- /*
- * ===========================================================================
- * PRODUCTION $Log: locus_link.cpp,v $
- * PRODUCTION Revision 1000.5 2004/06/01 20:56:50 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: locus_link.cpp,v 1000.5 2004/06/01 20:56:50 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 "locus_link.hpp"
- #include "utils.hpp"
- #include <gui/plugin/PluginInfo.hpp>
- #include <gui/plugin/PluginRequest.hpp>
- #include <gui/plugin/PluginCommand.hpp>
- #include <gui/plugin/PluginCommandSet.hpp>
- #include <gui/plugin/PluginArgSet.hpp>
- #include <gui/plugin/PluginArg.hpp>
- #include <gui/core/version.hpp>
- #include <gui/core/idocument.hpp>
- #include <gui/core/plugin_utils.hpp>
- #include <gui/utils/app_popup.hpp>
- #include <corelib/ncbiapp.hpp>
- #include <corelib/ncbireg.hpp>
- #include <objmgr/util/feature.hpp>
- #include <objmgr/util/sequence.hpp>
- #include <objects/seq/Bioseq.hpp>
- #include <objects/seqfeat/Org_ref.hpp>
- #include <objects/general/Dbtag.hpp>
- #include <objects/general/Object_id.hpp>
- BEGIN_NCBI_SCOPE
- USING_SCOPE(objects);
- // standard info boilerplate
- void CAlgoLinkOut_LocusLink::GetInfo(CPluginInfo& info)
- {
- info.Reset();
- // version info macro
- info.SetInfo(CPluginVersion::eMajor, CPluginVersion::eMinor, 0,
- string(__DATE__) + " " + string(__TIME__),
- "CAlgoLinkOut_LocusLink", "Link Out/LocusLink",
- "Open items in LocusLink", "");
- // command info
- CPluginCommandSet& cmds = info.SetCommands();
- CPluginCommand& args = cmds.AddAlgoCommand(eAlgoCommand_run);
- args.AddArgument("gene", "Gene to search",
- CSeq_feat::GetTypeInfo());
- args.SetConstraint("gene",
- (*CPluginValueConstraint::CreateFeatType(),
- CSeqFeatData::e_Gene));
- args.AddArgument("orgn", "Limit to originating organism",
- CPluginArg::eBoolean);
- }
- // run our plugin
- void CAlgoLinkOut_LocusLink::RunCommand(CPluginMessage& msg)
- {
- const CPluginCommand& args = msg.GetRequest().GetCommand();
- CPluginReply& reply = msg.SetReply();
- plugin_args::TFeatList genes;
- GetArgValue(args["gene"], genes);
- const CSeq_feat& feat = *genes.front().second;
- const IDocument& doc = *genes.front().first;
- bool limit_to_orgn = args["orgn"].AsBoolean();
- // retrieve the default link for LocusLink
- CNcbiApplication* app = CNcbiApplication::Instance();
- _ASSERT(app);
- const CNcbiRegistry& reg = app->GetConfig();
- string locus_link_url =
- reg.GetString("LINKOUT", "LocusLink",
- "http://www.ncbi.nlm.nih.gov/LocusLink/list.cgi?"
- "Q=<gene>");
- string gene_name;
- feature::GetLabel(feat, &gene_name, feature::eContent, &doc.GetScope());
- locus_link_url = NStr::Replace(locus_link_url, "<gene>", gene_name);
- //
- // check for species
- //
- if (limit_to_orgn) {
- string species_tag;
- CBioseq_Handle handle =
- doc.GetScope().GetBioseqHandle(feat.GetLocation());
- CConstRef<COrg_ref> ref = GetOrganism(handle);
- if (ref) {
- switch (ref->GetTaxId()) {
- default:
- break;
- case 9606:
- // homo sapiens
- species_tag = "Hs";
- break;
- case 7227:
- // drosophila melanogaster
- species_tag = "Dm";
- break;
- case 7955:
- // danio rerio (zebrafish
- species_tag = "Dr";
- break;
- case 10090:
- // mus musculus
- species_tag = "Mm";
- break;
- case 10116:
- // rattus norvegicus
- species_tag = "Rn";
- break;
- }
- if ( !species_tag.empty() ) {
- locus_link_url += "&ORG=" + species_tag;
- }
- }
- }
- if ( !CAppPopup::PopupURL(locus_link_url) ) {
- reply.SetStatus(eMessageStatus_failed);
- } else {
- reply.SetStatus(eMessageStatus_success);
- }
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: locus_link.cpp,v $
- * Revision 1000.5 2004/06/01 20:56:50 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10
- *
- * Revision 1.10 2004/05/21 22:27:47 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.9 2004/01/27 18:45:26 dicuccio
- * Added missing header files
- *
- * Revision 1.8 2003/11/24 15:45:31 dicuccio
- * Renamed CVersion to CPluginVersion
- *
- * Revision 1.7 2003/11/06 20:12:13 dicuccio
- * Cleaned up handling of USING_SCOPE - removed from all headers
- *
- * Revision 1.6 2003/11/04 17:49:24 dicuccio
- * Changed calling parameters for plugins - pass CPluginMessage instead of paired
- * CPluginCommand/CPluginReply
- *
- * Revision 1.5 2003/10/15 18:30:01 dicuccio
- * Changed to match one-of-set constraint for feature type
- *
- * Revision 1.4 2003/10/07 13:47:04 dicuccio
- * Renamed CPluginURL* to CPluginValue*
- *
- * Revision 1.3 2003/09/25 17:49:17 dicuccio
- * Cleaned up handling of org-refs - implemented private function to return the
- * apporpriate COrg_ref. Added virtual destructors where necessary
- *
- * Revision 1.2 2003/09/24 18:24:57 dicuccio
- * Cleaned up determination of tax-id from org-ref
- *
- * Revision 1.1 2003/09/23 19:45:45 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */