Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -92,4 +100,4 @@ main(int argc, char ** argv)
// close the files
reader.close();
writer.close();
}
}
25 changes: 22 additions & 3 deletions src/stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

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;
}
}
16 changes: 15 additions & 1 deletion src/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ namespace stats {
std::unordered_map<artefact::Artefact, int> stats;
};

struct ArtefactBreakdown
{
// strand counts when there is NO artefact
std::unordered_map<strand::Strand, int> noArtefactStrand;

// counts of specific artefact types (TSO-TSO, RTP-RTP)
std::unordered_map<artefact::Artefact,int> artefactTypes;

int noArtefactTotal = 0;
int artefactTotal = 0;
};
/*
holds all the necessary stats about the reads in the file being parsed
*/
Expand All @@ -33,6 +44,7 @@ namespace stats {
int total;
StrandStats strand;
ArtefactStats artefact;
ArtefactBreakdown breakdown;
};

nlohmann::json
Expand All @@ -44,6 +56,8 @@ namespace stats {
nlohmann::json
toJson(Stats stats);

nlohmann::json
toJson(ArtefactBreakdown stats);
}

#endif
#endif