📄 entrez2_client.cpp
字号:
/* * =========================================================================== * PRODUCTION $Log: entrez2_client.cpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 19:32:08 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * PRODUCTION * =========================================================================== *//* $Id: entrez2_client.cpp,v 1000.2 2004/06/01 19:32:08 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. * * =========================================================================== * * Author: Josh Cherry * * File Description: * Entrez2 network client * * Remark: * This code was originally generated by application DATATOOL * using specifications from the data definition file * 'entrez2.asn'. */// standard includes// generated includes#include <ncbi_pch.hpp>#include <objects/entrez2/entrez2_client.hpp>#include <objects/entrez2/Entrez2_db_id.hpp>#include <objects/entrez2/Entrez2_link_id.hpp>#include <objects/entrez2/Entrez2_db_id.hpp>#include <objects/entrez2/Entrez2_id.hpp>#include <objects/entrez2/Entrez2_get_links.hpp>#include <objects/entrez2/Entrez2_id_list.hpp>#include <objects/entrez2/Entrez2_boolean_element.hpp>#include <objects/entrez2/Entrez2_boolean_exp.hpp>#include <objects/entrez2/Entrez2_eval_boolean.hpp>#include <objects/entrez2/Entrez2_boolean_reply.hpp>// generated classesBEGIN_NCBI_SCOPEBEGIN_objects_SCOPE // namespace ncbi::objects::// destructorCEntrez2Client::~CEntrez2Client(void){}/// A simplified interface for getting neighbors (links)/// This form just yields a vector of UIDsvoid CEntrez2Client::GetNeighbors(int query_uid, const string& db, const string& link_type, vector<int>& neighbor_uids){ vector<int> uids; uids.push_back(query_uid); GetNeighbors(uids, db, link_type, neighbor_uids);}/// This form just yields a vector of UIDsvoid CEntrez2Client::GetNeighbors(const vector<int>& query_uids, const string& db, const string& link_type, vector<int>& neighbor_uids){ // first retrieve the link_set CRef<CEntrez2_link_set> link_set; link_set = GetNeighbors(query_uids, db, link_type); // then extract the UIDs CEntrez2_id_list::TConstUidIterator it = link_set->GetIds().GetConstUidIterator(); for ( ; !it.AtEnd(); ++it) { neighbor_uids.push_back(*it); }}/// This form returns the entire CEntrez2_link_set object,/// which includes scores.CRef<CEntrez2_link_set> CEntrez2Client::GetNeighbors(int query_uid, const string& db, const string& link_type){ vector<int> uids; uids.push_back(query_uid); return GetNeighbors(uids, db, link_type);}/// This form returns the entire CEntrez2_link_set object,/// which includes scores.CRef<CEntrez2_link_set>CEntrez2Client::GetNeighbors(const vector<int>& query_uids, const string& db, const string& link_type){ CEntrez2_id_list uids; uids.SetDb() = CEntrez2_db_id(db); uids.AssignUids(query_uids); CEntrez2_get_links gl; gl.SetUids(uids); gl.SetLinktype().Set(db + "_" + link_type); CRef<CEntrez2_link_set> link_set = AskGet_links(gl); return link_set;}/// Retrieve counts of the various types of neighbors availableCRef<CEntrez2_link_count_list>CEntrez2Client::GetNeighborCounts(int query_uid, const string& db){ CEntrez2_id uid; uid.SetDb() = CEntrez2_db_id(db); uid.SetUid(query_uid); return AskGet_link_counts(uid);}/// Query a db with a string, returning uids as integersvoid CEntrez2Client::Query(const string& query, const string& db, vector<int>& result_uids){ CRef<CEntrez2_boolean_element> bel(new CEntrez2_boolean_element); bel->SetStr(query); CEntrez2_boolean_exp bexp; bexp.SetDb().Set(db); bexp.SetExp().push_back(bel); CEntrez2_eval_boolean req; req.SetReturn_UIDs(true); req.SetQuery(bexp); CRef<CEntrez2_boolean_reply> reply = AskEval_boolean(req); // now extract the UIDs if (!reply->GetUids().CanGetUids ()) { // this happens when no matches were found return; } for (CEntrez2_id_list::TConstUidIterator it = reply->GetUids().GetConstUidIterator(); !it.AtEnd(); ++it) { result_uids.push_back(*it); }}/// Given some uids, a database, and an entrez query string,/// determine which of these uids match the query stringvoid CEntrez2Client::FilterIds(const vector<int>& query_uids, const string& db, const string& query_string, vector<int>& result_uids){ if (query_uids.empty()) { return; } string uids; ITERATE (vector<int>, uid, query_uids) { if ( !uids.empty() ) { uids += " OR "; } uids += NStr::IntToString(*uid) + "[UID]"; } string whole_query = "(" + query_string + ") AND (" + uids + ")"; Query(whole_query, db, result_uids);}END_objects_SCOPE // namespace ncbi::objects::END_NCBI_SCOPE/** ===========================================================================** $Log: entrez2_client.cpp,v $* Revision 1000.2 2004/06/01 19:32:08 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9** Revision 1.9 2004/05/19 17:20:02 gorelenk* Added include of PCH - ncbi_pch.hpp** Revision 1.8 2004/03/11 17:29:07 dicuccio* Added APIs for retrieving neighbors for multiple UIDs. Changed how link type* is interpreted - both link and db are databases** Revision 1.7 2004/01/20 05:36:56 jcherry* Added missing '&' on argument to FilterIds (pass by reference)** Revision 1.6 2003/10/21 13:48:49 grichenk* Redesigned type aliases in serialization library.* Fixed the code (removed CRef-s, added explicit* initializers etc.)** Revision 1.5 2003/10/17 16:44:01 jcherry* Fixed behavior when Query finds nothing** Revision 1.4 2003/10/16 20:10:23 jcherry* Added some simplified interfaces for querying** Revision 1.3 2003/10/08 19:56:44 jcherry* OK, we're back** Revision 1.1 2003/10/08 19:18:01 jcherry* Added a simplified interface for getting neighbors*** ===========================================================================*//* Original file checksum: lines: 64, chars: 1896, CRC32: cd6a8df4 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -