Python luigi.LocalTarget() Examples

The following are 30 code examples of luigi.LocalTarget(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module luigi , or try the search function .
Example #1
Source File: guesser.py    From qb with MIT License 6 votes vote down vote up
def output(self):
        guesser_class = get_class(self.guesser_module, self.guesser_class)
        guesser_targets = [
            LocalTarget(file)
            for file in guesser_class.files(
                AbstractGuesser.output_path(self.guesser_module, self.guesser_class, self.config_num, '')
            )]

        return [
            LocalTarget(AbstractGuesser.output_path(
                self.guesser_module, self.guesser_class, self.config_num, ''
            )),
            LocalTarget(
                AbstractGuesser.output_path(
                    self.guesser_module, self.guesser_class, self.config_num, 'guesser_params.pickle'
                ))
        ] + guesser_targets 
Example #2
Source File: luigi_utils_test.py    From spotify-tensorflow with Apache License 2.0 6 votes vote down vote up
def test_get_uri():

        class TargetWithURI(LocalTarget):
            def uri(self):
                return 'i://have/a/uri'

        class TargetWithPath(LocalTarget):
            pass

        class NotATarget:
            pass

        assert get_uri(TargetWithURI('fake/path')) == 'i://have/a/uri'
        assert get_uri(TargetWithPath('a/path')) == 'a/path'

        try:
            get_uri(NotATarget())
            assert False
        except ValueError as e:
            assert "Unknown input target type" in str(e) 
Example #3
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 6 votes vote down vote up
def run(self):
        tm_args = self.get_module_args(TransMap, genome=self.genome)
        logger.info('Running transMap for {}.'.format(self.genome))
        cmd = [['pslMap', '-chainMapFile', tm_args.ref_psl, tm_args.chain_file, '/dev/stdout'],
               ['pslMapPostChain', '/dev/stdin', '/dev/stdout'],
               ['sort', '-k14,14', '-k16,16n'],
               ['pslRecalcMatch', '/dev/stdin', tm_args.two_bit, tm_args.transcript_fasta, 'stdout'],
               ['sort', '-k10,10']]  # re-sort back to query name for filtering
        tmp_file = luigi.LocalTarget(is_tmp=True)
        with tmp_file.open('w') as tmp_fh:
            tools.procOps.run_proc(cmd, stdout=tmp_fh, stderr='/dev/null')
        tm_psl_tgt, tm_gp_tgt = self.output()
        tools.fileOps.ensure_file_dir(tm_psl_tgt.path)
        with tm_psl_tgt.open('w') as outf:
            for psl_rec in tools.psl.psl_iterator(tmp_file.path, make_unique=True):
                tools.fileOps.print_row(outf, psl_rec.psl_string())
        with tm_gp_tgt.open('w') as outf:
            cmd = ['transMapPslToGenePred', '-nonCodingGapFillMax=80', '-codingGapFillMax=50',
                   tm_args.annotation_gp, tm_psl_tgt.path, '/dev/stdout']
            tools.procOps.run_proc(cmd, stdout=outf) 
Example #4
Source File: guesser.py    From qb with MIT License 6 votes vote down vote up
def output(self):
        if os.path.exists(c.QANTA_EXPO_DATASET_PATH):
            folds = [c.GUESSER_DEV_FOLD, c.GUESSER_TEST_FOLD, c.EXPO_FOLD]
        else:
            folds = [c.GUESSER_DEV_FOLD, c.GUESSER_TEST_FOLD]

        targets = [LocalTarget(AbstractGuesser.reporting_path(
            self.guesser_module,
            self.guesser_class,
            self.config_num,
            f'guesser_params.pickle'))
        ]
        for f in folds:
            targets.append(
                LocalTarget(AbstractGuesser.reporting_path(
                    self.guesser_module,
                    self.guesser_class,
                    self.config_num,
                    f'guesser_report_{f}.pickle'
                ))
            )
        return targets 
Example #5
Source File: gutenberg.py    From gluish with GNU General Public License v3.0 5 votes vote down vote up
def output(self):
        return luigi.LocalTarget(path=self.path(ext='mrc')) 
Example #6
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        pipeline_args = self.get_pipeline_args()
        hgm_args = Hgm.get_args(pipeline_args, self.mode)
        for genome in hgm_args.genomes:
            db = pipeline_args.dbs[genome]
            tools.fileOps.ensure_file_dir(db)
            conn_str = 'sqlite:///{}'.format(db)
            tablename = tools.sqlInterface.tables['hgm'][self.mode].__tablename__
            yield luigi.contrib.sqla.SQLAlchemyTarget(connection_string=conn_str,
                                                      target_table=tablename,
                                                      update_id='_'.join([tablename, str(hash(pipeline_args))]))
        for f in hgm_args.gtf_out_files.values():
            yield luigi.LocalTarget(f) 
Example #7
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        consensus_args = self.get_module_args(Consensus, genome=self.genome)
        yield luigi.LocalTarget(consensus_args.metrics_json)
        yield luigi.LocalTarget(consensus_args.consensus_gp)
        yield luigi.LocalTarget(consensus_args.consensus_gp_info)
        yield luigi.LocalTarget(consensus_args.consensus_gff3)
        yield luigi.LocalTarget(consensus_args.consensus_fasta)
        yield luigi.LocalTarget(consensus_args.consensus_protein_fasta) 
Example #8
Source File: gutenberg.py    From gluish with GNU General Public License v3.0 5 votes vote down vote up
def output(self):
        return luigi.LocalTarget(path=self.path(), format=TSV) 
Example #9
Source File: wordcount.py    From HadoopWithPython with MIT License 5 votes vote down vote up
def output(self):
      """
      The task's output
      """
      return luigi.LocalTarget(self.output_file) 
Example #10
Source File: gutenberg.py    From gluish with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        url = "http://gutenberg.readingroo.ms/cache/generated/feeds/catalog.marc.bz2"
        output = shellout('wget -q "{url}" -O {output}', url=url)
        output = shellout('bunzip2 {input} -c > {output}', input=output)
        luigi.LocalTarget(output).move(self.output().path) 
Example #11
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        pipeline_args = self.get_pipeline_args()
        augustus_args = Augustus.get_args(pipeline_args, self.genome)
        yield luigi.LocalTarget(augustus_args.augustus_tm_gp)
        yield luigi.LocalTarget(augustus_args.augustus_tm_gtf)
        if augustus_args.augustus_tmr:
            yield luigi.LocalTarget(augustus_args.augustus_tmr_gp)
            yield luigi.LocalTarget(augustus_args.augustus_tmr_gtf) 
Example #12
Source File: gutenberg.py    From gluish with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        output = shellout('marctotsv -k -s "|" {input} 001 653.a > {output}',
                 input=self.input().get('dump').path)
        with luigi.LocalTarget(output, format=TSV).open() as handle:
            with self.output().open('w') as output:
                for row in handle.iter_tsv(cols=('id', 'terms')):
                    for subfield in row.terms.split('|'):
                        for term in subfield.split('--'):
                            term = term.strip()
                            output.write_tsv(row.id, term) 
Example #13
Source File: newspapers.py    From gluish with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        """ Just run wget quietly. """
        output = shellout('wget -q "{url}" -O {output}', url=self.url)
        luigi.LocalTarget(output).move(self.output().path) 
Example #14
Source File: newspapers.py    From gluish with GNU General Public License v3.0 5 votes vote down vote up
def output(self):
        """ Output a file with a single Json doc. """
        return luigi.LocalTarget(path=self.path(digest=True, ext='json')) 
Example #15
Source File: newspapers.py    From gluish with GNU General Public License v3.0 5 votes vote down vote up
def output(self):
        """ Use the digest version, since URL can be ugly. """
        return luigi.LocalTarget(path=self.path(digest=True, ext='html')) 
Example #16
Source File: wordcount.py    From HadoopWithPython with MIT License 5 votes vote down vote up
def output(self):
      """
      Return the target for this task
      """
      return luigi.LocalTarget(self.input_file) 
Example #17
Source File: gutenberg.py    From gluish with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        output = shellout("cut -f 2- {input}| sort | uniq -c | sort -nr > {output}",
                          input=self.input().path)
        luigi.LocalTarget(output).move(self.output().path) 
Example #18
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        pipeline_args = self.get_pipeline_args()
        augustus_pb_args = AugustusPb.get_args(pipeline_args, self.genome)
        yield luigi.LocalTarget(augustus_pb_args.augustus_pb_gp)
        yield luigi.LocalTarget(augustus_pb_args.augustus_pb_gtf)
        yield luigi.LocalTarget(augustus_pb_args.augustus_pb_raw_gtf) 
Example #19
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        pipeline_args = self.get_pipeline_args()
        cgp_args = self.get_args(pipeline_args)
        for path_dict in [cgp_args.augustus_cgp_gp, cgp_args.augustus_cgp_gtf, cgp_args.augustus_cgp_raw_gtf]:
            for path in path_dict.values():
                yield luigi.LocalTarget(path) 
Example #20
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        pipeline_args = self.get_pipeline_args()
        args = CreateDirectoryStructure.get_args(pipeline_args)
        yield luigi.LocalTarget(args.hub_txt)
        yield luigi.LocalTarget(args.genomes_txt)
        yield luigi.LocalTarget(args.groups_txt)
        yield luigi.LocalTarget(args.hal)
        for local_path, hub_path in args.sizes.values():
            yield luigi.LocalTarget(hub_path)
        for local_path, hub_path in args.twobits.values():
            yield luigi.LocalTarget(hub_path) 
Example #21
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def run(self):
        tm_args = self.get_module_args(TransMap, genome=self.genome)
        logger.info('Creating unfiltered transMap GTF for {}.'.format(self.genome))
        tmp_gp = luigi.LocalTarget(is_tmp=True)
        cmd = ['transMapPslToGenePred', '-nonCodingGapFillMax=80', '-codingGapFillMax=50',
               tm_args.annotation_gp, tm_args.tm_psl, tmp_gp.path]
        tools.procOps.run_proc(cmd)
        tools.misc.convert_gp_gtf(self.output(), tmp_gp) 
Example #22
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        pipeline_args = self.get_pipeline_args()
        tm_args = self.get_module_args(TransMap, genome=self.genome)
        tools.fileOps.ensure_file_dir(tm_args.db_path)
        conn_str = 'sqlite:///{}'.format(tm_args.db_path)
        tm_args = self.get_module_args(TransMap, genome=self.genome)
        return (luigi.contrib.sqla.SQLAlchemyTarget(connection_string=conn_str,
                                                    target_table=self.eval_table,
                                                    update_id='_'.join([self.eval_table, str(hash(pipeline_args))])),
                luigi.LocalTarget(tm_args.filtered_tm_psl),
                luigi.LocalTarget(tm_args.metrics_json),
                luigi.LocalTarget(tm_args.filtered_tm_gp)) 
Example #23
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        tm_args = self.get_module_args(TransMap, genome=self.genome)
        return luigi.LocalTarget(tm_args.tm_psl), luigi.LocalTarget(tm_args.tm_gp) 
Example #24
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        pipeline_args = self.get_pipeline_args()
        chain_args = self.get_args(pipeline_args)
        for path in chain_args.chain_files.values():
            yield luigi.LocalTarget(path) 
Example #25
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        return luigi.LocalTarget(self.hints_args.hints_path) 
Example #26
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        return luigi.LocalTarget(self.transcript_flat_fasta) 
Example #27
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def run(self):
        logger.info('Extracting reference annotation GTF.')
        tools.misc.convert_gp_gtf(self.output(), luigi.LocalTarget(self.annotation_gp)) 
Example #28
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        return luigi.LocalTarget(self.annotation_gtf) 
Example #29
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        return luigi.LocalTarget(self.transcript_fasta) 
Example #30
Source File: __init__.py    From Comparative-Annotation-Toolkit with Apache License 2.0 5 votes vote down vote up
def output(self):
        return luigi.LocalTarget(self.flat_fasta)