57 }
catch (std::exception& ex) {
58 LOG_POST(
Error <<
"Exception in CTaxonCache::CTaxonCache() : " << ex.what());
67 }
catch (std::exception& ex) {
68 LOG_POST(
Error <<
"Exception in CTaxonCache::~CTaxonCache() : " << ex.what());
78 for (
auto &tax_it :
m_Map) {
79 ostr << tax_it.first <<
'\t' << tax_it.second.Label <<
'\t' << tax_it.second.TaxName <<
'\t' << tax_it.second.CommonName <<
'\t' << tax_it.second.BlastName <<
'\n';
91 while ( !line_reader->
AtEOF() ) {
108 m_Map[tax_id] = tax_info;
129 vector<int> to_initialize;
130 ITERATE(vector<int>, it, tax_ids) {
132 to_initialize.push_back(*it);
135 if (to_initialize.empty())
142 ITERATE(vector<int>, it, to_initialize) {
143 bool is_species =
false;
144 bool is_uncultured =
false;
151 org_ref->GetLabel(&tax_info.
Label);
152 if (org_ref->CanGetTaxname())
153 tax_info.
TaxName = org_ref->GetTaxname();
154 if (org_ref->CanGetCommon())
158 m_Map[*it] = tax_info;
162 catch (
const exception& ex) {
178 if (conn_res !=
true) {
186 bool is_species =
false;
187 bool is_uncultured =
false;
194 org_ref->GetLabel(&tax_info.
Label);
195 if (org_ref->CanGetTaxname())
196 tax_info.
TaxName = org_ref->GetTaxname();
197 if (org_ref->CanGetCommon())
201 m_Map[tax_id] = tax_info;
213 catch (
const exception& ex) {
220 catch (
const exception& ex)
222 LOG_POST(
Error <<
"Second try of CTaxonCache::GetLabel: " << ex.what());
236 return it->second.Label;
246 return it->second.TaxName;
256 return it->second.CommonName;
266 return it->second.BlastName;
CConstRef< COrg_ref > GetOrgRef(TTaxId tax_id, bool &is_species, bool &is_uncultured, string &blast_name, bool *is_specified=NULL)
void Initialize(const vector< int > &tax_ids)
void ResetConnection()
Drop connection to NCBI taxon service.
static void InitStorage(const char *cache_path)
TMap::const_iterator x_GetItem(int tax_id)
string GetTaxname(int tax_id)
static CTaxonCache & GetInstance()
string GetCommon(int tax_id)
string GetLabel(int tax_id)
void x_QueryTaxonService(int tax_id)
string GetBlastName(int tax_id)
void x_SaveTaxonCache() const
unique_ptr< objects::CTaxon1 > m_TaxonClient
static string m_CachePath
container_type::const_iterator const_iterator
const_iterator end() const
const_iterator find(const key_type &key) const
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define TAX_ID_FROM(T, value)
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
void Info(CExceptionArgs_Base &args)
CTempString GetCurrentLine(void) const
static CRef< ILineReader > New(const string &filename)
Return a new ILineReader object corresponding to the given filename, taking "-" (but not "....
virtual bool AtEOF(void) const =0
Indicates (negatively) whether there is any more input.
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static const char label[]
Lightweight interface for getting lines of data with minimal memory copying.
Multi-threading – mutexes; rw-locks; semaphore.
static const char *const strings[]
DEFINE_STATIC_MUTEX(s_Mutex)