예제 #1
0
    def customize(cls,
                  input_alignment,
                  input_partitions,
                  output_tree,
                  dependencies=()):
        command = AtomicCmdBuilder("raxmlHPC")

        # Compute a randomized parsimony starting tree
        command.set_option("-y")
        # Output files are saved with a .Pypeline postfix, and subsequently renamed
        command.set_option("-n", "Pypeline")
        # Model required, but not used
        command.set_option("-m", "GTRGAMMA")
        # Ensures that output is saved to the temporary directory
        command.set_option("-w", "%(TEMP_DIR)s")
        # Set random seed for bootstrap generation. May be set to a fixed value to allow replicability.
        command.set_option("-p", int(random.random() * 2**31 - 1), fixed=False)

        # Symlink to sequence and partitions, to prevent the creation of *.reduced files outside temp folder
        command.set_option("-s", "%(TEMP_OUT_ALIGNMENT)s")
        command.set_option("-q", "%(TEMP_OUT_PARTITION)s")

        command.set_kwargs(
            IN_ALIGNMENT=input_alignment,
            IN_PARTITION=input_partitions,

            # TEMP_OUT_ is used to automatically remove these files
            TEMP_OUT_ALIGNMENT="RAxML_alignment",
            TEMP_OUT_PARTITION="RAxML_partitions",
            TEMP_OUT_INFO="RAxML_info.Pypeline",
            OUT_TREE=output_tree,
            CHECK_VERSION=RAXML_VERSION)

        return {"command": command}
예제 #2
0
    def customize(cls, input_alignment, input_partition, output_file, dependencies = ()):
        """
        Arguments:
        input_alignment  -- An alignment file in a format readable by RAxML.
        input_partition  -- A set of partitions in a format readable by RAxML.
        output_filename  -- Filename for the output binary sequence."""

        command = AtomicCmdBuilder("examlParser", set_cwd = True)

        command.set_option("-s", "%(TEMP_OUT_ALN)s")
        command.set_option("-q", "%(TEMP_OUT_PART)s")
        # Output file will be named output.binary, and placed in the CWD
        command.set_option("-n", "output")

        # Substitution model
        command.set_option("-m", "DNA", fixed = False)


        command.set_kwargs(# Auto-delete: Symlinks
                          TEMP_OUT_PART   = os.path.basename(input_partition),
                          TEMP_OUT_ALN    = os.path.basename(input_alignment),

                          # Input files, are not used directly (see below)
                          IN_ALIGNMENT    = input_alignment,
                          IN_PARTITION    = input_partition,

                          # Final output file, are not created directly
                          OUT_BINARY      = output_file,

                          CHECK_EXAML     = PARSER_VERSION)

        return {"command" : command}
예제 #3
0
파일: raxml.py 프로젝트: schae234/pypeline
    def customize(cls,
                  input_alignment,
                  input_partition,
                  output_template,
                  threads=1,
                  dependencies=()):
        """
        Arguments:
        input_alignment  -- An alignment file in a format readable by RAxML.
        input_partition  -- A set of partitions in a format readable by RAxML.
        output_template  -- A template string used to construct final filenames. Should consist
                            of a full path, including a single '%s', which is replaced with the
                            variable part of RAxML output files (e.g. 'info', 'bestTree', ...).
                            Example destination: '/disk/project/SN013420.RAxML.%s'
                            Example output:      '/disk/project/SN013420.RAxML.bestTree'"""

        if threads > 1:
            command = AtomicCmdBuilder("raxmlHPC-PTHREADS")
            command.set_option("-T", threads)
        else:
            command = AtomicCmdBuilder("raxmlHPC")

        # Perform rapid bootstrapping
        command.set_option("-f", "a")
        # Output files are saved with a .Pypeline postfix, and subsequently renamed
        command.set_option("-n", "Pypeline")
        # Ensures that output is saved to the temporary directory
        command.set_option("-w", "%(TEMP_DIR)s")
        # Symlink to sequence and partitions, to prevent the creation of *.reduced files outside temp folder
        # In addition, it may be nessesary to remove the .reduced files if created
        command.set_option("-s", "%(TEMP_OUT_ALN)s")
        command.set_option("-q", "%(TEMP_OUT_PART)s")

        command.set_kwargs(  # Auto-delete: Symlinks and .reduced files that RAxML may generate
            TEMP_OUT_PART=os.path.basename(input_partition),
            TEMP_OUT_PART_R=os.path.basename(input_partition) + ".reduced",
            TEMP_OUT_ALN=os.path.basename(input_alignment),
            TEMP_OUT_ALN_R=os.path.basename(input_alignment) + ".reduced",

            # Input files, are not used directly (see below)
            IN_ALIGNMENT=input_alignment,
            IN_PARTITION=input_partition,

            # Final output files, are not created directly
            OUT_INFO=output_template % "info",
            OUT_BESTTREE=output_template % "bestTree",
            OUT_BOOTSTRAP=output_template % "bootstrap",
            OUT_BIPART=output_template % "bipartitions",
            OUT_BIPARTLABEL=output_template % "bipartitionsBranchLabels")

        # Use the GTRGAMMAI model of NT substitution by default
        command.set_option("-m", "GTRGAMMAI", fixed=False)
        # Enable Rapid Boostrapping and set random seed. May be set to a fixed value to allow replicability.
        command.set_option("-x", int(random.random() * 2**31 - 1), fixed=False)
        # Set random seed for parsimony inference. May be set to a fixed value to allow replicability.
        command.set_option("-p", int(random.random() * 2**31 - 1), fixed=False)
        # Terminate bootstrapping upon convergence, rather than after a fixed number of repetitions
        command.set_option("-N", "autoMRE", fixed=False)

        return {"command": command}
예제 #4
0
파일: raxml.py 프로젝트: schae234/pypeline
    def customize(cls,
                  input_alignment,
                  input_partition,
                  output_file,
                  dependencies=()):
        """
        Arguments:
        input_alignment  -- An alignment file in a format readable by RAxML.
        input_partition  -- A set of partitions in a format readable by RAxML.
        output_filename  -- Filename for the output binary sequence."""

        command = AtomicCmdBuilder("examlParser", set_cwd=True)

        command.set_option("-s", "%(TEMP_OUT_ALN)s")
        command.set_option("-q", "%(TEMP_OUT_PART)s")
        # Output file will be named output.binary, and placed in the CWD
        command.set_option("-n", "output")

        # Substitution model
        command.set_option("-m", "DNA", fixed=False)

        command.set_kwargs(  # Auto-delete: Symlinks
            TEMP_OUT_PART=os.path.basename(input_partition),
            TEMP_OUT_ALN=os.path.basename(input_alignment),

            # Input files, are not used directly (see below)
            IN_ALIGNMENT=input_alignment,
            IN_PARTITION=input_partition,

            # Final output file, are not created directly
            OUT_BINARY=output_file)

        return {"command": command}
예제 #5
0
def test_builder__set_kwargs__after_finalize():
    expected = {"IN_PATH" : "/a/b/"}
    builder = AtomicCmdBuilder("echo")
    builder.set_kwargs(IN_PATH = "/a/b/")
    builder.finalize()
    assert_raises(AtomicCmdBuilderError, builder.set_kwargs, OUT_PATH = "/dst/file")
    assert_equal(builder.kwargs, expected)
예제 #6
0
파일: raxml.py 프로젝트: schae234/pypeline
    def customize(cls, input_alignment, input_partition, output_alignment, dependencies = ()):
        command = AtomicCmdBuilder("raxmlHPC", set_cwd = True)

        # Read and (in the case of empty columns) reduce input
        command.set_option("-f", "j")
        # Output files are saved with a .Pypeline postfix, and subsequently renamed
        command.set_option("-n", "Pypeline")
        # Model required, but not used
        command.set_option("-m", "GTRGAMMA")
        # Set random seed for bootstrap generation. May be set to a fixed value to allow replicability.
        command.set_option("-b", int(random.random() * 2**31 - 1), fixed = False)
        # Generate a single bootstrap alignment (makes growing the number of bootstraps easier).
        command.set_option("-N", 1, fixed = False)

        # Symlink to sequence and partitions, to prevent the creation of *.reduced files outside temp folder
        # In addition, it may be nessesary to remove the .reduced files if created
        command.set_option("-s", "input.alignment")
        command.set_option("-q", "input.partition")

        command.set_kwargs(IN_ALIGNMENT      = input_alignment,
                          IN_PARTITION      = input_partition,

                          OUT_ALIGNMENT     = output_alignment,
                          OUT_INFO          = fileutils.swap_ext(output_alignment, ".info"))

        return {"command" : command}
예제 #7
0
파일: raxml.py 프로젝트: CarlesV/paleomix
    def customize(cls, input_alignment, input_partitions, output_tree, dependencies = ()):
        command = AtomicCmdBuilder("raxmlHPC")

        # Compute a randomized parsimony starting tree
        command.set_option("-y")
        # Output files are saved with a .Pypeline postfix, and subsequently renamed
        command.set_option("-n", "Pypeline")
        # Model required, but not used
        command.set_option("-m", "GTRGAMMA")
        # Ensures that output is saved to the temporary directory
        command.set_option("-w", "%(TEMP_DIR)s")
        # Set random seed for bootstrap generation. May be set to a fixed value to allow replicability.
        command.set_option("-p", int(random.random() * 2**31 - 1), fixed = False)

        # Symlink to sequence and partitions, to prevent the creation of *.reduced files outside temp folder
        command.set_option("-s", "%(TEMP_OUT_ALIGNMENT)s")
        command.set_option("-q", "%(TEMP_OUT_PARTITION)s")

        command.set_kwargs(IN_ALIGNMENT       = input_alignment,
                           IN_PARTITION       = input_partitions,

                           # TEMP_OUT_ is used to automatically remove these files
                           TEMP_OUT_ALIGNMENT = "RAxML_alignment",
                           TEMP_OUT_PARTITION = "RAxML_partitions",
                           TEMP_OUT_INFO      = "RAxML_info.Pypeline",

                           OUT_TREE           = output_tree,

                           CHECK_VERSION      = RAXML_VERSION)

        return {"command" : command}
예제 #8
0
파일: raxml.py 프로젝트: CarlesV/paleomix
    def customize(cls, input_alignment, input_partition, output_alignment, output_partition, dependencies = ()):
        command = AtomicCmdBuilder("raxmlHPC")

        # Read and (in the case of empty columns) reduce input
        command.set_option("-f", "c")
        # Output files are saved with a .Pypeline postfix, and subsequently renamed
        command.set_option("-n", "Pypeline")
        # Model required, but not used
        command.set_option("-m", "GTRGAMMA")
        # Ensures that output is saved to the temporary directory
        command.set_option("-w", "%(TEMP_DIR)s")

        # Symlink to sequence and partitions, to prevent the creation of *.reduced files outside temp folder
        # In addition, it may be nessesary to remove the .reduced files if created
        command.set_option("-s", "%(TEMP_IN_ALIGNMENT)s")
        command.set_option("-q", "%(TEMP_IN_PARTITION)s")

        command.set_kwargs(IN_ALIGNMENT      = input_alignment,
                          IN_PARTITION      = input_partition,

                          TEMP_IN_ALIGNMENT = "RAxML_alignment",
                          TEMP_IN_PARTITION = "RAxML_partitions",
                          TEMP_OUT_INFO     = "RAxML_info.Pypeline",

                          OUT_ALIGNMENT     = output_alignment,
                          OUT_PARTITION     = output_partition,
                          CHECK_VERSION     = RAXML_VERSION)

        return {"command" : command}
예제 #9
0
파일: bowtie2.py 프로젝트: CarlesV/paleomix
def _bowtie2_template(call, prefix, iotype = "IN", **kwargs):
    params = AtomicCmdBuilder(call, **kwargs)
    for postfix in ("1.bt2", "2.bt2", "3.bt2", "4.bt2", "rev.1.bt2", "rev.2.bt2"):
        key = "%s_PREFIX_%s" % (iotype, postfix.upper())
        params.set_kwargs(**{key : (prefix + "." + postfix)})

    return params
예제 #10
0
파일: raxml.py 프로젝트: schae234/pypeline
    def customize(cls,
                  input_alignment,
                  input_partition,
                  output_alignment,
                  dependencies=()):
        command = AtomicCmdBuilder("raxmlHPC", set_cwd=True)

        # Read and (in the case of empty columns) reduce input
        command.set_option("-f", "j")
        # Output files are saved with a .Pypeline postfix, and subsequently renamed
        command.set_option("-n", "Pypeline")
        # Model required, but not used
        command.set_option("-m", "GTRGAMMA")
        # Set random seed for bootstrap generation. May be set to a fixed value to allow replicability.
        command.set_option("-b", int(random.random() * 2**31 - 1), fixed=False)
        # Generate a single bootstrap alignment (makes growing the number of bootstraps easier).
        command.set_option("-N", 1, fixed=False)

        # Symlink to sequence and partitions, to prevent the creation of *.reduced files outside temp folder
        # In addition, it may be nessesary to remove the .reduced files if created
        command.set_option("-s", "input.alignment")
        command.set_option("-q", "input.partition")

        command.set_kwargs(IN_ALIGNMENT=input_alignment,
                           IN_PARTITION=input_partition,
                           OUT_ALIGNMENT=output_alignment,
                           OUT_INFO=fileutils.swap_ext(output_alignment,
                                                       ".info"))

        return {"command": command}
