示例#1
0
文件: testAggr.py 项目: afcarl/PyPPL
 def dataProvider_testSetattr(self):
     pGetAttr1 = Proc()
     pGetAttr2 = Proc()
     pGetAttr3 = Proc()
     aggr1 = Aggr(pGetAttr1, pGetAttr2, pGetAttr3)
     aggr2 = Aggr(pGetAttr1, pGetAttr2, pGetAttr3)
     yield aggr1, 'forks', 10, [10] * 3
     aggr2.delegate('forks', 'pGetAttr2')
     yield aggr2, 'forks', 10, [1, 10, 1]
示例#2
0
文件: testAggr.py 项目: afcarl/PyPPL
    def dataProvider_testSetattr(self):
        pSetattra = Proc()
        pSetattra.args.a = Box()
        pSetattrb = Proc()
        pSetattrb.args.a = Box()
        pSetattrc = Proc()
        pSetattrc.args.a = Box(b=1)
        pSetattrd = Proc()
        pSetattre = Proc()
        aggr = Aggr(pSetattra, pSetattrb, pSetattrc, pSetattrd, pSetattre)
        aggr.delegate('forks', 'pSetattrb')
        aggr.delegate('tag', 'ends')
        yield aggr, 'forks', 10, [1, 10, 1, 1, 1]
        yield aggr, 'tag', 't', [
            aggr.pSetattra.tag, aggr.pSetattra.tag, aggr.pSetattra.tag,
            aggr.pSetattra.tag, 't'
        ]
        # depends and input
        aggr.starts = 'pSetattra, pSetattrb'
        yield aggr, 'depends', ['pSetattrc', 'pSetattrd'], [[aggr.pSetattrc],
                                                            [aggr.pSetattrd],
                                                            [aggr.pSetattrb],
                                                            [aggr.pSetattrc],
                                                            [aggr.pSetattrd]]
        yield aggr, 'depends2', ['pSetattrc', 'pSetattrd'
                                 ], [[aggr.pSetattrc, aggr.pSetattrd],
                                     [aggr.pSetattrc, aggr.pSetattrd],
                                     [aggr.pSetattrb], [aggr.pSetattrc],
                                     [aggr.pSetattrd]]

        aggr1 = Aggr(pSetattra, pSetattrb, pSetattrc)
        aggr1.delegate('errntry', 'pSetattra, pSetattrb')
        aggr1.delegate('args.a', 'pSetattrb')
        yield aggr1, 'errntry', 8, [8, 8, 3]
示例#3
0
文件: testAggr.py 项目: taebow/PyPPL
	def dataProvider_testSetattr(self):
		pSetattra = Proc()
		pSetattra.args.a = Box()
		pSetattrb = Proc()
		pSetattrb.args.a = Box()
		pSetattrc = Proc()
		pSetattrc.args.a = Box(b=1)
		pSetattrd = Proc()
		pSetattre = Proc()
		aggr = Aggr(pSetattra, pSetattrb, pSetattrc, pSetattrd, pSetattre)
		aggr.delegate('forks', 'pSetattrb')
		aggr.delegate('tag', 'ends')
		proxy = _Proxy(aggr, check = True)
		yield proxy, 'forks', 10, [1, 10, 1, 1, 1]
		yield proxy, 'tag', 't', [aggr.pSetattra.tag, aggr.pSetattra.tag, aggr.pSetattra.tag, aggr.pSetattra.tag, 't']
		# depends and input
		aggr.starts = 'pSetattra, pSetattrb'
		yield proxy, 'depends', ['pSetattrc', 'pSetattrd'], [[aggr.pSetattrc], [aggr.pSetattrd], [aggr.pSetattrb], [aggr.pSetattrc], [aggr.pSetattrd]]
		yield proxy, 'depends2', ['pSetattrc', 'pSetattrd'], [[aggr.pSetattrc, aggr.pSetattrd], [aggr.pSetattrc, aggr.pSetattrd], [aggr.pSetattrb], [aggr.pSetattrc], [aggr.pSetattrd]]

		aggr1 = Aggr(pSetattra, pSetattrb, pSetattrc)
		aggr1.delegate('args.a.b', 'pSetattra, pSetattrb')
		aggr1.delegate('args.a', 'pSetattrb')
		proxy1 = _Proxy(aggr1, prefix = ['args', 'a'], check = True)
		yield proxy1, 'b', 3, [3, 3, 1]
