File: detectionMethylFractionTest.py

package info (click to toggle)
kineticstools 0.6.1%2Bgit20200729.e3723e0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 22,144 kB
  • sloc: python: 3,505; makefile: 207; ansic: 104; sh: 55; xml: 19
file content (49 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import logging
import os
import platform

from pbcore.io import CmpH5Reader

from kineticsTools.ReferenceUtils import ReferenceWindow
from kineticsTools.KineticWorker import KineticWorker
from kineticsTools.ipdModel import IpdModel

from test import TestSetup


class TestDetectionMethylFraction(TestSetup):

    # We inherit the setup method for test.py.
    # If you need to customize your dataset, we should set up some different
    # conventions

    def getOpts(self):
        opts = self.basicOpts()
        opts.identify = False
        opts.methylFraction = True
        return opts

    def testSmallDecode(self):
        """
        Test modified fraction estimation in detection mode around a known modification in lambda
        """

        # First methlyated A in lambda:
        # strand            motif onTarget seqid   tpl
        #      0    GCACNNNNNNGTT       On     1 14983

        start = 14900
        end = 15100
        referenceWindow = ReferenceWindow(1, "lambda_NEB3011", start, end)
        bounds = (start, end)

        self.kw._prepForReferenceWindow(referenceWindow)
        kinetics = self.kw._summarizeReferenceRegion(bounds, True, False)

        # Verify that we detect m6A mods at 14982 and 14991
        m6AMods = [{'frac': x['frac'], 'fracLow': x['fracLow'], 'fracUp': x['fracUp'], 'tpl': x['tpl'], 'strand': x['strand']}
                   for x in kinetics if 'frac' in x and x['tpl'] in (14982, 14991)]
        print(m6AMods)

        for mod in m6AMods:
            assert mod["frac"] > 0.5