当前位置: 首页>>代码示例>>Python>>正文


Python node.CommandNode类代码示例

本文整理汇总了Python中paleomix.node.CommandNode的典型用法代码示例。如果您正苦于以下问题:Python CommandNode类的具体用法?Python CommandNode怎么用?Python CommandNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommandNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, config, reference, intervals, infiles, outfile,
                 dependencies=()):
        self._basename = os.path.basename(outfile)

        infiles = safe_coerce_to_tuple(infiles)
        jar_file = os.path.join(config.jar_root, "GenomeAnalysisTK.jar")
        command = AtomicJavaCmdBuilder(jar_file,
                                       jre_options=config.jre_options)
        command.set_option("-T", "IndelRealigner")
        command.set_option("-R", "%(IN_REFERENCE)s")
        command.set_option("-targetIntervals", "%(IN_INTERVALS)s")
        command.set_option("-o", "%(OUT_BAMFILE)s")
        command.set_option("--bam_compression", 0)
        command.set_option("--disable_bam_indexing")
        _set_input_files(command, infiles)

        command.set_kwargs(IN_REFERENCE=reference,
                           IN_REF_DICT=fileutils.swap_ext(reference, ".dict"),
                           IN_INTERVALS=intervals,
                           OUT_BAMFILE=outfile,
                           CHECK_GATK=_get_gatk_version_check(config))

        calmd = AtomicCmd(["samtools", "calmd", "-b",
                           "%(TEMP_IN_BAM)s", "%(IN_REF)s"],
                          TEMP_IN_BAM=self._basename,
                          IN_REF=reference,
                          TEMP_OUT_STDOUT=self._basename + ".calmd",
                          CHECK_VERSION=SAMTOOLS_VERSION)

        description = "<GATK Indel Realigner (aligning): %s -> %r>" \
            % (describe_files(infiles), outfile)
        CommandNode.__init__(self,
                             description=description,
                             command=ParallelCmds([command.finalize(), calmd]),
                             dependencies=dependencies)
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:35,代码来源:gatk.py

示例2: __init__

    def __init__(self, output_prefix, tfam, tped,
                 indep_filter=None, indep_parameters=None,
                 plink_parameters=None,
                 dependencies=()):
        temp_prefix = os.path.basename(output_prefix)

        plink_cmd = ["plink", "--make-bed", "--noweb",
                     "--tped", "%(IN_TPED)s",
                     "--tfam", "%(IN_TFAM)s",
                     "--out", "%(TEMP_OUT_PREFIX)s"]

        plink_cmd.extend(self._parse_parameters(plink_parameters))

        command = AtomicCmd(plink_cmd,
                            IN_TPED=tped,
                            IN_TFAM=tfam,
                            TEMP_OUT_PREFIX=temp_prefix,
                            OUT_BED=output_prefix + ".bed",
                            OUT_BIM=output_prefix + ".bim",
                            OUT_FAM=output_prefix + ".fam",
                            OUT_LOG=output_prefix + ".log",
                            TEMP_OUT_NOSEX=temp_prefix + ".nosex",
                            TEMP_OUT_NOF=temp_prefix + ".nof",
                            CHECK_VERSION=PLINK_VERSION,
                            set_cwd=True)

        CommandNode.__init__(self,
                             description="<BuildBEDFiles -> '%s.*'>"
                             % (output_prefix,),
                             command=command,
                             dependencies=dependencies)
开发者ID:muslih14,项目名称:paleomix,代码行数:31,代码来源:nuclear.py

