예제 #1
0
    def test_write_chunks(self):
        def f(i):
            return {
                "{c}movie_fofn_id".format(c=PipelineChunk.CHUNK_KEY_PREFIX):
                "/path/to_movie-{i}.fofn".format(i=i),
                "{c}region_fofn_id".format(c=PipelineChunk.CHUNK_KEY_PREFIX):
                "/path/rgn_{i}.fofn".format(i=i)
            }

        def to_i(i):
            return "chunk-id-{i}".format(i=i)

        def to_p(i):
            return PipelineChunk(to_i(i), **f(i))

        nchunks = 5
        pipeline_chunks = [to_p(i) for i in range(nchunks)]
        log.debug(pipeline_chunks)
        tmp_dir = get_temp_dir("pipeline-chunks")
        tmp_name = get_temp_file("_chunk.json", tmp_dir)

        write_pipeline_chunks(pipeline_chunks, tmp_name, "Example chunk file")

        pchunks = load_pipeline_chunks_from_json(tmp_name)
        assert len(pchunks) == nchunks
    def test_01(self):
        file_name = "resolved_tool_contract_dev_app.json"
        rtc = load_resolved_tool_contract_from(get_data_file(file_name))
        self.assertIsInstance(rtc, ResolvedToolContract)

        d = get_temp_dir("rtc-app")
        f = get_temp_file("-resolved-tool-contract.avro", d)
        write_resolved_tool_contract_avro(rtc, f)
예제 #3
0
    def test_01(self):
        file_name = "resolved_tool_contract_dev_app.json"
        rtc = load_resolved_tool_contract_from(get_resolved_tool_contract(file_name))
        self.assertIsInstance(rtc, ResolvedToolContract)

        d = get_temp_dir("rtc-app")
        f = get_temp_file("-resolved-tool-contract.avro", d)
        write_resolved_tool_contract_avro(rtc, f)
예제 #4
0
    def test_simple_run_cmd(self):
        d = get_temp_dir("simple-cmd")
        txt_in = get_temp_file(".txt", d)
        txt_out = get_temp_file("*.txt", d)
        exe = "cat {i} > {o}".format(i=txt_in, o=txt_out)

        # this could all be bundled into a context manager
        # with RunCommand('/path/stdout', '/path/to/stderr') as r:
        #   r.exe("echo 'exe1')
        #   r.exe("echo 'exe2')
        #   result = r.get_result() # close the file handles
        stdout = get_temp_file("-stdout", d)
        stderr = get_temp_file("-stderr", d)
        with open(stdout, 'w') as fo:
            with open(stderr, 'w') as fe:
                result = run_cmd(exe, fo, fe)

        emgs = "Command {e} failed".format(e=exe)
        if result.exit_code != 0:
            print(emgs)
        assert result.exit_code == 0
    def test_write_chunks(self):

        def f(i):
            return {"{c}movie_fofn_id".format(c=PipelineChunk.CHUNK_KEY_PREFIX): "/path/to_movie-{i}.fofn".format(i=i),
                    "{c}region_fofn_id".format(c=PipelineChunk.CHUNK_KEY_PREFIX): "/path/rgn_{i}.fofn".format(i=i)}

        to_i = lambda i: "chunk-id-{i}".format(i=i)
        to_p = lambda i: PipelineChunk(to_i(i), **f(i))

        nchunks = 5
        pipeline_chunks = [to_p(i) for i in xrange(nchunks)]
        log.debug(pipeline_chunks)
        tmp_dir = get_temp_dir("pipeline-chunks")
        tmp_name = get_temp_file("_chunk.json", tmp_dir)

        write_pipeline_chunks(pipeline_chunks, tmp_name, "Example chunk file")

        pchunks = load_pipeline_chunks_from_json(tmp_name)
        self.assertEquals(len(pchunks), nchunks)