Skip to content

Commit

Permalink
Allow the BED reader to split on tabs and spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
clintval committed Mar 26, 2024
1 parent 674567c commit ca6c6fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pybedlite/bed_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def parse_rgb(x: str) -> Tuple[int, int, int]:
continue
if line.strip() == "":
continue
fields = line.strip().split("\t")
fields = line.strip().split()
assert len(fields) >= 3, (
"BED records must conform to specifications, which requires at least 3 input "
+ f"fields. On line {i} in {self._path} had only {len(fields)} fields"
Expand Down
10 changes: 8 additions & 2 deletions pybedlite/tests/test_pybedlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
# Test header, with a line with whitespace below it.
# More header
# BED record with tabs as a separator
1 100 150 test_record1 100 + 100 100 0,0,0 1 50 0
1 200 300 test_record2 100 - 210 290 0,0,0 1 100 0
2 200 300 test_record3 . . . . . . . .
# BED record with spaces as a separator
1 200 300 test_record2 100 - 210 290 0,0,0 1 100 0
# BED record with a mix of spaces and tabs as a separator
2 200 300 test_record3 . . . . . . . .
"""


Expand Down

0 comments on commit ca6c6fa

Please sign in to comment.