예제 #11
0
파일: raxml.py 프로젝트: CarlesV/paleomix
    def customize(cls, input_alignment, input_partition, template, start = 0, bootstraps = 50, dependencies = ()):
        command = AtomicCmdBuilder("raxmlHPC", set_cwd = True)

        # Read and (in the case of empty columns) reduce input
        command.set_option("-f", "j")
        # Output files are saved with a .Pypeline postfix, and subsequently renamed
        command.set_option("-n", "Pypeline")
        # Model required, but not used
        command.set_option("-m", "GTRGAMMA")
        # Set random seed for bootstrap generation. May be set to a fixed value to allow replicability.
        command.set_option("-b", int(random.random() * 2**31 - 1), fixed = False)
        # Generate a single bootstrap alignment (makes growing the number of bootstraps easier).
        command.set_option("-N", int(bootstraps), fixed = False)

        # Symlink to sequence and partitions, to prevent the creation of *.reduced files outside temp folder
        # In addition, it may be nessesary to remove the .reduced files if created
        command.set_option("-s", "input.alignment")
        command.set_option("-q", "input.partition")

        bootstrap_files = {"IN_ALIGNMENT" : input_alignment,
                           "IN_PARTITION" : input_partition,
                           "TEMP_OUT_INF" : "RAxML_info.Pypeline",
                           "TEMP_OUT_ALN" : "input.alignment",
                           "TEMP_OUT_PAR" : "input.partition",
                           "CHECK_VERSION": RAXML_VERSION}

        for (index, (_, filename)) in enumerate(cls._bootstraps(template, bootstraps, start)):
            bootstrap_files["OUT_BS_%03i" % index] = filename
        command.set_kwargs(**bootstrap_files)

        return {"command" : command}
예제 #12
0
파일: raxml.py 프로젝트: schae234/pypeline
    def customize(cls,
                  input_alignment,
                  input_partition,
                  output_alignment,
                  output_partition,
                  dependencies=()):
        command = AtomicCmdBuilder("raxmlHPC")

        # Read and (in the case of empty columns) reduce input
        command.set_option("-f", "c")
        # Output files are saved with a .Pypeline postfix, and subsequently renamed
        command.set_option("-n", "Pypeline")
        # Model required, but not used
        command.set_option("-m", "GTRGAMMA")
        # Ensures that output is saved to the temporary directory
        command.set_option("-w", "%(TEMP_DIR)s")

        # Symlink to sequence and partitions, to prevent the creation of *.reduced files outside temp folder
        # In addition, it may be nessesary to remove the .reduced files if created
        command.set_option("-s", "%(TEMP_IN_ALIGNMENT)s")
        command.set_option("-q", "%(TEMP_IN_PARTITION)s")

        command.set_kwargs(IN_ALIGNMENT=input_alignment,
                           IN_PARTITION=input_partition,
                           TEMP_IN_ALIGNMENT="RAXML_alignment",
                           TEMP_IN_PARTITION="RAXML_partitions",
                           TEMP_OUT_INFO="RAxML_info.Pypeline",
                           OUT_ALIGNMENT=output_alignment,
                           OUT_PARTITION=output_partition)

        return {"command": command}
