Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c99c3eb
src/radmeth/radmeth_optimize.cpp: added an implementation for digamma…
andrewdavidsmith Oct 13, 2025
72374ed
Makefile.am: adding additional sources
andrewdavidsmith Oct 15, 2025
81bd7ad
src/dnmtools.cpp: adding the radmeth-nano command for doing DMPs on n…
andrewdavidsmith Oct 15, 2025
bd30df2
src/radmeth/radmeth_design.hcpp: adding files for the Design class se…
andrewdavidsmith Oct 15, 2025
3b3b79b
../src/radmeth/radmeth_model_nano.hcpp: adding files for the Regressi…
andrewdavidsmith Oct 15, 2025
da61e8d
../src/radmeth/radmeth_optimize_nano.hcpp: adding optimization code i…
andrewdavidsmith Oct 15, 2025
45af7a8
src/radmeth/radmeth_utils.hcpp: adding files for common functions sha…
andrewdavidsmith Oct 15, 2025
392ab7f
src/radmeth/radmeth.cpp: factoring out code shared by radmeth and rad…
andrewdavidsmith Oct 15, 2025
99e696a
src/radmeth/radmeth_model.hcpp: moving Design-related code to a sepa…
andrewdavidsmith Oct 15, 2025
cde6b33
src/radmeth/radmeth_optimize.cpp: adding back the code for the discre…
andrewdavidsmith Oct 15, 2025
639aa0c
src/radmeth/radmeth_nano.cpp: adding this file, forgotten previously,…
andrewdavidsmith Oct 16, 2025
be62144
src/radmeth/radmeth_optimize.cpp and _nano.cpp: adding a const
andrewdavidsmith Oct 17, 2025
5830de3
src/radmeth/radmeth_nano.cpp: minor cleanup
andrewdavidsmith Oct 17, 2025
d9ab669
src/radmeth/radmeth.cpp: ensuring the reported model design for the a…
andrewdavidsmith Oct 17, 2025
07dc1fd
src/radmeth/radmeth_nano.cpp: ensuring the reported model design for …
andrewdavidsmith Oct 17, 2025
b53c7ba
src/radmeth/radmeth_optimize_nano.cpp: making the chebyschev approx f…
andrewdavidsmith Oct 17, 2025
780ebc2
src/radmeth/radmeth_optimize.cpp: minor tweaks for speed and clarity
andrewdavidsmith Oct 17, 2025
bc71c53
src/radmeth/radmeth_model.cpp: removed during renaming
andrewdavidsmith Oct 20, 2025
001adb2
src/radmeth/radmeth_optimize.hcpp: renamed
andrewdavidsmith Oct 20, 2025
6c7a2f9
src/radmeth/radmeth_optimize_series.hcpp: renamed
andrewdavidsmith Oct 20, 2025
7b69ce5
src/radmeth/radmeth_optimize_gamma.hcpp: renamed and adding non-gradi…
andrewdavidsmith Oct 20, 2025
3be1c88
src/radmeth/radmeth_optimize_nano.hcpp: removed during renaming
andrewdavidsmith Oct 20, 2025
65a86ea
src/radmeth/radmeth_optimize_params.hpp: moving params in namespace
andrewdavidsmith Oct 20, 2025
b27869b
src/radmeth/radmeth_model.hpp: collapsing the Regression model classe…
andrewdavidsmith Oct 20, 2025
086f58a
src/radmeth/radmeth.cpp: update to use template for Regression class
andrewdavidsmith Oct 20, 2025
8e5d464
src/radmeth/radmeth_nano.cpp: update to use template on Regression cl…
andrewdavidsmith Oct 20, 2025
b893e22
src/radmeth/radmeth_model_nano.hcpp: removing due to collapse into te…
andrewdavidsmith Oct 20, 2025
cba7966
Makefile.am: updates for (ongoing) change to names of radmeth sources
andrewdavidsmith Oct 20, 2025
2541eed
src/radmeth/radmeth_optimize_series.cpp: cleaning up junk code left i…
andrewdavidsmith Oct 20, 2025
7a75574
src/radmeth/radmeth_optimize_series.cpp: cleaning more junk code
andrewdavidsmith Oct 20, 2025
f4b6121
src/radmeth/radmeth_optimize_gamma.cpp: making bfgs2 the default and …
andrewdavidsmith Oct 20, 2025
0340295
src/radmeth/radmeth.cpp and radmeth_nano.cpp: making these two source…
andrewdavidsmith Oct 20, 2025
205676e
macOS clang fixes: from_chars for float to sscanf and sprintf to snpr…
andrewdavidsmith Oct 22, 2025
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
15 changes: 11 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,12 @@ libdnmtools_a_SOURCES += \
# ADS: additional radmeth sources to help isolate the parts using GSL for
# optimization
libdnmtools_a_SOURCES += \
src/radmeth/radmeth_optimize.hpp \
src/radmeth/radmeth_model.hpp
src/radmeth/radmeth_optimize_series.hpp \
src/radmeth/radmeth_optimize_gamma.hpp \
src/radmeth/radmeth_optimize_params.hpp \
src/radmeth/radmeth_model.hpp \
src/radmeth/radmeth_utils.hpp \
src/radmeth/radmeth_design.hpp

LDADD = libdnmtools.a src/abismal/libabismal.a src/smithlab_cpp/libsmithlab_cpp.a

