Protocol of experiments 31.05.2017

Goal: Test more tools.

Requirements:

  1. Installed Docker with the internet access
  2. Python3, pip
  3. Installed dependencies from requirements.txt

We import the Container class from docker_wrapper module.


In [ ]:
exec(open('../tooldog/analyse/container.py').read())

As in previous experiment we will define some useful constants and util functions for later use.


In [ ]:
def write_to_file(filename, string = ''):
    """Write string to file

    :param str filename: Filename
    :param str string: String to write
    """
    f = open(filename, 'w')
    f.write(string)
    f.close()

In [ ]:
PYTHON_VERSION = 2 # version of python tool

In [ ]:
TOOL_NAME = 'integron_finder' # name of the tool, assuming it is available via PyPi

In [ ]:
OUTPUT_FORMAT = 'cwl' # output: cwl / xml

In [ ]:
OUTPUT_FILENAME = TOOL_NAME + "." + OUTPUT_FORMAT # output filename

In [ ]:
PYTHON_PATH = "/usr/local/lib/python3.5/dist-packages/" if PYTHON_VERSION == 3 else \
"/usr/local/lib/python2.7/dist-packages/" # PYTHONPATH, required for argparse2tool

Now we are ready to create a container.


In [ ]:
c = Container("inkuzm/tooldog-analyser-sandbox",
              "tail -f /dev/null",  # run until we will stop the container
              environment={'PYTHONPATH': PYTHON_PATH})

Let's create an executional context.


In [ ]:
cwl_tool = '' 
with c:
    exe1 = c.exec("pip2 install argparse2tool")
    for line in exe1:
        print(line)
    exe2 = c.exec('pip2 install ' + TOOL_NAME)
    for line in exe2:
        print(line)
    exe3 = c.exec(TOOL_NAME + ' --generate_cwl_tool')
    for line in exe3:
        cwl_tool += line.decode("utf-8")[:-1]

In [ ]:
write_to_file(OUTPUT_FILENAME, cwl_tool)

In [ ]: