Skip to content

Commit 03ec186

Browse files
committed
fix bug in in memory tab reader
1 parent 2c5ce9a commit 03ec186

File tree

1 file changed

+11
-8
lines changed
  • coolbox/utilities/reader

1 file changed

+11
-8
lines changed

coolbox/utilities/reader/tab.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,20 +317,23 @@ def query(
317317
'end2': 'end2',
318318
}
319319

320-
if open_region:
321-
second = gr
322-
323-
if (second is not None) or open_region:
320+
if second is not None:
324321
sdf = self.df.query(
325322
f"{field_names['chrom1']} == '{gr.chrom}' and {field_names['start1']} >= {gr.start} and {field_names['end1']} <= {gr.end} "
326323
f"and {field_names['chrom2']} == '{second.chrom}' and {field_names['start2']} >= {second.start} and {field_names['end2']} <= {second.end}"
327324
)
328325
return sdf
329326
else:
330-
sdf = self.df.query(
331-
f"{field_names['chrom1']} == '{gr.chrom}' and {field_names['start1']} >= {gr.start} and {field_names['end1']} <= {gr.end} "
332-
f"and {field_names['chrom2']} == '{gr.chrom}"
333-
)
327+
if open_region:
328+
sdf = self.df.query(
329+
f"{field_names['chrom1']} == '{gr.chrom}' and {field_names['start1']} >= {gr.start} and {field_names['end1']} <= {gr.end} "
330+
f"and {field_names['chrom2']} == '{gr.chrom}"
331+
)
332+
else:
333+
sdf = self.df.query(
334+
f"{field_names['chrom1']} == '{gr.chrom}' and {field_names['start1']} >= {gr.start} and {field_names['end1']} <= {gr.end} "
335+
f"and {field_names['chrom2']} == '{gr.chrom}' and {field_names['start2']} >= {gr.start} and {field_names['end2']} <= {gr.end}"
336+
)
334337
return sdf
335338
else:
336339
chrom_str = 'chrom'

0 commit comments

Comments
 (0)