예제 #13
0
파일: raxml.py 프로젝트: CarlesV/paleomix
    def customize(cls, input_alignment, input_partition, output_template, threads = 1, dependencies = ()):
        """
        Arguments:
        input_alignment  -- An alignment file in a format readable by RAxML.
        input_partition  -- A set of partitions in a format readable by RAxML.
        output_template  -- A template string used to construct final filenames. Should consist
                            of a full path, including a single '%s', which is replaced with the
                            variable part of RAxML output files (e.g. 'info', 'bestTree', ...).
                            Example destination: '/disk/project/SN013420.RAxML.%s'
                            Example output:      '/disk/project/SN013420.RAxML.bestTree'"""

        if threads > 1:
            command = AtomicCmdBuilder("raxmlHPC-PTHREADS")
            command.set_option("-T", threads)
            version = RAXML_PTHREADS_VERSION
        else:
            command = AtomicCmdBuilder("raxmlHPC")
            version = RAXML_VERSION

        # Perform rapid bootstrapping
        command.set_option("-f", "a")
        # Output files are saved with a .Pypeline postfix, and subsequently renamed
        command.set_option("-n", "Pypeline")
        # Ensures that output is saved to the temporary directory
        command.set_option("-w", "%(TEMP_DIR)s")
        # Symlink to sequence and partitions, to prevent the creation of *.reduced files outside temp folder
        # In addition, it may be nessesary to remove the .reduced files if created
        command.set_option("-s", "%(TEMP_OUT_ALN)s")
        command.set_option("-q", "%(TEMP_OUT_PART)s")

        command.set_kwargs(# Auto-delete: Symlinks and .reduced files that RAxML may generate
                          TEMP_OUT_PART   = os.path.basename(input_partition),
                          TEMP_OUT_PART_R = os.path.basename(input_partition) + ".reduced",
                          TEMP_OUT_ALN    = os.path.basename(input_alignment),
                          TEMP_OUT_ALN_R  = os.path.basename(input_alignment) + ".reduced",

                          # Input files, are not used directly (see below)
                          IN_ALIGNMENT    = input_alignment,
                          IN_PARTITION    = input_partition,

                          # Final output files, are not created directly
                          OUT_INFO        = output_template % "info",
                          OUT_BESTTREE    = output_template % "bestTree",
                          OUT_BOOTSTRAP   = output_template % "bootstrap",
                          OUT_BIPART      = output_template % "bipartitions",
                          OUT_BIPARTLABEL = output_template % "bipartitionsBranchLabels",

                          CHECK_VERSION   = version)

        # Use the GTRGAMMAI model of NT substitution by default
        command.set_option("-m", "GTRGAMMAI", fixed = False)
        # Enable Rapid Boostrapping and set random seed. May be set to a fixed value to allow replicability.
        command.set_option("-x", int(random.random() * 2**31 - 1), fixed = False)
        # Set random seed for parsimony inference. May be set to a fixed value to allow replicability.
        command.set_option("-p", int(random.random() * 2**31 - 1), fixed = False)
        # Terminate bootstrapping upon convergence, rather than after a fixed number of repetitions
        command.set_option("-N", "autoMRE", fixed = False)

        return {"command"         : command}
예제 #14
0
def _bowtie2_template(call, prefix, iotype="IN", **kwargs):
    params = AtomicCmdBuilder(call, **kwargs)
    for postfix in ("1.bt2", "2.bt2", "3.bt2", "4.bt2", "rev.1.bt2",
                    "rev.2.bt2"):
        key = "%s_PREFIX_%s" % (iotype, postfix.upper())
        params.set_kwargs(**{key: (prefix + "." + postfix)})

    return params
예제 #15
0
def test_builder__set__kwargs__overwriting():
    expected = {"IN_PATH": "/a/b/"}
    builder = AtomicCmdBuilder("echo")
    builder.set_kwargs(IN_PATH="/a/b/")
    assert_raises(AtomicCmdBuilderError,
                  builder.set_kwargs,
                  IN_PATH="/dst/file")
    assert_equal(builder.kwargs, expected)
예제 #16
0
    def customize(cls, input_file, output_file, algorithm = "auto", dependencies = ()):
        command = AtomicCmdBuilder(_PRESETS[algorithm.lower()])
        command.add_value("%(IN_FASTA)s")
        command.set_kwargs(IN_FASTA   = input_file,
                           OUT_STDOUT = output_file,
                           CHECK_VERSION = MAFFT_VERSION)

        return {"command"      : command,
                "dependencies" : dependencies}
예제 #17
0
def test_builder__set_kwargs__after_finalize():
    expected = {"IN_PATH": "/a/b/"}
    builder = AtomicCmdBuilder("echo")
    builder.set_kwargs(IN_PATH="/a/b/")
    builder.finalize()
    assert_raises(AtomicCmdBuilderError,
                  builder.set_kwargs,
                  OUT_PATH="/dst/file")
    assert_equal(builder.kwargs, expected)