示例3: __init__

    def __init__(self, infile, outfile, genome, from_start=0, from_end=0,
                 strand_relative=False, dependencies=()):
        if type(from_start) != type(from_end):
            raise ValueError("Parameters 'from_start' and 'from_end' should "
                             "be of same type!")

        call = ["bedtools", "slop",
                "-i", "%(IN_FILE)s",
                "-g", "%(IN_GENOME)s",
                "-l", str(from_start),
                "-r", str(from_end)]

        if strand_relative:
            call.append("-s")
        if type(from_start) is float:
            call.append("-pct")

        command = AtomicCmd(call,
                            IN_FILE=infile,
                            IN_GENOME=genome,
                            OUT_STDOUT=outfile,
                            CHECK_VERSION=BEDTOOLS_VERSION)

        description = "<SlopBed: '%s' -> '%s'>" % (infile, outfile)

        CommandNode.__init__(self,
                             description=description,
                             command=command,
                             dependencies=dependencies)
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:29,代码来源:bedtools.py

示例4: _setup

    def _setup(self, config, temp):
        CommandNode._setup(self, config, temp)

        # The temp folder may contain old files:
        # Remove old pipes to prevent failure at _teardown
        for pipe_fname in glob.glob(os.path.join(temp, "pipe*")):
            fileutils.try_remove(pipe_fname)
        # ExaML refuses to overwrite old info files
        fileutils.try_remove(os.path.join(temp, "ExaML_info.Pypeline"))

        # Resume from last checkpoint, if one such was generated
        checkpoints = glob.glob(os.path.join(temp,
                                "ExaML_binaryCheckpoint.Pypeline_*"))
        if not checkpoints:
            return

        cache = FileStatusCache()
        if not cache.are_files_outdated(self.input_files, checkpoints):
            checkpoints.sort(key=lambda fname: int(fname.rsplit("_", 1)[-1]))

            # FIXME: Less hacky solution to modifying AtomicCmds needed
            self._command._command.append("-R")
            self._command._command.append(checkpoints[-1])
        else:
            for fpath in checkpoints:
                fileutils.try_remove(fpath)
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:26,代码来源:examl.py

示例5: _teardown

    def _teardown(self, config, temp):
        os.remove(os.path.join(temp, self.PIPE_FILE))
        if self._index_format:
            os.remove(os.path.join(temp, swap_ext(self.PIPE_FILE,
                                                  self._index_format)))

        CommandNode._teardown(self, config, temp)
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:7,代码来源:picard.py

示例6: __init__

    def __init__(self, config, input_bams, command, index_format=None,
                 description=None, threads=1, dependencies=()):
        self._input_bams = safe_coerce_to_tuple(input_bams)
        self._index_format = index_format

        if not self._input_bams:
            raise ValueError("No input BAM files specified!")
        elif len(self._input_bams) > 1 and index_format:
            raise ValueError("BAM index cannot be required for > 1 file")
        elif index_format not in (None, ".bai", ".csi"):
            raise ValueError("Unknown index format %r" % (index_format,))

        if len(self._input_bams) > 1:
            merge = picard_command(config, "MergeSamFiles")
            merge.set_option("SO", "coordinate", sep="=")
            merge.set_option("COMPRESSION_LEVEL", 0, sep="=")
            merge.set_option("OUTPUT", "%(TEMP_OUT_BAM)s", sep="=")
            # Validation is mostly left to manual ValidateSamFile runs; this
            # is because .csi indexed BAM records can have "invalid" bins.
            merge.set_option("VALIDATION_STRINGENCY", "LENIENT", sep="=")
            merge.add_multiple_options("I", input_bams, sep="=")

            merge.set_kwargs(TEMP_OUT_BAM=self.PIPE_FILE)

            command = ParallelCmds([merge.finalize(), command])

        CommandNode.__init__(self,
                             command=command,
                             description=description,
                             threads=threads,
                             dependencies=dependencies)
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:31,代码来源:picard.py

