Options
+
+
+
+
+ Traverse the graph from a segmentSegment name from which to begin the traversal
-
-
-
- Path range, in path[:pos1[-pos2]] format, from which to begin the traversal
- The number of segments away from the initial segments to traverse
-
-
+
+
+ Extract segments in path range
+
+
+
+ Extract segments in PATH_RANGE, specified in the path[:pos1[-pos2]] format. pos1 and pos2 are 0-based coordinates. The extracted segments include pos1 (inclusive) but not pos2 (exclusive).
+
diff --git a/domagi/domagi.py b/domagi/domagi.py
index 2aba383..e2bf457 100644
--- a/domagi/domagi.py
+++ b/domagi/domagi.py
@@ -226,34 +226,27 @@ def depth(con, graph_depth_table, paths, bed_input, threads, progress):
@click.option("-c", "--context-steps", "steps",
type=click.INT,
# TODO: Add default=0
- required=True,
help="number of traversal steps")
@common_options
def extract(con, outfile, segment_name, path_range, steps, threads, progress):
set_duckdb_threads(con, threads)
with connect_duckdb(outfile, threads) as out_con:
out_con.execute(read_sql("schema.sql"))
- if segment_name:
- con.execute("""
- CREATE TEMPORARY TABLE initial_segment AS
- SELECT id FROM segment WHERE segment.name=?
- """,
- [segment_name])
- elif path_range:
- # TODO: We're assuming the interval is [start, end) rather
- # than [start, end]. But check what odgi does.
+ if path_range:
+ path, start, end = re.match(r"^([^:]*):(\d+)-(\d+)", path_range).groups()
con.execute("""
- CREATE TEMPORARY TABLE initial_segment AS
+ CREATE TEMPORARY TABLE selected_segment AS
SELECT segment_id AS id
FROM path_segment
INNER JOIN path ON path.id=path_segment.path_id
- WHERE path.name=? AND start>=? AND start;
+ WHERE path.name=$1 AND path_segment.start<$3 AND $2