예제 #18
0
파일: bwa.py 프로젝트: schae234/pypeline
def _get_bwa_template(call, prefix, iotype = "IN", **kwargs):
    extensions = ["amb", "ann", "bwt", "pac", "sa"]
    try:
        if BWA_VERSION.version < (0, 6, 0):
            extensions.extend(("rbwt", "rpac", "rsa"))
    except versions.VersionRequirementError:
        pass # Ignored here, handled elsewhere

    params = AtomicCmdBuilder(call, **kwargs)
    for postfix in extensions:
        key = "%s_PREFIX_%s" % (iotype, postfix.upper())
        params.set_kwargs(**{key : (prefix + "." + postfix)})

    return params
예제 #19
0
파일: bwa.py 프로젝트: health1987/paleomix
def _get_bwa_template(call, prefix, iotype="IN", **kwargs):
    extensions = ["amb", "ann", "bwt", "pac", "sa"]
    try:
        if BWA_VERSION.version < (0, 6, 0):
            extensions.extend(("rbwt", "rpac", "rsa"))
    except versions.VersionRequirementError:
        pass  # Ignored here, handled elsewhere

    params = AtomicCmdBuilder(call, **kwargs)
    for postfix in extensions:
        key = "%s_PREFIX_%s" % (iotype, postfix.upper())
        params.set_kwargs(**{key: (prefix + "." + postfix)})

    return params
예제 #20
0
def test_builder__finalize__calls_atomiccmd():
    was_called = []
    class _AtomicCmdMock:
        def __init__(self, *args, **kwargs):
            assert_equal(args, (["echo", "-out", "%(OUT_FILE)s", "%(IN_FILE)s"],))
            assert_equal(kwargs, {"IN_FILE" : "/in/file", "OUT_FILE" : "/out/file", "set_cwd" : True})
            was_called.append(True)

    with Monkeypatch("pypeline.atomiccmd.builder.AtomicCmd", _AtomicCmdMock):
        builder = AtomicCmdBuilder("echo", set_cwd = True)
        builder.add_option("-out", "%(OUT_FILE)s")
        builder.add_value("%(IN_FILE)s")
        builder.set_kwargs(OUT_FILE = "/out/file",
                           IN_FILE  = "/in/file")

        builder.finalize()
        assert was_called
예제 #21
0
    def customize(cls,
                  input_alignment,
                  input_partition,
                  template,
                  start=0,
                  bootstraps=50,
                  dependencies=()):
        command = AtomicCmdBuilder("raxmlHPC", set_cwd=True)

        # Read and (in the case of empty columns) reduce input
        command.set_option("-f", "j")
        # Output files are saved with a .Pypeline postfix, and subsequently renamed
        command.set_option("-n", "Pypeline")
        # Model required, but not used
        command.set_option("-m", "GTRGAMMA")
        # Set random seed for bootstrap generation. May be set to a fixed value to allow replicability.
        command.set_option("-b", int(random.random() * 2**31 - 1), fixed=False)
        # Generate a single bootstrap alignment (makes growing the number of bootstraps easier).
        command.set_option("-N", int(bootstraps), fixed=False)

        # Symlink to sequence and partitions, to prevent the creation of *.reduced files outside temp folder
        # In addition, it may be nessesary to remove the .reduced files if created
        command.set_option("-s", "input.alignment")
        command.set_option("-q", "input.partition")

        bootstrap_files = {
            "IN_ALIGNMENT": input_alignment,
            "IN_PARTITION": input_partition,
            "TEMP_OUT_INF": "RAxML_info.Pypeline",
            "TEMP_OUT_ALN": "input.alignment",
            "TEMP_OUT_PAR": "input.partition",
            "CHECK_VERSION": RAXML_VERSION
        }

        for (index, (_, filename)) in enumerate(
                cls._bootstraps(template, bootstraps, start)):
            bootstrap_files["OUT_BS_%03i" % index] = filename
        command.set_kwargs(**bootstrap_files)

        return {"command": command}
예제 #22
0
def test_builder__finalize__calls_atomiccmd():
    was_called = []

    class _AtomicCmdMock:
        def __init__(self, *args, **kwargs):
            assert_equal(args,
                         (["echo", "-out", "%(OUT_FILE)s", "%(IN_FILE)s"], ))
            assert_equal(kwargs, {
                "IN_FILE": "/in/file",
                "OUT_FILE": "/out/file",
                "set_cwd": True
            })
            was_called.append(True)

    with Monkeypatch("pypeline.atomiccmd.builder.AtomicCmd", _AtomicCmdMock):
        builder = AtomicCmdBuilder("echo", set_cwd=True)
        builder.add_option("-out", "%(OUT_FILE)s")
        builder.add_value("%(IN_FILE)s")
        builder.set_kwargs(OUT_FILE="/out/file", IN_FILE="/in/file")

        builder.finalize()
        assert was_called
