Skip to content

Commit

Permalink
Remove comment lines while parsing seqids (thanks @Pedicularis1kib, #676
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tanghaibao committed Jun 28, 2024
1 parent 2eae789 commit 92aa50a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions jcvi/graphics/karyotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ def __init__(
fp = open(seqidsfile)
# Strip the reverse orientation tag for e.g. chr3-
di = lambda x: x[:-1] if x[-1] == "-" else x
for i, row in enumerate(fp):
if row[0] == "#":
continue
# 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("#")):
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_comments
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#aa
chr1,chr2,chr3,chr4,chr5,chr6,chr7,chr8,chr9,chr10,chr11,chr12,chr13,chr14,chr15,chr16,chr17,chr18,chr19
#bb
#cc
Pp01,Pp02,Pp03,Pp04,Pp05,Pp06,Pp07,Pp08
#dd
5 changes: 5 additions & 0 deletions tests/graphics/test_karyotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ def test_main():
cleanup("karyotype.pdf")
image_name = karyotype_main(["seqids", "layout"])
assert op.exists(image_name)
cleanup("karyotype_with_comments.pdf")
image_name = karyotype_main(
["seqids_with_comments", "layout", "-o", "karyotype_with_comments.pdf"]
)
assert op.exists(image_name)
os.chdir(cwd)

0 comments on commit 92aa50a

Please sign in to comment.