Skip to content

Commit

Permalink
Set sensible defaults for one/zero based coords
Browse files Browse the repository at this point in the history
  • Loading branch information
robomics committed Dec 7, 2023
1 parent af0644c commit 3c48ee3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/hictk/cli/cli_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ void Cli::make_load_subcommand() {
sc.add_flag(
"--one-based,!--zero-based",
c.one_based,
"Interpret genomic coordinates or bins as one/zero based.");
"Interpret genomic coordinates or bins as one/zero based.\n"
"By default coordinates are assumed to be one-based for interactions in\n"
"4dn and validapairs formats and zero-based otherwise.");

sc.add_flag(
"--count-as-float",
Expand Down Expand Up @@ -152,8 +154,15 @@ void Cli::validate_load_subcommand() const {

void Cli::transform_args_load_subcommand() {
auto& c = std::get<LoadConfig>(_config);
const auto& sc = *_cli.get_subcommand("load");

c.offset = c.one_based ? -1 : 0;
if (sc.get_option("--one-based")->empty()) {
if (c.format == "4dn" || c.format == "validpairs") {
c.offset = -1;
}
} else {
c.offset = c.one_based ? -1 : 0;
}

// in spdlog, high numbers correspond to low log levels
assert(c.verbosity > 0 && c.verbosity < 5);
Expand Down
2 changes: 0 additions & 2 deletions test/scripts/hictk_load_coo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ if [[ "$sorted" == true ]]; then
--assume-sorted \
--batch-size 1000000 \
--bin-size 10000 \
--zero-based \
"$outdir/chrom.sizes" \
"$outdir/out.cool"
else
Expand All @@ -120,7 +119,6 @@ else
--assume-unsorted \
--batch-size 1000000 \
--bin-size 10000 \
--zero-based \
"$outdir/chrom.sizes" \
"$outdir/out.cool"
fi
Expand Down

0 comments on commit 3c48ee3

Please sign in to comment.