Skip to content

Commit

Permalink
Merge pull request #6 from schorlton/main
Browse files Browse the repository at this point in the history
Parse CS tag correctly
  • Loading branch information
alexomics authored Dec 31, 2021
2 parents 47f363f + 33c902a commit 0436917
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions readpaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__all__ = ["parse_paf"]

__version__ = "0.0.8"
__version__ = "0.0.9"

try:
import pandas as pd
Expand Down Expand Up @@ -95,7 +95,7 @@ def _parse_tags(tags):
"""
return {
tag: SAM_TAG(tag, type_, SAM_TYPES.get(type_, lambda x: x)(val))
for tag, type_, val in (x.split(":") for x in tags)
for tag, type_, val in (x.split(":", 2) for x in tags)
}


Expand Down
7 changes: 7 additions & 0 deletions tests/test_readpaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ def test_tag_suffix_dataframe():
assert set(df.columns) == set(cols + ["tp_tag"]), "Tag field not set correctly"


def test_cs_tag_parsing():
_rec = "a7208cb4-133c-4ab9-96fe-db8630f4d9bb\t373\t15\t368\t+\tEf_genome\t2845392\t586028\t586405\t103\t377\t60\ttp:A:P\tcs:Z::6-ata:10+gtc:4*at:3\n"
PAF_IO = StringIO(_rec)
for rec in parse_paf(PAF_IO):
assert rec.tags["cs"].value == ":6-ata:10+gtc:4*at:3", "cs tag didn't match"


def test_read_uncompressed():
c = 0
with open(PAF_FILE, "r") as fh:
Expand Down

0 comments on commit 0436917

Please sign in to comment.