Skip to content

Commit

Permalink
Merge branch 'master' of gitlab.rlp.net:muellan/metacache
Browse files Browse the repository at this point in the history
  • Loading branch information
muellan committed May 9, 2019
2 parents e213634 + 11ab3b9 commit 78b48a8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
12 changes: 8 additions & 4 deletions src/classification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,14 +672,14 @@ void map_queries_to_targets_default(

if(opt.output.showTaxAbundances) {
show_abundances(results.perTaxonOut, allTaxCounts,
results.statistics.total(), opt.output);
results.statistics, opt.output);
}

if(opt.output.showAbundanceEstimatesOnRank != taxonomy::rank::none) {
estimate_abundance(db, allTaxCounts, opt.output.showAbundanceEstimatesOnRank);

show_abundance_estimates(results.perTaxonOut, allTaxCounts,
results.statistics.total(), opt.output);
results.statistics, opt.output);
}
}

Expand Down Expand Up @@ -715,6 +715,10 @@ void map_candidates_to_targets(const vector<string>& queryHeaders,
const database& db, const query_options& opt,
classification_results& results)
{
if(opt.output.mapViewMode != map_view_mode::none) {
show_query_mapping_header(results.perReadOut, opt.output);
}

//taxon -> read count
taxon_count_map allTaxCounts;

Expand All @@ -737,14 +741,14 @@ void map_candidates_to_targets(const vector<string>& queryHeaders,

if(opt.output.showTaxAbundances) {
show_abundances(results.perTaxonOut, allTaxCounts,
results.statistics.total(), opt.output);
results.statistics, opt.output);
}

if(opt.output.showAbundanceEstimatesOnRank != taxonomy::rank::none) {
estimate_abundance(db, allTaxCounts, opt.output.showAbundanceEstimatesOnRank);

show_abundance_estimates(results.perTaxonOut, allTaxCounts,
results.statistics.total(), opt.output);
results.statistics, opt.output);
}
}

Expand Down
31 changes: 23 additions & 8 deletions src/printing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,47 +473,62 @@ void show_matches_per_targets(std::ostream& os,
//-------------------------------------------------------------------
void show_abundance_table(std::ostream& os,
const taxon_count_map& allTaxCounts,
const classification_statistics::count_t totalCount,
const classification_statistics& statistics,
const classification_output_options& opt)
{
os << opt.format.comment
<< "rank" << opt.format.rankSuffix
<< "name" << opt.format.column
<< "taxid" << opt.format.column
<< "number of reads" << opt.format.column
<< "abundance\n";

for(const auto& tc : allTaxCounts) {
if(tc.first) {
os << tc.first->rank_name() << opt.format.rankSuffix
<< tc.first->name();
<< tc.first->name() << opt.format.column;
if(tc.first->rank() == taxon_rank::Sequence)
os << tc.first->parent_id();
else
os << tc.first->id();
} else {
os << "none";
}
os << opt.format.column << tc.second << opt.format.column
<< (tc.second / double(totalCount) * 100) << "%\n";
<< (tc.second / double(statistics.total()) * 100) << "%\n";
}
os << "unclassified" << opt.format.column
<< '0' << opt.format.column
<< statistics.unassigned() << opt.format.column
<< statistics.unclassified_rate() * 100 << "%\n";
}



//-------------------------------------------------------------------
void show_abundances(std::ostream& os,
const taxon_count_map& allTaxCounts,
const classification_statistics::count_t totalCount,
const classification_statistics& statistics,
const classification_output_options& opt)
{
os << opt.format.comment
<< "query summary: number of queries mapped per taxon\n";
show_abundance_table(os, allTaxCounts, totalCount, opt);
<< "query summary: number of queries mapped per taxon\n";
show_abundance_table(os, allTaxCounts, statistics, opt);
}



//-------------------------------------------------------------------
void show_abundance_estimates(std::ostream& os,
const taxon_count_map& allTaxCounts,
const classification_statistics::count_t totalCount,
const classification_statistics& statistics,
const classification_output_options& opt)
{
os << opt.format.comment
<< "estimated abundance (number of queries) per "
<< taxonomy::rank_name(opt.showAbundanceEstimatesOnRank) << "\n";

show_abundance_table(os, allTaxCounts, totalCount, opt);
show_abundance_table(os, allTaxCounts, statistics, opt);
}


Expand Down
4 changes: 2 additions & 2 deletions src/printing.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void show_matches_per_targets(std::ostream&,
*****************************************************************************/
void show_abundances(std::ostream&,
const taxon_count_map&,
const classification_statistics::count_t,
const classification_statistics&,
const classification_output_options&);


Expand All @@ -127,7 +127,7 @@ void show_abundances(std::ostream&,
*****************************************************************************/
void show_abundance_estimates(std::ostream&,
const taxon_count_map&,
const classification_statistics::count_t,
const classification_statistics&,
const classification_output_options&);


Expand Down
2 changes: 2 additions & 0 deletions src/taxonomy.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ class taxonomy
return taxonomy::rank_name(rank_);
}

taxon_id parent_id() const noexcept { return parent_; }

bool has_parent() const noexcept {
return parent_ != taxonomy::none_id();
}
Expand Down
Binary file modified test/data.tar.gz
Binary file not shown.

0 comments on commit 78b48a8

Please sign in to comment.