about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2026-08-14 22:09:21 +0100
committerArun Isaac2026-08-15 20:53:15 +0100
commita7806b70c6d651acfdbbaeaa986b4bd28f1d685a (patch)
treec2f18c4ddfbb1564b19593815d994929dfdee2d7
parentbc371f2374156b7f6593ef0287bfb52b478ed92e (diff)
downloaddomagi-a7806b70c6d651acfdbbaeaa986b4bd28f1d685a.tar.gz
domagi-a7806b70c6d651acfdbbaeaa986b4bd28f1d685a.tar.lz
domagi-a7806b70c6d651acfdbbaeaa986b4bd28f1d685a.zip
Add domagi overlap --paths.
-rw-r--r--doc/domagi-overlap.dbk5
-rw-r--r--domagi/domagi.py8
-rw-r--r--tests/test_domagi.py17
3 files changed, 29 insertions, 1 deletions
diff --git a/doc/domagi-overlap.dbk b/doc/domagi-overlap.dbk
index e8e40e7..657e664 100644
--- a/doc/domagi-overlap.dbk
+++ b/doc/domagi-overlap.dbk
@@ -13,6 +13,11 @@
         <term><option>--path=<replaceable>PATH</replaceable></option></term>
         <listitem><para>Find paths touched by <replaceable>PATH</replaceable>. This argument may be specified more than once to find paths touched by more than one path.</para></listitem>
       </varlistentry>
+      <varlistentry>
+        <term><option>-R <replaceable>FILE</replaceable></option></term>
+        <term><option>--paths=<replaceable>FILE</replaceable></option></term>
+        <listitem><para>Find paths touched by paths listed in <replaceable>FILE</replaceable>, one per line.</para></listitem>
+      </varlistentry>
       <xi:include href="threads-argument.dbk" />
       <xi:include href="help-option.dbk" />
     </variablelist>
diff --git a/domagi/domagi.py b/domagi/domagi.py
index faa7429..77d28b9 100644
--- a/domagi/domagi.py
+++ b/domagi/domagi.py
@@ -267,9 +267,15 @@ def matrix(con, threads):
               multiple=True,
               metavar="PATH",
               help="find paths touched by PATH")
+@click.option("-R", "--paths", "paths_file",
+              type=click.File(),
+              metavar="FILE",
+              help="find paths touched by paths listed in FILE")
 @common_options
-def overlap(con, paths, threads):
+def overlap(con, paths, paths_file, threads):
     set_duckdb_threads(con, threads)
+    if paths_file:
+        paths = [line.rstrip() for line in paths_file.readlines()]
     (con.execute(read_sql("overlap.sql"), [paths])
      .fetchdf()
      .to_csv(sys.stdout, sep="\t", index=False))
diff --git a/tests/test_domagi.py b/tests/test_domagi.py
index d678a3f..757d1ec 100644
--- a/tests/test_domagi.py
+++ b/tests/test_domagi.py
@@ -214,6 +214,23 @@ def test_domagi_overlap(tmp_path, test_data_file, expected_output):
                        .sort_values(by=["#path", "path.touched"],
                                     ignore_index=True),
                        check_dtype=False)
+    # Test passing in the paths through a file.
+    paths_file = tmp_path / "paths"
+    with open(paths_file, "w") as file:
+        for path in paths:
+            print(path, file=file)
+    result = runner.invoke(main, ["overlap",
+                                  "--db", duckdb_path,
+                                  "--paths", paths_file])
+    assert result.exit_code == 0
+    assert_frame_equal(pd.read_csv(expected_output, sep="\t")
+                       .sort_values(by=["#path", "path.touched"],
+                                    ignore_index=True),
+                       pd.read_csv(io.StringIO(result.stdout),
+                                   sep="\t")
+                       .sort_values(by=["#path", "path.touched"],
+                                    ignore_index=True),
+                       check_dtype=False)
 
 @pytest.mark.parametrize("test_data_file, expected_output",
                          [(Path("test-data/test1.gfa"),