Ejemplo n.º 1
0
def test_sequential_commands__abort_on_error_3(temp_folder):
    cmd_1 = AtomicCmd("true")
    cmd_2 = AtomicCmd("true")
    cmd_3 = AtomicCmd("false")
    cmds = SequentialCmds([cmd_1, cmd_2, cmd_3])
    cmds.run(temp_folder)
    assert_equal(cmds.join(), [0, 0, 1])
Ejemplo n.º 2
0
def test_sequential_commands__abort_on_error_3(temp_folder):
    cmd_1 = AtomicCmd("true")
    cmd_2 = AtomicCmd("true")
    cmd_3 = AtomicCmd("false")
    cmds = SequentialCmds([cmd_1, cmd_2, cmd_3])
    cmds.run(temp_folder)
    assert_equal(cmds.join(), [0, 0, 1])
Ejemplo n.º 3
0
def test_sequential_commands__abort_on_error_1(temp_folder):
    cmd_1 = AtomicCmd("false")
    cmd_2 = AtomicCmd(("sleep", 10))
    cmd_3 = AtomicCmd(("sleep", 10))
    cmds = SequentialCmds([cmd_1, cmd_2, cmd_3])
    cmds.run(temp_folder)
    assert_equal(cmds.join(), [1, None, None])
Ejemplo n.º 4
0
def test_sequential_commands__abort_on_error_1(temp_folder):
    cmd_1 = AtomicCmd("false")
    cmd_2 = AtomicCmd(("sleep", 10))
    cmd_3 = AtomicCmd(("sleep", 10))
    cmds = SequentialCmds([cmd_1, cmd_2, cmd_3])
    cmds.run(temp_folder)
    assert_equal(cmds.join(), [1, None, None])
Ejemplo n.º 5
0
    def __init__(self, config, reference, input_files, output_file,
                 dependencies):
        cat_cmds, cat_obj = concatenate_input_bams(config, input_files)
        cmd_map = AtomicCmd([
            "mapDamage", "-n", _MAPDAMAGE_MAX_READS, "-i", "-", "-d",
            "%(TEMP_DIR)s", "-r", reference
        ],
                            IN_STDIN=cat_obj,
                            CHECK_VERSION=MAPDAMAGE_VERSION)
        train_cmds = ParallelCmds(cat_cmds + [cmd_map])

        cat_cmds, cat_obj = concatenate_input_bams(config, input_files)
        cmd_scale = AtomicCmd([
            "mapDamage", "--rescale-only", "-n", _MAPDAMAGE_MAX_READS, "-i",
            "-", "-d", "%(TEMP_DIR)s", "-r", reference, "--rescale-out",
            "%(OUT_BAM)s"
        ],
                              IN_STDIN=cat_obj,
                              OUT_BAM=output_file,
                              CHECK_VERSION=MAPDAMAGE_VERSION)
        rescale_cmds = ParallelCmds(cat_cmds + [cmd_scale])

        description = "<mapDamageRescale: %i file(s) -> '%s'>" % (
            len(input_files), output_file)
        CommandNode.__init__(self,
                             command=SequentialCmds([train_cmds,
                                                     rescale_cmds]),
                             description=description,
                             dependencies=dependencies)
Ejemplo n.º 6
0
def test_sequential_commands__atomiccmds():
    mocks = []
    for _ in range(3):
        cmd_mock = flexmock(AtomicCmd(["ls"]))
        cmd_mock.should_receive('run').with_args("xTMPx").once
        cmd_mock.should_receive('join').with_args().and_return([0]).twice
        mocks.append(cmd_mock)

    cmds = SequentialCmds(mocks)
    assert not cmds.ready()
    cmds.run("xTMPx")
    assert cmds.ready()
    assert_equal(cmds.join(), [0, 0, 0])
Ejemplo n.º 7
0
def test_sequential_commands__atomiccmds():
    mocks = []
    for _ in range(3):
        cmd_mock = flexmock(AtomicCmd(["ls"]))
        cmd_mock.should_receive('run').with_args("xTMPx").once
        cmd_mock.should_receive('join').with_args().and_return([0]).twice
        mocks.append(cmd_mock)

    cmds = SequentialCmds(mocks)
    assert not cmds.ready()
    cmds.run("xTMPx")
    assert cmds.ready()
    assert_equal(cmds.join(), [0, 0, 0])
Ejemplo n.º 8
0
def test_pformat__sets__nested():
    cmd_1 = AtomicCmd(("echo", "foo"), OUT_STDOUT=AtomicCmd.PIPE)
    cmd_2 = AtomicCmd("gzip", IN_STDIN=cmd_1)
    cmd_3 = AtomicCmd("sha1sum")
    set_1 = ParallelCmds((cmd_1, cmd_2))
    set_2 = SequentialCmds((set_1, cmd_3))
    assert_equal(pformat(set_2), ("<Sequential commands:\n"
                                  "  - Parallel commands:\n"
                                  "      - <00> Command = ['echo', 'foo']\n"
                                  "             STDOUT  = <01>\n"
                                  "             STDERR* = '${{TEMP_DIR}}/pipe_echo_{cmd_1_id}.stderr'\n"
                                  "      - <01> Command = ['gzip']\n"
                                  "             STDIN   = <00>\n"
                                  "             STDOUT* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2_id}.stdout'\n"
                                  "             STDERR* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2_id}.stderr'\n"
                                  "  - <02> Command = ['sha1sum']\n"
                                  "         STDOUT* = '${{TEMP_DIR}}/pipe_sha1sum_{cmd_3_id}.stdout'\n"
                                  "         STDERR* = '${{TEMP_DIR}}/pipe_sha1sum_{cmd_3_id}.stderr'>") \
                                  .format(cmd_1_id = id(cmd_1),
                                          cmd_2_id = id(cmd_2),
                                          cmd_3_id = id(cmd_3)))
Ejemplo n.º 9
0
def test_sequential_commands__reject_empty_commandset():
    SequentialCmds([])
Ejemplo n.º 10
0
def test_sequential_commands__reject_noncommand():
    SequentialCmds([object()])
Ejemplo n.º 11
0
def test_sequential_commands__accept_sequential():
    command = AtomicCmd(["ls"])
    seqcmd = SequentialCmds([command])
    SequentialCmds([seqcmd])
Ejemplo n.º 12
0
def test_sequential_commands__accept_parallel():
    command = AtomicCmd(["ls"])
    parcmd = ParallelCmds([command])
    SequentialCmds([parcmd])
Ejemplo n.º 13
0
def test_parallel_commands__reject_sequential():
    command = AtomicCmd(["ls"])
    seqcmd = SequentialCmds([command])
    assert_raises(CmdError, ParallelCmds, [seqcmd])