예제 #23
0
    def customize(cls, input_alignment, output_tree, dependencies = ()):
        """
        Arguments:
        input_alignment  -- An alignment file in a format readable by RAxML.
        output_tree      -- Filename for the output newick tree."""

        command = AtomicCmdBuilder("parsimonator", set_cwd = True)

        command.set_option("-s", "%(TEMP_OUT_ALN)s")
        command.set_option("-n", "output")
        # Random seed for the stepwise addition process
        command.set_option("-p", int(random.random() * 2**31 - 1), fixed = False)

        command.set_kwargs(# Auto-delete: Symlinks
                          TEMP_OUT_ALN   = os.path.basename(input_alignment),

                          # Input files, are not used directly (see below)
                          IN_ALIGNMENT    = input_alignment,

                          # Final output file, are not created directly
                          OUT_TREE       = output_tree)

        return {"command"         : command}
예제 #24
0
    def __init__(self, d_bam, dependencies):
        aux_r = os.path.join(os.path.dirname(gccorrect.__file__), 'model_gc.R')
        dest = os.path.join(d_bam.bam_output,
                            '%s_GC_Model.txt' % (str(d_bam.bam_name)))
        plot_dest = os.path.splitext(dest)[0] + '.pdf'
        infiles = [''.join(n.output_files) for n in dependencies]
        builder = AtomicCmdBuilder(("Rscript", "%(AUX_R)s"))
        builder.add_value('%(OUT_FILEPATH)s')
        builder.add_value('%(OUT_PLOT)s')
        builder.add_multiple_values(infiles)
        builder.set_kwargs(AUX_R=aux_r,
                           OUT_FILEPATH=dest,
                           OUT_PLOT=plot_dest,
                           CHECK_VERSION=Rscript_VERSION)
        cmd = builder.finalize()

        d_bam.opts['BamInfo']['--GCmodel'] = dest
        description = "<CreateGCModel: '%s' -> '%s'" % (d_bam.bam_temp_local,
                                                        dest)
        CommandNode.__init__(self,
                             description=description,
                             command=cmd,
                             dependencies=dependencies)
예제 #25
0
파일: raxml.py 프로젝트: schae234/pypeline
    def customize(cls, input_alignment, output_tree, dependencies=()):
        """
        Arguments:
        input_alignment  -- An alignment file in a format readable by RAxML.
        output_tree      -- Filename for the output newick tree."""

        command = AtomicCmdBuilder("parsimonator", set_cwd=True)

        command.set_option("-s", "%(TEMP_OUT_ALN)s")
        command.set_option("-n", "output")
        # Random seed for the stepwise addition process
        command.set_option("-p", int(random.random() * 2**31 - 1), fixed=False)

        command.set_kwargs(  # Auto-delete: Symlinks
            TEMP_OUT_ALN=os.path.basename(input_alignment),

            # Input files, are not used directly (see below)
            IN_ALIGNMENT=input_alignment,

            # Final output file, are not created directly
            OUT_TREE=output_tree)

        return {"command": command}