Expand Down Expand Up @@ -236,9 +240,12 @@ dnmtools_SOURCES += src/amrfinder/amrtester.cpp

dnmtools_SOURCES += src/radmeth/dmr.cpp
dnmtools_SOURCES += src/radmeth/methdiff.cpp
dnmtools_SOURCES += src/radmeth/radmeth_optimize.cpp
dnmtools_SOURCES += src/radmeth/radmeth_model.cpp
dnmtools_SOURCES += src/radmeth/radmeth_utils.cpp
dnmtools_SOURCES += src/radmeth/radmeth_optimize_series.cpp
dnmtools_SOURCES += src/radmeth/radmeth_optimize_gamma.cpp
dnmtools_SOURCES += src/radmeth/radmeth_design.cpp
dnmtools_SOURCES += src/radmeth/radmeth.cpp
dnmtools_SOURCES += src/radmeth/radmeth_nano.cpp
dnmtools_SOURCES += src/radmeth/radmeth-adjust.cpp
dnmtools_SOURCES += src/radmeth/radmeth-merge.cpp

Expand Down
38 changes: 22 additions & 16 deletions src/analysis/nanopore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,8 @@ struct read_processor {
if (chrom_name == nullptr)
throw std::runtime_error("failed to identify chrom for tid: " +
std::to_string(tid));
const auto chrom_name_offset = std::sprintf(buffer, "%s\t", chrom_name);
const auto chrom_name_offset =
std::snprintf(buffer, buf_size, "%s\t", chrom_name);
if (chrom_name_offset < 0)
throw std::runtime_error("failed to write to output buffer");
auto buffer_after_chrom = buffer + chrom_name_offset;
Expand All @@ -869,14 +870,16 @@ struct read_processor {
const double mods = counts[chrom_posn].get_mods(is_c) / denom;

// clang-format off
const int r = std::sprintf(buffer_after_chrom, out_fmt,
chrom_posn,
is_c ? '+' : '-',
tag_values[the_tag],
mods,
n_reads,
hydroxy,
methyl);
const int r = std::snprintf(buffer_after_chrom,
buf_size - chrom_name_offset,
out_fmt,
chrom_posn,
is_c ? '+' : '-',
tag_values[the_tag],
mods,
n_reads,
hydroxy,
methyl);
// clang-format on

if (r < 0)
Expand All @@ -900,7 +903,8 @@ struct read_processor {
if (chrom_name == nullptr)
throw std::runtime_error("failed to identify chrom for tid: " +
std::to_string(tid));
const auto chrom_name_offset = std::sprintf(buffer, "%s\t", chrom_name);
const auto chrom_name_offset =
std::snprintf(buffer, buf_size, "%s\t", chrom_name);
if (chrom_name_offset < 0)
throw std::runtime_error("failed to write to output buffer");
auto buffer_after_chrom = buffer + chrom_name_offset;
Expand Down Expand Up @@ -935,12 +939,14 @@ struct read_processor {
const auto mods = hydroxy + methyl;

// clang-format off
const int r = std::sprintf(buffer_after_chrom, out_fmt,
chrom_posn - 1, // for previous position
mods,
n_reads,
hydroxy,
methyl);
const int r = std::snprintf(buffer_after_chrom,
buf_size - chrom_name_offset,
out_fmt,
chrom_posn - 1, // for previous position
mods,
n_reads,
hydroxy,
methyl);
// clang-format on

if (r < 0)
Expand Down
3 changes: 3 additions & 0 deletions src/dnmtools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ main_radmeth_adjust(int argc, char *argv[]);
int
main_radmeth(int argc, char *argv[]);
int
main_radmeth_nano(int argc, char *argv[]);
int
main_radmeth_merge(int argc, char *argv[]);
int
main_clean_hairpins(int argc, char *argv[]);
Expand Down Expand Up @@ -204,6 +206,7 @@ main(int argc, char *argv[]) {
{{{"dmr", "identify DMRs from genomic intervals and single-CpG DM probabilities", main_dmr},
{"diff", "compute single-CpG DM probability between two methylomes", main_methdiff},
{"radmeth", "compute DM probabilities for each CpG using multiple methylomes", main_radmeth},
{"radmeth-nano", "radmeth designed for nanopore data", main_radmeth_nano},
{"radadjust", "adjust p-values from radmeth output", main_radmeth_adjust},
{"radmerge", "merge significant CpGs in radmeth output", main_radmeth_merge}}}},

Expand Down
20 changes: 10 additions & 10 deletions src/radmeth/methdiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ write_methdiff_site(T &out, const MSite &a, const MSite &b,
static char buffer[buf_size];

// clang-format off
const int r = std::sprintf(buffer, out_fmt,
a.chrom.data(),
a.pos,
a.strand,
a.context.data(),
diffscore,
a.n_meth(),
a.n_unmeth(),
b.n_meth(),
b.n_unmeth());
const int r = std::snprintf(buffer, buf_size, out_fmt,
a.chrom.data(),
a.pos,
a.strand,
a.context.data(),
diffscore,
a.n_meth(),
a.n_unmeth(),
b.n_meth(),
b.n_unmeth());
// clang-format on
if (r < 0)
throw std::runtime_error("failed to write to output buffer");
Expand Down
Loading
Loading