示例7: _setup

    def _setup(self, config, temp):
        with open(os.path.join(temp, "contigs.table"), "w") as handle:
            handle.write("ID\tSize\tNs\tHits\n")

            # Workaround for pysam < 0.9 returning list, >= 0.9 returning str
            for line in "".join(pysam.idxstats(self._input_file)).split('\n'):
                line = line.strip()
                if not line:
                    continue

                name, size, hits, _ = line.split('\t')
                name = contig_name_to_plink_name(name)
                if name is None or not (name.isdigit() or name == 'X'):
                    continue

                if int(size) != self._contigs[name]['Size']:
                    raise NodeError("TODO: size mismatch")

                row = {
                    'ID': name,
                    'Size': self._contigs[name]['Size'],
                    'Ns': self._contigs[name]['Ns'],
                    'Hits': hits,
                }

                handle.write('{ID}\t{Size}\t{Ns}\t{Hits}\n'.format(**row))

        CommandNode._setup(self, config, temp)
开发者ID:muslih14,项目名称:paleomix,代码行数:28,代码来源:nuclear.py

示例8: _setup

 def _setup(self, config, temp):
     CommandNode._setup(self, config, temp)
     for fname in ("3pGtoA_freq.txt", "5pCtoT_freq.txt", "dnacomp.txt",
                   "misincorporation.txt"):
         relpath = os.path.join(self._directory, fname)
         abspath = os.path.abspath(relpath)
         os.symlink(abspath, os.path.join(temp, fname))
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:7,代码来源:mapdamage.py

示例9: __init__

    def __init__(self, samples, treefile, bootstraps, output_prefix,
                 dependencies=()):
        rscript = rtools.rscript("zonkey", "tinytree.r")

        cmd = AtomicCmd(("Rscript", rscript,
                         "%(TEMP_OUT_FILE)s",
                         "%(IN_SAMPLES)s",
                         "%(TEMP_OUT_PREFIX)s"),
                        AUX_RSCRIPT=rscript,
                        IN_SAMPLES=samples,
                        IN_FILE=treefile,
                        IN_BOOTSTRAPS=bootstraps,
                        TEMP_OUT_FILE="rerooted.newick",
                        TEMP_OUT_PREFIX=os.path.basename(output_prefix),
                        OUT_TREE_PDF=output_prefix + ".pdf",
                        OUT_TREE_PNG=output_prefix + ".png",
                        CHECK_RSCRIPT=RSCRIPT_VERSION,
                        CHECK_RSCRIPT_APE=rtools.requirement("ape"),
                        CHECK_RSCRIPT_GGPLOT2=rtools.requirement("ggplot2"),
                        CHECK_RSCRIPT_GRID=rtools.requirement("grid"))

        self._treefile = treefile
        self._bootstraps = bootstraps

        CommandNode.__init__(self,
                             description="<DrawPhylogeny -> '%s.*'>"
                             % (output_prefix,),
                             command=cmd,
                             dependencies=dependencies)
开发者ID:muslih14,项目名称:paleomix,代码行数:29,代码来源:mitochondria.py

示例10: __init__

 def __init__(self, parameters):
     self._kwargs = parameters.command.kwargs
     CommandNode.__init__(self,
                          command      = parameters.command.finalize(),
                          description  = "<RAxMLReduce: '%s' -> '%s'>" \
                                  % (parameters.input_alignment, parameters.output_alignment),
                          dependencies = parameters.dependencies)
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:7,代码来源:raxml.py

示例11: _setup

    def _setup(self, config, temp):
        """See CommandNode._setup."""
        infile = os.path.abspath(self._infile)
        outfile = reroot_path(temp, self._infile)
        os.symlink(infile, outfile)

        CommandNode._setup(self, config, temp)
开发者ID:muslih14,项目名称:paleomix,代码行数:7,代码来源:samtools.py

