diff --git a/src/main.cpp b/src/main.cpp index 5b8fa49..46fdc18 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,6 +82,14 @@ main(int argc, char ** argv) stats.total++; stats.strand.stats[record.strand]++; stats.artefact.stats[record.artefact]++; + + if (artefact::getName(record.artefact) == "no artefact") { + stats.breakdown.noArtefactStrand[record.strand]++; + stats.breakdown.noArtefactTotal++; + } else { + stats.breakdown.artefactTypes[record.artefact]++; + stats.breakdown.artefactTotal++; + } } if (!config.silent) { @@ -92,4 +100,4 @@ main(int argc, char ** argv) // close the files reader.close(); writer.close(); -} \ No newline at end of file +} diff --git a/src/stats.cpp b/src/stats.cpp index ea08595..a054077 100644 --- a/src/stats.cpp +++ b/src/stats.cpp @@ -28,10 +28,29 @@ namespace stats { toJson(Stats stats) { nlohmann::json json; + json["artefactBreakdown"] = toJson(stats.breakdown); json["totalReads"] = stats.total; - json["strandStats"] = toJson(stats.strand); - json["artefactStats"] = toJson(stats.artefact); return json; } -} \ No newline at end of file + + nlohmann::json + toJson(ArtefactBreakdown breakdown) + { + nlohmann::json json; + for (const auto& [strand, count] : breakdown.noArtefactStrand) { + json["no artefact"][std::string(1, strand)] = count; + } + json["no artefact"]["total"] = breakdown.noArtefactTotal; + + nlohmann::json artefactJson; + for (const auto& [key, count] : breakdown.artefactTypes) { + artefactJson[artefact::getName(key)] = count; + } + artefactJson["total"] = breakdown.artefactTotal; + + json["artefact"] = artefactJson; + + return json; + } +} diff --git a/src/stats.h b/src/stats.h index a5970bf..fa5cba7 100644 --- a/src/stats.h +++ b/src/stats.h @@ -25,6 +25,17 @@ namespace stats { std::unordered_map stats; }; + struct ArtefactBreakdown + { + // strand counts when there is NO artefact + std::unordered_map noArtefactStrand; + + // counts of specific artefact types (TSO-TSO, RTP-RTP) + std::unordered_map artefactTypes; + + int noArtefactTotal = 0; + int artefactTotal = 0; + }; /* holds all the necessary stats about the reads in the file being parsed */ @@ -33,6 +44,7 @@ namespace stats { int total; StrandStats strand; ArtefactStats artefact; + ArtefactBreakdown breakdown; }; nlohmann::json @@ -44,6 +56,8 @@ namespace stats { nlohmann::json toJson(Stats stats); + nlohmann::json + toJson(ArtefactBreakdown stats); } -#endif \ No newline at end of file +#endif