1 #ifndef EFETCH__HPP 2 #define EFETCH__HPP 3 4 /* $Id: efetch.hpp 119669 2008-02-12 19:40:05Z grichenk $ 5 * =========================================================================== 6 * 7 * PUBLIC DOMAIN NOTICE 8 * National Center for Biotechnology Information 9 * 10 * This software/database is a "United States Government Work" under the 11 * terms of the United States Copyright Act. It was written as part of 12 * the author's official duties as a United States Government employee and 13 * thus cannot be copyrighted. This software/database is freely available 14 * to the public for use. The National Library of Medicine and the U.S. 15 * Government have not placed any restriction on its use or reproduction. 16 * 17 * Although all reasonable efforts have been taken to ensure the accuracy 18 * and reliability of the software and data, the NLM and the U.S. 19 * Government do not and cannot warrant the performance or results that 20 * may be obtained by using this software or data. The NLM and the U.S. 21 * Government disclaim all warranties, express or implied, including 22 * warranties of performance, merchantability or fitness for any particular 23 * purpose. 24 * 25 * Please cite the author in any work or product based on this material. 26 * 27 * =========================================================================== 28 * 29 * Author: Aleksey Grichenko 30 * 31 * File Description: 32 * EFetch request 33 * 34 */ 35 36 #include <corelib/ncbistd.hpp> 37 #include <objtools/eutils/api/eutils.hpp> 38 #include <objtools/eutils/uilist/IdList.hpp> 39 40 41 BEGIN_NCBI_SCOPE 42 43 44 /** @addtogroup EUtils 45 * 46 * @{ 47 */ 48 49 50 ///////////////////////////////////////////////////////////////////////////// 51 /// 52 /// CEFetch_Request 53 /// 54 /// Base class for all EFetch readers 55 /// 56 57 58 class NCBI_EUTILS_EXPORT CEFetch_Request : public CEUtils_Request 59 { 60 public: 61 CEFetch_Request(CRef<CEUtils_ConnContext>& ctx); 62 virtual ~CEFetch_Request(void); 63 64 /// Get CGI script query string. 65 virtual string GetQueryString(void) const; 66 67 /// Group of ids to retrieve. GetId(void) const68 const CEUtils_IdGroup& GetId(void) const { return m_Id; } GetId(void)69 CEUtils_IdGroup& GetId(void) { Disconnect(); return m_Id; } 70 71 /// Sequential number of the first id retrieved. Default is 0 which 72 /// will retrieve the first record. GetRetStart(void) const73 int GetRetStart(void) const { return m_RetStart; } SetRetStart(int retstart)74 void SetRetStart(int retstart) { Disconnect(); m_RetStart = retstart; } 75 76 /// Number of items retrieved, default is 20, maximum is 10,000. GetRetMax(void) const77 int GetRetMax(void) const { return m_RetMax; } SetRetMax(int retmax)78 void SetRetMax(int retmax) { Disconnect(); m_RetMax = retmax; } 79 80 /// Output format for efetch requests. 81 enum ERetMode { 82 eRetMode_none = 0, 83 eRetMode_xml, ///< Return data as XML 84 eRetMode_html, ///< Return data as HTML 85 eRetMode_text, ///< Return data as plain text 86 eRetMode_asn ///< Return data as text ASN.1 87 }; 88 /// Output format. The real format can be different from the requested 89 /// one depending on the request type and other arguments (e.g. rettype). GetRetMode(void) const90 ERetMode GetRetMode(void) const { return m_RetMode; } SetRetMode(ERetMode retmode)91 void SetRetMode(ERetMode retmode) { Disconnect(); m_RetMode = retmode; } 92 93 /// Get serial stream format for reading data 94 virtual ESerialDataFormat GetSerialDataFormat(void) const; 95 96 /// Get IdList using the currently set DB, WebEnv, retstart, retmax etc. 97 /// Limit number of ids in a single request to chunk_size if it's > 0. 98 /// Stream format is set to XML. 99 /// Data type should be set before calling this method. The method does 100 /// not check returned data type, an exception will be thrown if reading 101 /// fails. 102 virtual CRef<uilist::CIdList> FetchIdList(int chunk_size); 103 104 protected: 105 106 private: 107 typedef CEUtils_Request TParent; 108 109 const char* x_GetRetModeName(void) const; 110 111 CEUtils_IdGroup m_Id; 112 int m_RetStart; 113 int m_RetMax; 114 ERetMode m_RetMode; 115 }; 116 117 118 ///////////////////////////////////////////////////////////////////////////// 119 /// 120 /// CEFetch_Literature_Request 121 /// 122 /// Literature database request. 123 /// 124 125 126 class NCBI_EUTILS_EXPORT CEFetch_Literature_Request : public CEFetch_Request 127 { 128 public: 129 /// Literature databases. 130 enum ELiteratureDB { 131 eDB_pubmed = 0, 132 eDB_pmc, 133 eDB_journals, 134 eDB_omim 135 }; 136 CEFetch_Literature_Request(ELiteratureDB db, 137 CRef<CEUtils_ConnContext>& ctx); 138 139 /// Output types based on database. 140 enum ERetType { 141 eRetType_none = 0, 142 eRetType_uilist, 143 eRetType_abstract, 144 eRetType_citation, 145 eRetType_medline, 146 eRetType_full 147 }; 148 149 /// Output data type. GetRetType(void) const150 ERetType GetRetType(void) const { return m_RetType; } SetRetType(ERetType rettype)151 void SetRetType(ERetType rettype) { Disconnect(); m_RetType = rettype; } 152 153 /// Get CGI script query string 154 virtual string GetQueryString(void) const; 155 156 /// Get IdList using the currently set DB, WebEnv, retstart, retmax etc. 157 /// The method changes rettype to uilist and retmode to xml, all other 158 /// parameters are unchanged. 159 /// Limit number of ids in a single request to chunk_size if it's > 0. 160 virtual CRef<uilist::CIdList> FetchIdList(int chunk_size); 161 162 private: 163 typedef CEFetch_Request TParent; 164 165 const char* x_GetRetTypeName(void) const; 166 167 ERetType m_RetType; 168 }; 169 170 171 ///////////////////////////////////////////////////////////////////////////// 172 /// 173 /// CEFetch_Sequence_Request 174 /// 175 /// Sequence database request. 176 /// 177 178 179 class NCBI_EUTILS_EXPORT CEFetch_Sequence_Request : public CEFetch_Request 180 { 181 public: 182 /// Sequence databases. 183 enum ESequenceDB { 184 eDB_gene = 0, 185 eDB_genome, 186 eDB_nucleotide, 187 eDB_nuccore, 188 eDB_nucest, 189 eDB_nucgss, 190 eDB_protein, 191 eDB_popset, 192 eDB_snp, 193 eDB_sequences 194 }; 195 CEFetch_Sequence_Request(ESequenceDB db, 196 CRef<CEUtils_ConnContext>& ctx); 197 198 /// Output types based on database. 199 enum ERetType { 200 eRetType_none = 0, 201 eRetType_native, 202 eRetType_fasta, 203 eRetType_gb, 204 eRetType_gbc, 205 eRetType_gbwithparts, 206 eRetType_est, 207 eRetType_gss, 208 eRetType_gp, 209 eRetType_gpc, 210 eRetType_seqid, 211 eRetType_acc, 212 eRetType_chr, 213 eRetType_flt, 214 eRetType_rsr, 215 eRetType_brief, 216 eRetType_docset 217 }; 218 219 /// Output data type. GetRetType(void) const220 ERetType GetRetType(void) const { return m_RetType; } SetRetType(ERetType rettype)221 void SetRetType(ERetType rettype) { Disconnect(); m_RetType = rettype; } 222 223 /// Strand of DNA to show. 224 enum EStrand { 225 eStrand_none = 0, 226 eStrand_plus = 1, 227 eStrand_minus = 2 228 }; 229 230 /// Strand of DNA to show. GetStrand(void) const231 EStrand GetStrand(void) const { return m_Strand; } SetStrand(EStrand strand)232 void SetStrand(EStrand strand) { Disconnect(); m_Strand = strand; } 233 234 /// Show sequence starting from this base number. GetSeqStart(void) const235 int GetSeqStart(void) const { return m_SeqStart; } SetSeqStart(int pos)236 void SetSeqStart(int pos) { Disconnect(); m_SeqStart = pos; } 237 /// Show sequence ending on this base number. GetSeqStop(void) const238 int GetSeqStop(void) const { return m_SeqStop; } SetSeqStop(int pos)239 void SetSeqStop(int pos) { Disconnect(); m_SeqStop = pos; } 240 241 /// Complexity level 242 enum EComplexity { 243 eComplexity_none = -1, 244 eComplexity_WholeBlob = 0, ///< Get the whole blob 245 eComplexity_Bioseq = 1, ///< Get bioseq (default in Entrez) 246 eComplexity_BioseqSet = 2, ///< Get the minimal bioseq-set 247 eComplexity_NucProt = 3, ///< Get the minimal nuc-prot 248 eComplexity_PubSet = 4 ///< Get the minimal pub-set 249 }; 250 251 /// Complexity level of the output data. GetComplexity(void) const252 EComplexity GetComplexity(void) const { return m_Complexity; } SetComplexity(EComplexity complexity)253 void SetComplexity(EComplexity complexity) 254 { Disconnect(); m_Complexity = complexity; } 255 256 /// Get CGI script query string 257 virtual string GetQueryString(void) const; 258 259 private: 260 typedef CEFetch_Request TParent; 261 262 const char* x_GetRetTypeName(void) const; 263 264 ERetType m_RetType; 265 EComplexity m_Complexity; 266 EStrand m_Strand; 267 int m_SeqStart; 268 int m_SeqStop; 269 }; 270 271 272 ///////////////////////////////////////////////////////////////////////////// 273 /// 274 /// CEFetch_Taxonomy_Request 275 /// 276 /// Taxonomy database request. 277 /// 278 279 280 class NCBI_EUTILS_EXPORT CEFetch_Taxonomy_Request : public CEFetch_Request 281 { 282 public: 283 CEFetch_Taxonomy_Request(CRef<CEUtils_ConnContext>& ctx); 284 285 /// Output data format. 286 enum EReport { 287 eReport_none = 0, 288 eReport_uilist, 289 eReport_brief, 290 eReport_docsum, 291 eReport_xml 292 }; 293 294 /// Output data format. GetReport(void) const295 EReport GetReport(void) const { return m_Report; } SetReport(EReport report)296 void SetReport(EReport report) { Disconnect(); m_Report = report; } 297 298 /// Get CGI script query string 299 virtual string GetQueryString(void) const; 300 301 /// Get IdList using the currently set DB, WebEnv, retstart, retmax etc. 302 /// The method changes report to uilist and retmode to xml, all other 303 /// parameters are unchanged. 304 /// Limit number of ids in a single request to chunk_size if it's > 0. 305 virtual CRef<uilist::CIdList> FetchIdList(int chunk_size); 306 307 private: 308 typedef CEFetch_Request TParent; 309 310 const char* x_GetReportName(void) const; 311 312 EReport m_Report; 313 }; 314 315 316 /* @} */ 317 318 319 END_NCBI_SCOPE 320 321 #endif // EFETCH__HPP 322