Skip to content

Commit

Permalink
Ignore empty lines in seqids file
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Jul 10, 2024
1 parent 443ec52 commit 4fe0bf4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion jcvi/graphics/karyotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ def __init__(
di = lambda x: x[:-1] if x[-1] == "-" else x
# Comments can cause layout and seqids to be out of sync
# https://github.com/tanghaibao/jcvi/issues/676
for i, row in enumerate(_ for _ in fp if not _.startswith("#")):
for i, row in enumerate(_ for _ in fp if not _.startswith("#") and _.strip()):
logger.info("Processing `%s` (track %d)", row.strip(), i)
t = layout[i]
# There can be comments in seqids file:
# https://github.com/tanghaibao/jcvi/issues/335
Expand Down
6 changes: 6 additions & 0 deletions tests/graphics/data/seqids_with_empty_lines
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


chr1,chr2,chr3,chr4,chr5,chr6,chr7,chr8,chr9,chr10,chr11,chr12,chr13,chr14,chr15,chr16,chr17,chr18,chr19

Pp01,Pp02,Pp03,Pp04,Pp05,Pp06,Pp07,Pp08

4 changes: 4 additions & 0 deletions tests/graphics/test_karyotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ def test_main():
["seqids_with_comments", "layout", "-o", "karyotype_with_comments.pdf"]
)
assert op.exists(image_name)
cleanup("karyotype_with_empty_lines.pdf")
image_name = karyotype_main(
["seqids_with_empty_lines", "layout", "-o", "karyotype_with_empty_lines.pdf"]
)
os.chdir(cwd)

0 comments on commit 4fe0bf4

Please sign in to comment.