Skip to content
Merged
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
4 changes: 3 additions & 1 deletion data/test_data/md5sum.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
bcf8363f788e54d38a5ec758042959ce ./fastq_plain_out/fastq_1/fastqc_data.txt
41a799d28bdc2e35e17546fe2af146cb ./preseq_out/bam_1/fastqc_data.txt
39b50a91a778f9713d6b510af435a9f0 ./sam_stdin_out/sam_stdin/fastqc_data.txt
037cb6bad120661ac15ccf6020cb82b1 ./bam_kmers_out/bam_1/fastqc_data.txt
41a799d28bdc2e35e17546fe2af146cb ./bam_out/bam_1/fastqc_data.txt
55d98514eda63c2cf4b900a0fb7b074b ./fastq_bgzf_mult_out/fastq_bgzip_1/fastqc_data.txt
39a5df25471d6f250de7b31a03325254 ./fastq_bgzf_mult_out/fastq_bgzip_2/fastqc_data.txt
Expand All @@ -19,3 +18,6 @@ c36524a785c41cd0dbd18b23173e88c6 ./fastq_iupac_out/fastq_1_iupac/fastqc_data.tx
3c25a00c6744c680059103a6643d1b27 ./iupac_dups_out/iupac_dups_bam/fastqc_data.txt
672381b9141cb7b217c39b2b5455cb6c ./iupac_dups_out/iupac_dups/fastqc_data.txt
8a141f57a21f8f0f1bbc4b80e3a2ec47 ./sam_out/sam_1/fastqc_data.txt
037cb6bad120661ac15ccf6020cb82b1 ./kmers_out/bam_1/fastqc_data.txt
a6b078d60d45ba2e34edd7cff517b19e ./kmers_out/fastq_bgzip_1/fastqc_data.txt
bcf6ed7982eb16b61725bcc823c7eaad ./kmers_out/fastq_bgzip_2/fastqc_data.txt
14 changes: 8 additions & 6 deletions data/test_scripts/kmers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
# Test k-mer analysis with BAM input and one thread

prog=./falco
infile=test_data/bam_1.bam
outdir=bam_kmers_out
if [[ -e "${infile}" ]]; then
${prog} --kmers -o ${outdir} ${infile}
infile1=test_data/bam_1.bam
infile2=test_data/fastq_bgzip_1.fq.gz
infile3=test_data/fastq_bgzip_2.fq.gz
outdir=kmers_out
if [[ -e "${infile1}" ||-e "${infile2}" || -e "${infile3}" ]]; then
${prog} --kmers -o ${outdir} ${infile1} ${infile2} ${infile3}
x=$(md5sum --ignore-missing -c test_data/md5sum.txt | \
grep "${outdir}" | \
grep -c "OK$")
if [[ "${x}" != "1" ]]; then
if [[ "${x}" != "3" ]]; then
exit 1;
fi
rm -r ${outdir}
else
echo "${infile} not found; skipping remaining tests";
echo "input files for kmer tests not found; skipping remaining tests";
exit 77;
fi
17 changes: 11 additions & 6 deletions src/html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ name: "Theoretical distribution"
const auto theor = get_theoretical_distribution(
gc_content, static_cast<std::uint64_t>(total_count));
const auto gc_smoothed = smooth_gc_content(gc_content, smoothing_window);
// NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.UninitializedObject)
const auto lines_data = fmt::format(gc_fmt, x, gc_smoothed, x, theor);

const auto grade = grades.grade(label);
Expand Down Expand Up @@ -414,6 +415,7 @@ yaxis: {{title: "tile", type: "category"}},
// z: one formatted vector of quality z scores per tile
const auto format1 = [](const auto &c) {
// ADS: note the format and precision (3) here
// NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.UninitializedObject)
return fmt::format("[{:.3f}]", fmt::join(c, ",")); // inner lists
};
const auto z = std::views::transform(centered | std::views::values, format1);
Expand Down Expand Up @@ -448,10 +450,16 @@ y: [{}],
type: "line",
name: "{}",
}})";
const auto grade = grades.grade(label);
const auto title = grades.get_title(label);
if (results.empty())
return fmt::format(
html_module_fmt, grade, label, title, grade,
R"(<div id="kmer_plot"></div>\n<div>No overrepresented kmers</div>)");
const auto get_pos = [&](const auto &x) { return x.pos; };
const auto xlim = std::ranges::max(std::views::transform(results, get_pos));
auto mostly0 = std::vector(xlim, 0.0); // change one position each kmer
const auto xvals = std::views::iota(0u, xlim);
auto mostly0 = std::vector(xlim + 1, 0.0); // change one position each kmer
const auto xvals = std::views::iota(0U, xlim + 1);
auto prev = 0;
const auto format1 = [&](const auto &k) {
// x: positions in read; y: zeros except at 'pos' for the kmer
Expand All @@ -461,14 +469,11 @@ name: "{}",
return fmt::format(kmer_line_format, fmt::join(xvals, ", "),
fmt::join(mostly0, ", "), k.decode());
};
const auto grade = grades.grade(label);
const auto title = grades.get_title(label);
// NOLINTBEGIN(clang-analyzer-optin.cplusplus.UninitializedObject)
// NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.UninitializedObject)
return fmt::format(
html_module_fmt, grade, label, title, grade,
fmt::format(
plot_format,
fmt::format("[{}]",
fmt::join(std::views::transform(results, format1), ",\n"))));
// NOLINTEND(clang-analyzer-optin.cplusplus.UninitializedObject)
}
2 changes: 1 addition & 1 deletion src/kmer_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ kmer_counter::decode_kmer(auto word, const auto n_bases) -> std::string {
[[nodiscard]] auto
get_grade_kmer(const std::vector<kmer_result> &results) -> std::string {
static constexpr auto label = "kmer";
const auto pval = results.front().pval;
const auto pval = results.empty() ? 1.0 : results.front().pval;
const auto neg_log_p_val =
pval > 0.0 ? -std::log10(pval) : std::numeric_limits<double>::max();
return grader_set::get_grade(label, neg_log_p_val);
Expand Down
8 changes: 2 additions & 6 deletions src/results_summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,8 @@ results_summary::get_report() const -> std::string {
if (mode.do_gc_content())
sections.emplace("gc_sequence", gc_sequence_report(gc_content, grades));

if (mode.do_kmers()) {
assert(!kmer_results.empty());
if (mode.do_kmers())
sections.emplace("kmer", kmer_report(kmer_results, grades));
}

if (mode.do_length())
sections.emplace("sequence_length",
Expand Down Expand Up @@ -201,10 +199,8 @@ results_summary::get_html() -> std::string {
if (mode.do_gc_content())
sections.emplace("gc_sequence", gc_sequence_html(gc_content, grades));

if (mode.do_kmers()) {
assert(!kmer_results.empty());
if (mode.do_kmers())
sections.emplace("kmer", kmer_html(kmer_results, grades));
}

if (mode.do_length())
sections.emplace("sequence_length", sequence_length_html(lengths, grades));
Expand Down
Loading