예제 #1
0
    def test_RecipeSimpleIncremental(self):
        project = self.project
        env = self.env
        nsamples = self.nsamples
        samplereads = self.samplereads
        sampleinfo_fh = self.sampleinfo_fh
        reference_fn = self.reference_fn
        referenceannotation = self.referenceannotation
        PHAGEFASTA = self._PHAGEFASTA
        PHAGEGFF = self._PHAGEGFF

        # steps used
        bowtie2index = env.activities.INDEX.bowtie2build
        bowtie2align = env.activities.ALIGN.bowtie2
        htseqcount = env.activities.QUANTIFY.htseqcount
        merge = env.activities.UTILITY.columnmerger
        edger = env.activities.DIFFEXP.edger

        from railroadtracks import easy

        # sequence of tasks to run
        torun = list()

        # index for alignment
        Assets = bowtie2index.Assets
        assets = Assets(Assets.Source(rnaseq.FASTAFile(reference_fn)),
                        Assets.Target.createundefined())
        task_index = project.add_task(bowtie2index, 
                                      assets)
        # the step is not done
        self.assertEqual(hortator._TASK_TODO, task_index.info[1])
        torun.append(task_index)
        # run the tasks
        for task in torun:
            # run only if not done
            if task.info[1] != hortator._TASK_DONE:
                task.execute()
                task.status = hortator._TASK_DONE

        self.assertEqual(1, project.persistent_graph.nconcrete_steps)
        # now that the tasks have run let's open the same project
        project_same = easy.Project(project.model, wd=project.wd)

        # index for alignment
        Assets = bowtie2index.Assets
        assets = Assets(Assets.Source(rnaseq.FASTAFile(reference_fn)),
                        Assets.Target.createundefined())
        task_index_same = project_same.add_task(bowtie2index, 
                                                assets)

        self.assertNotEqual(task_index, task_index_same)
        self.assertNotEqual(task_index.call.assets, task_index_same.call.assets)
        self.assertListEqual(list(task_index.call.assets.source.reference), 
                             list(task_index_same.call.assets.source.reference))
        self.assertListEqual(list(task_index.call.assets.target.indexfilepattern), 
                             list(task_index_same.call.assets.target.indexfilepattern))
        self.assertEqual(hortator._TASK_DONE, task_index_same.info[1])
        self.assertEqual(1, project.persistent_graph.nconcrete_steps)
 def setUp(self):
     wd = tempfile.mkdtemp()
     self.wd2 = tempfile.mkdtemp()
     self.project = easy.Project(rnaseq, wd)
     bowtie2index = rnaseq.Bowtie2Build()
     reference_fn = PHAGEFASTA
     Assets = bowtie2index.Assets
     task = self.project.add_task(
         bowtie2index,
         Assets(Assets.Source(rnaseq.FASTAFile(reference_fn))))
     self.task = task
 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)
예제 #4
0
def _project_status_str(args):
    import importlib
    model = importlib.import_module(args.model)
    project = easy.Project(model, args.wd, db_fn=args.db_fn)
    if args.follow:
        import curses
        import sys
        try:
            curses.wrapper(_project_status_curses,
                           project,
                           checkinterval=args.checkinterval)
        except KeyboardInterrupt:
            sys.exit(1)
    else:
        print(easy.str_project_view(project))
예제 #5
0
    def setUp(self):
        # -- recipe-init-begin
        # -- initialization boiler plate code
        wd = tempfile.mkdtemp()
        project = easy.Project(rnaseq, wd=wd)

        # declare the 3rd-party command-line tools we will use
        env = easy.Environment(rnaseq)
        # -- recipe-init-end

        # -- recipe-data-begin
        # Phage genome shipped with the package for testing purposes

        PHAGEFASTA = railroadtracks.model.simulate.PHAGEFASTA
        PHAGEGFF = railroadtracks.model.simulate.PHAGEGFF

        # create random data for 6 samples (just testing here)
        nsamples = 6
        samplereads = list()
        with open(PHAGEFASTA) as fasta_fh:
            reference = next(railroadtracks.model.simulate.readfasta_iter(fasta_fh))
        for sample_i in range(nsamples):
            read1_fh = tempfile.NamedTemporaryFile(prefix='read1', suffix='.fq')
            read2_fh = tempfile.NamedTemporaryFile(prefix='read2', suffix='.fq')
            read1_fh, read2_fh = railroadtracks.model.simulate.randomPEreads(read1_fh,
                                                                             read2_fh, 
                                                                             reference)
            samplereads.append((read1_fh, read2_fh))

        sampleinfo_fh = tempfile.NamedTemporaryFile(suffix='.csv', mode='w+')
        csv_w = csv.writer(sampleinfo_fh)
        csv_w.writerow(['sample_id', 'group'])
        for i in range(6):
            csv_w.writerow([str(i), ('A','B')[i%2]])
        sampleinfo_fh.flush()
        referenceannotation = rnaseq.GFFFile(PHAGEGFF)
        # -- recipe-data-end

        self._wd = wd
        self.project = project
        self.reference_fn = PHAGEFASTA
        self.env = env
        self.nsamples = nsamples
        self.samplereads = samplereads
        self.sampleinfo_fh = sampleinfo_fh
        self.referenceannotation = referenceannotation
        self._PHAGEFASTA = PHAGEFASTA
        self._PHAGEGFF = PHAGEGFF