예제 #26
0
파일: bwa.py 프로젝트: schae234/pypeline
def _process_output(stdin, output_file, reference, run_fixmate = False):
    convert = AtomicCmdBuilder("safeSAM2BAM")
    convert.set_option("--flag-as-sorted")
    convert.set_option("-F", "0x4", sep = "", fixed = False) # Remove misses
    convert.set_kwargs(IN_STDIN    = stdin,
                      OUT_STDOUT  = AtomicCmd.PIPE,
                      CHECK_PYSAM = PYSAM_VERSION,
                      CHECK_SAMTOOLS = SAMTOOLS_VERSION)

    fixmate = None
    if run_fixmate:
        fixmate = AtomicCmdBuilder(("samtools", "fixmate", "-", "-"),
                               IN_STDIN   = convert,
                               OUT_STDOUT = AtomicCmd.PIPE,
                               CHECK_SAMTOOLS = SAMTOOLS_VERSION)

    sort = AtomicCmdBuilder(("samtools", "sort"))
    sort.set_option("-o") # Output to STDOUT on completion
    sort.add_value("-")
    sort.add_value("%(TEMP_OUT_BAM)s")
    sort.set_kwargs(IN_STDIN     = fixmate or convert,
                   OUT_STDOUT   = AtomicCmd.PIPE,
                   TEMP_OUT_BAM = "sorted",
                   CHECK_SAM = SAMTOOLS_VERSION)

    calmd = AtomicCmdBuilder(("samtools", "calmd"))
    calmd.add_value("-")
    calmd.add_value("%(IN_REF)s")
    calmd.set_option("-b") # Output BAM
    calmd.set_kwargs(IN_REF   = reference,
                    IN_STDIN = sort,
                    OUT_STDOUT = output_file,
                    CHECK_SAM = SAMTOOLS_VERSION)

    order = ["convert", "sort", "calmd"]
    commands = {"convert" : convert,
                "sort"    : sort,
                "calmd"   : calmd}

    if run_fixmate:
        order.insert(1, "fixmate")
        commands["fixmate"] = fixmate

    return order, commands
예제 #27
0
파일: bwa.py 프로젝트: schae234/pypeline
def _process_output(stdin, output_file, reference, run_fixmate=False):
    convert = AtomicCmdBuilder("safeSAM2BAM")
    convert.set_option("--flag-as-sorted")
    convert.set_option("-F", "0x4", sep="", fixed=False)  # Remove misses
    convert.set_kwargs(IN_STDIN=stdin,
                       OUT_STDOUT=AtomicCmd.PIPE,
                       CHECK_PYSAM=PYSAM_VERSION,
                       CHECK_SAMTOOLS=SAMTOOLS_VERSION)

    fixmate = None
    if run_fixmate:
        fixmate = AtomicCmdBuilder(("samtools", "fixmate", "-", "-"),
                                   IN_STDIN=convert,
                                   OUT_STDOUT=AtomicCmd.PIPE,
                                   CHECK_SAMTOOLS=SAMTOOLS_VERSION)

    sort = AtomicCmdBuilder(("samtools", "sort"))
    sort.set_option("-o")  # Output to STDOUT on completion
    sort.add_value("-")
    sort.add_value("%(TEMP_OUT_BAM)s")
    sort.set_kwargs(IN_STDIN=fixmate or convert,
                    OUT_STDOUT=AtomicCmd.PIPE,
                    TEMP_OUT_BAM="sorted",
                    CHECK_SAM=SAMTOOLS_VERSION)

    calmd = AtomicCmdBuilder(("samtools", "calmd"))
    calmd.add_value("-")
    calmd.add_value("%(IN_REF)s")
    calmd.set_option("-b")  # Output BAM
    calmd.set_kwargs(IN_REF=reference,
                     IN_STDIN=sort,
                     OUT_STDOUT=output_file,
                     CHECK_SAM=SAMTOOLS_VERSION)

    order = ["convert", "sort", "calmd"]
    commands = {"convert": convert, "sort": sort, "calmd": calmd}

    if run_fixmate:
        order.insert(1, "fixmate")
        commands["fixmate"] = fixmate

    return order, commands
예제 #28
0
def test_builder__set_kwargs__called_twice():
    expected = {"IN_PATH": "/a/b/", "OUT_PATH": "/dst/file"}
    builder = AtomicCmdBuilder("echo")
    builder.set_kwargs(OUT_PATH="/dst/file")
    builder.set_kwargs(IN_PATH="/a/b/")
    assert_equal(builder.kwargs, expected)
예제 #29
0
def test_builder__set_kwargs__called_twice():
    expected = {"IN_PATH" : "/a/b/", "OUT_PATH" : "/dst/file"}
    builder = AtomicCmdBuilder("echo")
    builder.set_kwargs(OUT_PATH = "/dst/file")
    builder.set_kwargs(IN_PATH = "/a/b/")
    assert_equal(builder.kwargs, expected)
예제 #30
0
def test_builder__set__kwargs__overwriting():
    expected = {"IN_PATH" : "/a/b/"}
    builder = AtomicCmdBuilder("echo")
    builder.set_kwargs(IN_PATH = "/a/b/")
    assert_raises(AtomicCmdBuilderError, builder.set_kwargs, IN_PATH = "/dst/file")
    assert_equal(builder.kwargs, expected)