示例12: __init__

    def __init__(self, infile, index_format='.bai', dependencies=()):
        basename = os.path.basename(infile)

        if index_format == '.bai':
            samtools_version = SAMTOOLS_VERSION
            samtools_call = ["samtools", "index", "%(TEMP_IN_BAM)s"]
        elif index_format == '.csi':
            samtools_version = SAMTOOLS_VERSION_1x
            samtools_call = ["samtools", "index", "-c", "%(TEMP_IN_BAM)s"]
        else:
            raise ValueError("Unknown format type %r; expected .bai or .csi"
                             % (index_format,))

        cmd_link = AtomicCmd(["ln", "-s", "%(IN_BAM)s", "%(TEMP_OUT_BAM)s"],
                             IN_BAM=infile,
                             TEMP_OUT_BAM=basename,
                             set_cwd=True)

        cmd_index = AtomicCmd(samtools_call,
                              TEMP_IN_BAM=basename,
                              CHECK_SAM=samtools_version)

        cmd_rename = AtomicCmd(["mv", "%(TEMP_IN_BAM)s", "%(OUT_BAM)s"],
                               TEMP_IN_BAM=basename + index_format,
                               OUT_BAM=swap_ext(infile, index_format))

        commands = SequentialCmds((cmd_link, cmd_index, cmd_rename))

        CommandNode.__init__(self,
                             description="<BAMIndex (%s): '%s'>"
                             % (index_format[1:].upper(), infile),
                             command=commands,
                             dependencies=dependencies)
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:33,代码来源:samtools.py

示例13: __init__

    def __init__(self, control_file, sequence_file, trees_file, output_tar,
                 exclude_groups=(), dependencies=()):
        self._exclude_groups = safe_coerce_to_frozenset(exclude_groups)
        self._control_file = control_file
        self._sequence_file = sequence_file
        self._trees_file = trees_file

        paml_cmd = AtomicCmd(["codeml", "template.ctl"],
                             IN_CONTROL_FILE  = control_file,
                             IN_SEQUENCE_FILE = sequence_file,
                             IN_TREES_FILE    = trees_file,
                             TEMP_OUT_CTL     = "template.ctl",
                             TEMP_OUT_SEQS    = "template.seqs",
                             TEMP_OUT_TREES   = "template.trees",
                             TEMP_OUT_STDOUT  = "template.stdout",
                             TEMP_OUT_STDERR  = "template.stderr",
                             TEMP_OUT_4FOLD   = "4fold.nuc",
                             IN_STDIN         = "/dev/null", # Prevent promts from blocking
                             set_cwd          = True,
                             **CodemlNode._get_codeml_files("TEMP_OUT_CODEML"))

        tar_pairs = CodemlNode._get_codeml_files("TEMP_IN_CODEML")
        tar_files = ["%%(%s)s" % (key,) for key in tar_pairs]
        tar_cmd  = AtomicCmd(["tar", "cvzf", "%(OUT_FILE)s"] + tar_files,
                             OUT_FILE = output_tar,
                             set_cwd  = True,
                             **tar_pairs)

        CommandNode.__init__(self,
                             description  = "<CodemlNode: %r -> %r>" % (sequence_file, output_tar),
                             command      = SequentialCmds([paml_cmd, tar_cmd]),
                             dependencies = dependencies)
开发者ID:muslih14,项目名称:paleomix,代码行数:32,代码来源:paml.py

示例14: _setup

    def _setup(self, config, temp):
        for key in ("IN_ALIGNMENT", "IN_PARTITION"):
            source      = os.path.abspath(self._kwargs[key])
            destination = os.path.join(temp, self._kwargs["TEMP_" + key])

            os.symlink(source, destination)

        CommandNode._setup(self, config, temp)
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:8,代码来源:raxml.py

示例15: _teardown

    def _teardown(self, config, temp):
        os.remove(os.path.join(temp, "RAxML_info.output"))

        source      = os.path.join(temp, "RAxML_parsimonyTree.output.0")
        destination = fileutils.reroot_path(temp, self._output_tree)
        fileutils.move_file(source, destination)

        CommandNode._teardown(self, config, temp)
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:8,代码来源:examl.py


注:本文中的paleomix.node.CommandNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。