Skip to content

Commit

Permalink
updated filetypes and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simonvh committed Jun 12, 2017
1 parent f0ecd14 commit 9a4be0b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions fluff/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def __init__(self, fname, **kwargs):
self.rmrepeats = kwargs.get("rmrepeats", False)
self.fragmentsize = kwargs.get("fragmentsize", None)

if fname.endswith("bam"):
if fname.split(".")[-1] in self._filetypes:
self.track = pysam.AlignmentFile(fname, "rb")
self.ftype = "bam"
self.chroms = self.track.references
Expand Down Expand Up @@ -644,7 +644,7 @@ class WigTrack(Track):
def __init__(self, fname, **kwargs):
self.fname = fname

if fname.endswith("bg") or fname.endswith("wig"):
if fname.split(".")[-1] in self._filetypes:
self.track = pybedtools.BedTool(fname)
self.ftype = "wig"
else:
Expand Down Expand Up @@ -749,7 +749,7 @@ class BigWigTrack(Track):
_filetypes = ["bw", "bigWig"]

def __init__(self, fname, **kwargs):
if fname.endswith("bw"):
if fname.split(".")[-1] in self._filetypes:
self.track = pyBigWig.open(fname)
self.ftype = "bw"
else:
Expand Down
16 changes: 16 additions & 0 deletions tests/data/profile.bedGraph
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
scaffold_1 14750061 14750067 1
scaffold_1 44749422 44749429 1
scaffold_1 44749429 44749457 2
scaffold_1 44749457 44749464 1
scaffold_1 44749713 44749748 1
scaffold_1 44749845 44749868 1
scaffold_1 44749868 44749880 2
scaffold_1 44749880 44749903 1
scaffold_1 44749934 44749938 1
scaffold_1 44749938 44749969 2
scaffold_1 44749969 44749973 1
scaffold_1 44749994 44750026 1
scaffold_1 44750026 44750029 2
scaffold_1 44750029 44750032 1
scaffold_1 44750032 44750061 2
scaffold_1 44750061 44750067 1
Binary file added tests/data/profile.bigWig
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@pytest.fixture
def tracks():
ftypes = ["bam", "bed", "wig", "bg", "bw", "wig.gz", "bg.gz"]#, "bed.gz"]
ftypes = ["bam", "bed", "wig", "bg", "bw", "wig.gz", "bg.gz", "bigWig", "bedGraph"]#, "bed.gz"]
my_tracks = []
for ftype in ftypes:
fname = "tests/data/profile." + ftype
Expand Down

0 comments on commit 9a4be0b

Please sign in to comment.