コード例 #1
0
    def testAddTaskSet(self):
        ts = easy.TaskSet()
        ts.add(self.task)
        #
        tsg = tasksetgraph.TaskSetGraph()
        tsindex_id = tsg.add_taskset(ts)
        dict_retrieve = tsg.digraph.node[tasksetgraph.get_tasksetid(
            (self.task, ))]
        ts_retrieve = dict_retrieve['taskset']
        self.assertEqual(len(ts), len(ts_retrieve))
        self.assertEqual(tuple(x.task_id for x in ts),
                         tuple(x.task_id for x in ts_retrieve))

        # add connected tasks
        taskset_align = easy.TaskSet()
        aligner = rnaseq.Bowtie2()
        for fq_name in ('foo.fq', 'bar.fq'):
            Assets = aligner.Assets
            assets = Assets(
                Assets.Source(self.task.call.assets.target.indexfilepattern,
                              rnaseq.FASTQPossiblyGzipCompressed(fq_name),
                              None), None)
            task_align = self.project.add_task(aligner, assets)
            taskset_align.add(task_align)
        tsalign_id = tsg.add_taskset(taskset_align)
        lst = tsg.execution_list()
        self.assertEqual(tsindex_id,
                         tasksetgraph.get_tasksetid(lst[0].taskset))
        self.assertEqual(tsalign_id,
                         tasksetgraph.get_tasksetid(lst[1].taskset))
コード例 #2
0
    def testExecutionList(self):
        tsg = tasksetgraph.TaskSetGraph()
        # initial task/taskset is building a bowtie2 index
        tsindex_id = tsg.add(self.task)
        lst = tsg.execution_list()
        self.assertEqual(1, len(lst))

        # add a second task set that performs the alignment of several pairs of
        # FASTQ files
        n_fastq = 3
        pairnames = self._create_fastq(n_fastq, self.wd2)

        index_task = self.task
        bowtie2 = rnaseq.Bowtie2()
        Assets = bowtie2.Assets
        # Class to model FASTQ files that are optionally compressed
        FASTQ = rnaseq.FASTQPossiblyGzipCompressed
        ts = easy.TaskSet()
        # note that we are included the pair of FASTQ already aligned above
        for read1_fn, read2_fn in pairnames:
            task = self.project.add_task(
                bowtie2,
                Assets(
                    Assets.Source(
                        index_task.call.assets.target.indexfilepattern,
                        FASTQ(read1_fn), FASTQ(read2_fn))))
            ts.add(task)
        tsalign_id = tsg.add(ts)
        lst = tsg.execution_list()
コード例 #3
0
 def testAddTask(self):
     tsg = tasksetgraph.TaskSetGraph()
     tsg.add(self.task)
     dict_retrieve = tsg.digraph.node[tasksetgraph.get_tasksetid(
         (self.task, ))]
     ts_retrieve = dict_retrieve['taskset']
     self.assertEqual(1, len(ts_retrieve))
     self.assertEqual((self.task.task_id, ),
                      tuple(x.task_id for x in ts_retrieve))
コード例 #4
0
    def testAddTaskSetDuplicateTask(self):
        ts = easy.TaskSet()
        ts.add(self.task)
        tsg = tasksetgraph.TaskSetGraph()
        tsg.add_taskset(ts)

        ts2 = easy.TaskSet()
        ts2.add(self.task)
        self.assertRaises(ValueError, tsg.add_taskset, ts2)
コード例 #5
0
 def testAddTaskDifferentProject(self):
     project2 = easy.Project(rnaseq, self.wd2)
     bowtie2index = rnaseq.Bowtie2Build()
     reference_fn = PHAGEFASTA
     Assets = bowtie2index.Assets
     task2 = project2.add_task(
         bowtie2index,
         Assets(Assets.Source(rnaseq.FASTAFile(reference_fn))))
     #
     tsg = tasksetgraph.TaskSetGraph()
     tsg.add(self.task)
     self.assertRaises(ValueError, tsg.add, task2)
コード例 #6
0
    def testExecution(self):
        tsg = tasksetgraph.TaskSetGraph()
        tsg.add(self.task)
        n_fastq = 3
        pairnames = self._create_fastq(n_fastq, self.wd2)

        index_task = self.task
        bowtie2 = rnaseq.Bowtie2()
        Assets = bowtie2.Assets
        FASTQ = rnaseq.FASTQPossiblyGzipCompressed
        ts = easy.TaskSet()
        for read1_fn, read2_fn in pairnames:
            task = self.project.add_task(
                bowtie2,
                Assets(
                    Assets.Source(
                        index_task.call.assets.target.indexfilepattern,
                        FASTQ(read1_fn), FASTQ(read2_fn))))
            ts.add(task)
        tsg.add(ts)
        # no task mapper, check that an exception is raised
        self.assertRaises(ValueError, tsg.execute)

        # set the default task mapper to a multiprocessing based one
        n_processes = 1
        mpe = easy.MultiprocessingExecution(n_processes)
        tsg.defaultmapper = mpe
        tsg.execute()

        # use a run-only-once filter (that is only try to execute
        # tasks with the status "TO DO"
        flt = lambda taskset: taskset.filter_on_status(easy._TASK_TODO)
        tsg.defaulttasksetfilter = flt
        lst = tsg.execution_list()
        for elt in lst:
            ts_f = tsg._filtered_taskset(elt)
            # check that nothing is left to be exectuted
            # (since everything has been run earlier)
            self.assertEqual(0, len(ts_f))