80 if (seqs.size() == 0) {
81 LOG_POST(
"CTaxTreeToolJob: no input!");
86 bool tinit_ok = taxon1.
Init();
100 CScope* scope = seqs[0].scope.GetPointer();
108 const CObject*
object = it->object.GetPointer();
114 seq_id =
dynamic_cast<const CSeq_id*
>(object);
116 seq_loc =
dynamic_cast<const CSeq_loc*
>(object);
122 bool handle_valid =
false;
129 if (seq_loc && seq_loc->
GetId()) {
139 handles.push_back(canonical_seq_id_h);
151 }
catch (std::exception&) {
160 const CObject*
object = it->object.GetPointer();
166 seq_id =
dynamic_cast<const CSeq_id*
>(object);
168 seq_loc =
dynamic_cast<const CSeq_loc*
>(object);
179 if (seq_loc && seq_loc->
GetId()) {
199 if (tax_it != bio2tax.
end()) {
200 tax_id = (*tax_it).second;
208 if ( seq_id && seq_id->
IsGi() ) {
209 gi = seq_id->
GetGi();
212 gi = scope->
GetGi(canonical_seq_id_h);
216 if (seq_id && seq_id->
IsGi())
217 gi = seq_id->
GetGi();
235 tax_id_list.push_back(tax_id);
236 taxbv[tax_id] =
true;
238 seq2tax[canonical_seq_id_h] =
STaxSeqInfo(tax_id, seqid_label);
241 ERR_POST(
"CTaxTreeToolJob: No tax_id for " << seqid_label);
252 if (tax_id_list.size() == 0) {
254 "Can't generate common tree for sequences:\n"
255 "No taxonomy IDs found.");
260 if (tax_id_list.size() == 1) {
261 tax_ids_join = tax_id_list;
265 "Can't generate common tree for sequences");
269 if (tax_ids_join.size() == 0) {
271 "Can't generate common tree for sequences:\n"
272 "No taxonomy IDs found.");
277 bool tax_load_ok =
false;
278 ITERATE(vector<int>, it, tax_ids_join) {
280 tax_load_ok |= taxon2.
LoadNode(tax_id);
285 "Can't generate common tree for sequences:\n"
286 "Taxonomic load was not successfull.");
302 TTaxon1Conv conv_func;
303 conv_func(*btc, tax_tree_iter);
309 int max_tax_id = conv_func.GetMaxNodeId();
314 TTaxon1Conv::TTaxon1Visitor::TNodeList& node_list = btc->
SetNodes().Set();
315 ITERATE(TSeqId2Tax, mit, seq2tax) {
316 string seqid_str = mit->first.AsString();
317 int tax_id = mit->second.tax_id;
319 const string&
label = mit->second.label;
324 cnode->SetId(max_tax_id);
325 cnode->SetParent(tax_id);
326 TTaxon1Conv::TTaxon1Visitor::TCNodeFeatureSet& fset = cnode->SetFeatures();
330 cfeat(
new TTaxon1Conv::TTaxon1Visitor::TCNodeFeature);
332 cfeat->SetValue(seqid_str);
334 fset.Set().push_back(cfeat);
339 cfeat(
new TTaxon1Conv::TTaxon1Visitor::TCNodeFeature);
341 cfeat->SetValue(
label);
343 fset.Set().push_back(cfeat);
348 cfeat(
new TTaxon1Conv::TTaxon1Visitor::TCNodeFeature);
350 cfeat->SetValue(tax_id_str);
352 fset.Set().push_back(cfeat);
354 node_list.push_back(cnode);
365 item->
SetItem().SetOther().Set(*btc);
366 string project_item_label(
"Common TaxTree (");
368 project_item_label +=
" sequences)";
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
Things for representing and manipulating bio trees.
void AddProjectItem(objects::CProjectItem &item)
const string & GetLastError() const
bool GetTaxId4GI(TGi gi, TTaxId &tax_id_out)
vector< TTaxId > TTaxIdList
bool GetPopsetJoin(const TTaxIdList &ids_in, TTaxIdList &ids_out)
bool LoadNode(TTaxId tax_id, const ITaxon1Node **ppNode=NULL)
CRef< ITreeIterator > GetTreeIterator(EIteratorMode mode=eIteratorMode_Default)
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 ERR_POST(message)
Error posting with file, line number information but without error codes.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
CTaxTreeToolParams m_Params
TConstScopedObjects & SetObjects()
virtual void x_CreateProjectItems()
override this function in derived classes and populate m_Items.
CTaxTreeToolJob(const CTaxTreeToolParams ¶ms)
CTaxTreeToolJob.
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
string m_Descr
mutex to sync our internals
vector< SConstScopedObject > TConstScopedObjects
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
TTaxId GetTaxId(const CBioseq_Handle &handle)
return the tax-id associated with a given sequence.
vector< TTaxId > TTaxIds
Get taxonomy ids of sequences Return -1 for sequences that aren't found Return 0 for sequences that d...
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
TGi GetGi(const CSeq_id_Handle &idh, TGetFlags flags=0)
Get GI of a sequence Returns ZERO_GI if the sequence is not found or if it doesn't have GI.
TTaxIds GetTaxIds(const TSeq_id_Handles &idhs, TGetFlags flags=0)
vector< CSeq_id_Handle > TSeq_id_Handles
Bulk retrieval methods Common argument typedef - vector of requested ids.
CConstRef< CSeq_id > GetSeqId(void) const
Get id which can be used to access this bioseq handle Throws an exception if none is available.
CConstRef< CSeq_id > GetNonLocalIdOrNull(void) const
Find a non-local ID if present, consulting assembly details if all IDs for the overall sequence are l...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static const char label[]
@ BM_GAP
GAP compression is ON.
void SetNodes(TNodes &value)
Assign a value to Nodes data member.
void SetTreetype(const TTreetype &value)
Assign a value to Treetype data member.
void SetLabel(const TLabel &value)
Assign a value to Label data member.
void SetItem(TItem &value)
Assign a value to Item data member.
TGi GetGi(void) const
Get the variant data.
bool IsGi(void) const
Check if variant Gi is selected.
Compressed bitset (entry point to bm.h)
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
Sequence information record.
STaxSeqInfo(int tax, string l)
string label
sequence label