示例#4
0
	- gene list file, one per line
	- TF (1st col) list file with motif ids (2nd col). Default: params.tflist.value
"""
aTfbsTfP = Aggr(
	pSort.copy(newid = 'pTFs'),
	pPromoters,
	pSort.copy(newid = 'pTFList'),
	pSimRead,
	pBedGetfasta,
	pMotifScan,
	depends = False
)
# defaults
aTfbsTfP.pPromoters.runner = 'local'
delegate
aTfbsTfP.delegate('args.up'      , 'pPromoters')
aTfbsTfP.delegate('args.down'    , 'pPromoters')
aTfbsTfP.delegate('args.genome'  , 'pPromoters')
aTfbsTfP.delegate('args.ref'     , 'pBedGetfasta')
aTfbsTfP.delegate('args.pval'    , 'pMotifScan')
aTfbsTfP.delegate('args.tfmotifs', 'pMotifScan')
# depends
aTfbsTfP.starts               = aTfbsTfP.pTFs, aTfbsTfP.pPromoters, aTfbsTfP.pTFList 
aTfbsTfP.ends                 = aTfbsTfP.pMotifScan
aTfbsTfP.pMotifScan.depends   = aTfbsTfP.pSimRead, aTfbsTfP.pBedGetfasta
aTfbsTfP.pBedGetfasta.depends = aTfbsTfP.pPromoters
aTfbsTfP.pSimRead.depends     = aTfbsTfP.pTFList, aTfbsTfP.pTFs
# input
aTfbsTfP.pTFList.input    = [params.tflist.value]
# input size of either pTFs or pTFList should be 1
aTfbsTfP.pSimRead.input   = lambda ch1, ch2: [ch1.repRow(l).cbind(ch2.repRow(l)).flatten() for l in [max(ch1.length(), ch2.length())]]
示例#5
0
文件: testAggr.py 项目: afcarl/PyPPL
    def testSetGetAttr(self):
        pGetAttr1 = Proc()
        pGetAttr2 = Proc()
        pGetAttr3 = Proc()
        pGetAttr4 = Proc()
        pGetAttr5 = Proc()
        pGetAttr1.args.params = Box(inopts=Box())
        pGetAttr2.args.params = Box(inopts=Box())
        pGetAttr3.args.params = Box(inopts=Box())
        pGetAttr4.args.params = Box(inopts=Box())
        pGetAttr5.args.params = Box(inopts=Box())
        aggr = Aggr(pGetAttr1,
                    pGetAttr2,
                    pGetAttr3,
                    pGetAttr4,
                    pGetAttr5,
                    depends=False)
        # nothing delegated yet
        self.assertDictEqual(
            {
                'input': ['starts'],
                'depends': ['starts'],
                'exdir': ['ends'],
                'exhow': ['ends'],
                'expart': ['ends'],
                'exow': ['ends']
            }, aggr._delegates)
        # but when starts and ends changed
        aggr.starts = [aggr.pGetAttr1, aggr.pGetAttr2]
        aggr.ends = [aggr.pGetAttr5]
        self.assertDictEqual(
            {
                'input': ['starts'],
                'depends': ['starts'],
                'exdir': ['ends'],
                'exhow': ['ends'],
                'expart': ['ends'],
                'exow': ['ends']
            }, aggr._delegates)

        # delegate a short attribute
        aggr.delegate('forks', [aggr.pGetAttr2, aggr.pGetAttr3])
        aggr.forks = 10
        # only 2, 3 changed
        self.assertListEqual([p.forks for p in aggr._procs.values()],
                             [1, 10, 10, 1, 1])

        # change the specific procs
        aggr['pGetAttr2', 'pGetAttr4'].forks = 5
        self.assertListEqual([p.forks for p in aggr._procs.values()],
                             [1, 10, 10, 5, 1])

        # fix an attribute
        aggr.pGetAttr3.runner = 'dry'
        aggr.runner = 'sge'
        self.assertListEqual(
            [p.config['runner'] for p in aggr._procs.values()],
            ['sge', 'sge', 'dry', 'sge', 'sge'])

        # set input
        self.assertRaises(AggrAttributeError, setattr, aggr, 'input', 1)
        aggr.input = [1, 2]
        self.assertListEqual([p.config['input'] for p in aggr._procs.values()],
                             [1, 2, '', '', ''])
        # reverse it
        aggr.input = ['', '']
        aggr.input2 = [1, 2]
        self.assertListEqual([p.config['input'] for p in aggr._procs.values()],
                             [[1, 2], [1, 2], '', '', ''])
        aggr[3].input = 'i3'
        self.assertListEqual([p.config['input'] for p in aggr._procs.values()],
                             [[1, 2], [1, 2], '', 'i3', ''])
        # not suppose to do this
        # aggr.input2[2] = ['a', 'b']
        #self.assertListEqual([p.config['input'] for p in aggr._procs.values()], [[1,2], [1,2], ['a', 'b'], 'i3', ''])

        # similar for depends
        #self.assertRaises(AggrAttributeError, setattr, aggr, 'depends', 1)
        aggr.depends = [pGetAttr1, pGetAttr2]
        self.assertListEqual([p.depends for p in aggr._procs.values()],
                             [[pGetAttr1], [pGetAttr2], [], [], []])
        # reverse it
        aggr.depends = [[], []]
        aggr.depends2 = [pGetAttr1, pGetAttr2]
        self.assertListEqual(
            [p.depends for p in aggr._procs.values()],
            [[pGetAttr1, pGetAttr2], [pGetAttr1, pGetAttr2], [], [], []])

        # set attributes of certain processes
        aggr[0].args.params = Box(inopts=Box(a=1))
        self.assertListEqual([p.args for p in aggr._procs.values()], [
            Box(params=Box(inopts=Box(a=1))),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box())),
        ])

        aggr[:2].args.params = Box(inopts=Box(b=1))
        self.assertListEqual([p.args for p in aggr._procs.values()], [
            Box(params=Box(inopts=Box(b=1))),
            Box(params=Box(inopts=Box(b=1))),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box())),
        ])

        aggr[1, 2].args.params = Box(inopts=Box(c=1))
        self.assertListEqual([p.args for p in aggr._procs.values()], [
            Box(params=Box(inopts=Box(b=1))),
            Box(params=Box(inopts=Box(c=1))),
            Box(params=Box(inopts=Box(c=1))),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box())),
        ])

        # using proc ids
        aggr['pGetAttr1'].args.params = Box(inopts=Box(d=1))
        self.assertListEqual([p.args for p in aggr._procs.values()], [
            Box(params=Box(inopts=Box(d=1))),
            Box(params=Box(inopts=Box(c=1))),
            Box(params=Box(inopts=Box(c=1))),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box())),
        ])

        aggr['pGetAttr1', 'pGetAttr3'].args.params = Box(inopts=Box(e=1))
        self.assertListEqual([p.args for p in aggr._procs.values()], [
            Box(params=Box(inopts=Box(e=1))),
            Box(params=Box(inopts=Box(c=1))),
            Box(params=Box(inopts=Box(e=1))),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box())),
        ])

        aggr['pGetAttr1, pGetAttr3'].args.params = Box(inopts=Box(f=1))
        self.assertListEqual([p.args for p in aggr._procs.values()], [
            Box(params=Box(inopts=Box(f=1))),
            Box(params=Box(inopts=Box(c=1))),
            Box(params=Box(inopts=Box(f=1))),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box())),
        ])

        aggr['starts'].args.params = Box(inopts=Box(g=1))
        self.assertListEqual([p.args for p in aggr._procs.values()], [
            Box(params=Box(inopts=Box(g=1))),
            Box(params=Box(inopts=Box(g=1))),
            Box(params=Box(inopts=Box(f=1))),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box())),
        ])

        aggr['ends'].args.params = Box(inopts=Box(h=1))
        self.assertListEqual([p.args for p in aggr._procs.values()], [
            Box(params=Box(inopts=Box(g=1))),
            Box(params=Box(inopts=Box(g=1))),
            Box(params=Box(inopts=Box(f=1))),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box(h=1))),
        ])

        aggr.delegate('args.params.inopts', 'pGetAttr3')
        aggr.args['params'].inopts = Box(n=1)
        self.assertListEqual([p.args for p in aggr._procs.values()], [
            Box(params=Box(inopts=Box(g=1))),
            Box(params=Box(inopts=Box(g=1))),
            Box(params=Box(inopts=Box(n=1))),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box(h=1))),
        ])

        aggr.args.params['inopts'] = Box(m=1)
        self.assertListEqual([p.args for p in aggr._procs.values()], [
            Box(params=Box(inopts=Box(g=1))),
            Box(params=Box(inopts=Box(g=1))),
            Box(params=Box(inopts=Box(m=1))),
            Box(params=Box(inopts=Box())),
            Box(params=Box(inopts=Box(h=1))),
        ])

        aggr[0].args.params.inopts = Box(z=1)
        # remeber at line 453, inopts refers to the same Box() object, so both pGetAttr1 and 3 will change
        self.assertListEqual(
            [p.args for p in aggr._procs.values()],
            [
                Box(params=Box(inopts=Box(z=1))),
                Box(params=Box(inopts=Box(z=1))),  # <-- not g
                Box(params=Box(inopts=Box(m=1))),
                Box(params=Box(inopts=Box())),
                Box(params=Box(inopts=Box(h=1))),
            ])

        aggr.args.params.inopts.cnames = True
        self.assertListEqual(
            [p.args.params.inopts for p in aggr._procs.values()], [
                Box(z=1),
                Box(z=1),
                Box(m=1, cnames=True),
                Box(),
                Box(h=1),
            ])

        # something undelegated
        aggr.tag = 'abc'
        self.assertListEqual([p.tag for p in aggr._procs.values()],
                             ['abc'] * 5)

        del aggr._delegates['args.params.inopts']
        aggr.delegate('args', 'pGetAttr4')
        aggr.args.params.inopts.rnames = True
        self.assertListEqual(
            [p.args.params.inopts for p in aggr._procs.values()], [
                Box(z=1),
                Box(z=1),
                Box(m=1, cnames=True),
                Box(rnames=True),
                Box(h=1),
            ])
示例#6
0
aPrepareBam = Aggr(pBam2Fastq,
                   pFastqTrim,
                   pFastQC,
                   pFastMC,
                   pFastq2Sam,
                   pSam2Bam,
                   pBamRecal,
                   depends=False)
# starts and ends
aPrepareBam.ends = 'pBamRecal'
# depends
aPrepareBam['pFastq2Sam', ].depends = ['pFastqTrim']
aPrepareBam['pSam2Bam', ].depends = ['pFastq2Sam']
aPrepareBam['pBamRecal', ].depends = ['pSam2Bam']
# delegates
aPrepareBam.delegate('args.ref', 'pFastq2Sam, pBamRecal')
# args
aPrepareBam.pSam2Bam.args.markdup = True
# modules
aPrepareBam.module('ebam',
                   starts='pBam2Fastq',
                   depends={'pFastqTrim': 'pBam2Fastq'})
aPrepareBam.module('fastq', starts='pFastqTrim')
aPrepareBam.module('qc',
                   ends='pFastQC, pFastMC',
                   depends={'pFastQC, pFastMC': ['pFastqTrim'] * 2})
# inital modules
aPrepareBam.on('fastq')
"""
@name:
	aBam2SCNV