Skip to content

Commit

Permalink
add test for #213
Browse files Browse the repository at this point in the history
  • Loading branch information
daler committed Jul 4, 2023
1 parent 20a9102 commit a4b443b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions gffutils/test/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,40 @@ def _check(txt, expected_keys, dialect_trailing_semicolon):
],
dialect_trailing_semicolon=False,
)


def test_issue_213():
# GFF header directives seem to be not parsed when building a db from
# a file, even though it seems to work fine from a string.
data = dedent(
"""
##gff-version 3
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
"""
)

# Ensure directives are parsed from DataIterator
it = gffutils.iterators.DataIterator(data, from_string=True)
assert it.directives == ["gff-version 3"]


# Ensure they're parsed into the db from a string
db = gffutils.create_db(data, dbfn=":memory:", from_string=True, verbose=False)
assert db.directives == ["gff-version 3"], db.directives

# Ensure they're parsed into the db from a file
tmp = tempfile.NamedTemporaryFile(delete=False).name
with open(tmp, "w") as fout:
fout.write(data + "\n")
db = gffutils.create_db(tmp, ":memory:")
assert db.directives == ["gff-version 3"], db.directives
assert len(db.directives) == 1

# Ensure they're parsed into the db from a file, and going to a file (to
# exactly replicate example in #213)
db = gffutils.create_db(tmp, dbfn='issue_213.db', force=True)
assert db.directives == ["gff-version 3"], db.directives
assert len(db.directives) == 1

0 comments on commit a4b443b

Please sign in to comment.