Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove comment lines while parsing seqids (thanks @Pedicularis1kib, #676) #682

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading