Skip to content

Commit

Permalink
Improve liftover error message
Browse files Browse the repository at this point in the history
  • Loading branch information
nictru committed Aug 22, 2024
1 parent e4da932 commit 778a9c9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion easyliftover/liftover.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_class(c_type):
for lifter in lifters:
if c_type in lifter.supported_formats():
return lifter
raise Exception("Unsupported file type")
raise Exception("Unsupported file type: " + c_type)

def __get_type(path: str) -> str:
return path.split(".")[-1]
Expand Down
43 changes: 29 additions & 14 deletions test/test_lifters.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
from easyliftover import *

def __test__(clazz, assembly1: str, assembly2: str, path_assembly1: str, path_assembly2: str):

def __test__(
clazz, assembly1: str, assembly2: str, path_assembly1: str, path_assembly2: str
):
content_assembly1 = open(path_assembly1).read()
content_assembly2 = open(path_assembly2).read()

lifter: AbstractLifter = clazz(assembly1, assembly2)
reversed_lifter: AbstractLifter = clazz(assembly2, assembly1)

assert lifter.lift_path(path_assembly1) == content_assembly2
assert reversed_lifter.lift_path(path_assembly2) == content_assembly1


def test_bed():
__test__(BedLifter, 'hg19', 'hg38', 'test/data/hg19.bed', 'test/data/hg38.bed')

__test__(BedLifter, "hg19", "hg38", "test/data/hg19.bed", "test/data/hg38.bed")


def test_vcf():
__test__(VcfLifter, 'hg19', 'hg38', 'test/data/hg19.vcf', 'test/data/hg38.vcf')

__test__(VcfLifter, "hg19", "hg38", "test/data/hg19.vcf", "test/data/hg38.vcf")


def test_gff():
__test__(GffLifter, 'hg19', 'hg38', 'test/data/hg19.gff', 'test/data/hg38.gff')

__test__(GffLifter, "hg19", "hg38", "test/data/hg19.gff", "test/data/hg38.gff")


def test_wig():
__test__(WigLifter, 'hg19', 'hg38', 'test/data/hg19.wig', 'test/data/hg38.wig')

__test__(WigLifter, "hg19", "hg38", "test/data/hg19.wig", "test/data/hg38.wig")


def test_bedgraph():
__test__(BedGraphLifter, 'hg19', 'hg38', 'test/data/hg19.bedgraph', 'test/data/hg38.bedgraph')
__test__(
BedGraphLifter,
"hg19",
"hg38",
"test/data/hg19.bedgraph",
"test/data/hg38.bedgraph",
)


#def test_bigwig():
# def test_bigwig():
# lifter = BigWigLifter('hg38', 'hg19')
#
#
# assert lifter.lift_url('https://github.com/deeptools/pyBigWig/raw/master/pyBigWigTest/test.bw') == ""
# assert lifter.lift_path('test/data/hg38.bw') == ""
# assert lifter.lift_path('test/data/hg38.bw') == ""

0 comments on commit 778a9c9

Please sign in to comment.