diff --git a/jcvi/graphics/karyotype.py b/jcvi/graphics/karyotype.py index 0ce97d43..42bcb634 100644 --- a/jcvi/graphics/karyotype.py +++ b/jcvi/graphics/karyotype.py @@ -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 diff --git a/tests/graphics/data/seqids_with_empty_lines b/tests/graphics/data/seqids_with_empty_lines new file mode 100644 index 00000000..29ee8e3f --- /dev/null +++ b/tests/graphics/data/seqids_with_empty_lines @@ -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 + diff --git a/tests/graphics/test_karyotype.py b/tests/graphics/test_karyotype.py index 78b5a6cb..15b13e41 100644 --- a/tests/graphics/test_karyotype.py +++ b/tests/graphics/test_karyotype.py @@ -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)