Skip to content

Commit

Permalink
Allow bed format to contain browser/track headers (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao authored Aug 4, 2024
1 parent afb7b2d commit d6be631
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
7 changes: 4 additions & 3 deletions jcvi/formats/bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ def __init__(self, filename=None, key=None, sorted=True, juncs=False, include=No

for line in must_open(filename):
if (
line[0] == "#"
or (juncs and line.startswith("track name"))
or line.strip() == ""
line.strip() == ""
or line[0] == "#"
or line.startswith("browser ")
or line.startswith("track name")
):
continue
b = BedLine(line)
Expand Down
10 changes: 10 additions & 0 deletions tests/formats/data/custom.bed
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
browser position chr7:4499924-4500043
track name="Covered" description="Agilent SureSelect DNA - Custom Exome_1 - Genomic regions expected to be sequenced" color=0,128,0 visibility=dense db=hg38
chr7 4499923 4500043 7P22.1
chr7 4500475 4501075 7P22.1
chr7 4501706 4501844 7P22.1
chr7 4503679 4503919 7P22.1
chr7 4504362 4505023 7P22.1
chr7 4505688 4505990 7P22.1
chr7 4506376 4506496 7P22.1
chr7 4506928 4507768 7P22.1
10 changes: 10 additions & 0 deletions tests/formats/test_bed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os
import os.path as op

from jcvi.formats.bed import summary

def test_summary():
cwd = os.getcwd()
os.chdir(op.join(op.dirname(__file__), "data"))
summary(["custom.bed"])
os.chdir(cwd)

0 comments on commit d6be631

Please sign in to comment.