Skip to content

Commit

Permalink
fix coverage with custom cols1 (#170)
Browse files Browse the repository at this point in the history
* fix coverage with custom cols1

* add requested test for custom column names in coverage

* updates from main (#177)
  • Loading branch information
sergpolly authored Dec 22, 2023
1 parent 5affbc6 commit 6ffeb6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bioframe/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ def coverage(
cols2=cols2,
)

df_overlap["overlap"] = df_overlap["overlap_end"] - df_overlap["overlap_start"]
df_overlap["overlap"] = df_overlap[f"overlap_{ek1}"] - df_overlap[f"overlap_{sk1}"]

out_df = (
pd.DataFrame(
Expand Down
13 changes: 13 additions & 0 deletions tests/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,19 @@ def test_coverage():
df = pd.read_csv(StringIO(d), sep=r"\s+")
pd.testing.assert_frame_equal(df, bioframe.coverage(df1, df2))

### with custom column names
cols1 = ["chromosome", "begin", "stop"]
cols2 = ["chr", "cluster_start", "cluster_end"]
df1 = pd.DataFrame([["chr1", 3, 8]], columns=cols1)
df2 = pd.DataFrame([["chr1", 3, 8]], columns=cols2)
d = """chromosome begin stop coverage
0 chr1 3 8 5"""
df = pd.read_csv(StringIO(d), sep=r"\s+")
pd.testing.assert_frame_equal(
df,
bioframe.coverage(df1, df2, cols1=cols1, cols2=cols2)
)

### coverage of NA interval returns zero for coverage
df1 = pd.DataFrame(
[
Expand Down

0 comments on commit 6ffeb6d

Please sign in to comment.