Merge pull request #678 from kaizhang/master
[MACS.git] / test / test_Parser.py
blob09c82c6dd90ebc34451e82c61a3d5aeb0cc695eb
1 #!/usr/bin/env python
2 # Time-stamp: <2024-10-16 00:13:01 Tao Liu>
4 import unittest
6 from MACS3.IO.Parser import (guess_parser,
7 BEDParser,
8 SAMParser,
9 BAMParser,
10 FragParser)
13 class Test_auto_guess(unittest.TestCase):
15 def setUp(self):
16 self.bedfile = "test/tiny.bed.gz"
17 self.bedpefile = "test/tiny.bedpe.gz"
18 self.samfile = "test/tiny.sam.gz"
19 self.bamfile = "test/tiny.bam"
21 def test_guess_parser_bed(self):
22 p = guess_parser(self.bedfile)
23 self.assertTrue(p.is_gzipped())
24 self.assertTrue(isinstance(p, BEDParser))
26 def test_guess_parser_sam(self):
27 p = guess_parser(self.samfile)
28 self.assertTrue(p.is_gzipped())
29 self.assertTrue(isinstance(p, SAMParser))
31 def test_guess_parser_bam(self):
32 p = guess_parser(self.bamfile)
33 self.assertTrue(p.is_gzipped())
34 self.assertTrue(isinstance(p, BAMParser))
37 class Test_parsing(unittest.TestCase):
38 def setUp(self):
39 self.bedfile = "test/tiny.bed.gz"
40 self.bedpefile = "test/tiny.bedpe.gz"
41 self.samfile = "test/tiny.sam.gz"
42 self.bamfile = "test/tiny.bam"
43 self.fragfile = "test/test.fragments.tsv.gz"
45 def test_fragment_file(self):
46 p = FragParser(self.fragfile)
47 petrack = p.build_petrack2()
48 petrack.finalize()
49 bdg = petrack.pileup_bdg()
50 bdg2 = petrack.pileup_bdg2()
51 peaks = bdg.call_peaks(cutoff=10, min_length=200, max_gap=100)
52 peaks2 = bdg2.call_peaks(cutoff=10, min_length=200, max_gap=100)
53 print(peaks)
54 print(peaks2)