-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from bio-tools/dev
push v0.3.0 to master and pypi
- Loading branch information
Showing
31 changed files
with
2,099 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,263 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Protocol of experiments 01.06.2017" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"__Goals:__\n", | ||
" 1. Try out the proposed pipeline (see google slides)\n", | ||
" 1. Send file back to today from future." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"__Requirements:__\n", | ||
"1. Installed [Docker](https://store.docker.com/search?type=edition&offering=community) with the internet access\n", | ||
"1. Python3, pip\n", | ||
"1. Installed dependencies from requirements.txt \n", | ||
"1. Archive of the [Integron_Finder](https://github.com/gem-pasteur/Integron_Finder/archive/master.zip)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Again, we import the Container class from docker_wrapper module." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"exec(open('../tooldog/analyse/container.py').read())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"As in previous experiment we will define some useful constants and util functions for later use." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"def write_to_file(filename, string = ''):\n", | ||
" \"\"\"Write string to file\n", | ||
"\n", | ||
" :param str filename: Filename\n", | ||
" :param str string: String to write\n", | ||
" \"\"\"\n", | ||
" f = open(filename, 'w')\n", | ||
" f.write(string)\n", | ||
" f.close()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"PYTHON_VERSION = 2 # version of python tool" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"TOOL_NAME = 'gem-pasteur-Integron_Finder-4d54052' # name of the tool, assuming it is available via PyPi" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"OUTPUT_FORMAT = 'cwl' # output: cwl / xml" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"OUTPUT_FILENAME = TOOL_NAME + \".\" + OUTPUT_FORMAT # output filename" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"PYTHON_PATH = \"/usr/local/lib/python3.5/dist-packages/\" if PYTHON_VERSION == 3 else \\\n", | ||
"\"/usr/local/lib/python2.7/dist-packages/\" # PYTHONPATH, required for argparse2tool" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"CURRENT_PATH = os.path.realpath(os.getcwd())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Now we are ready to create a container." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"c = Container(\"inkuzm/tooldog-analyser-sandbox\",\n", | ||
" \"tail -f /dev/null\", # run until we will stop the container\n", | ||
" environment={'PYTHONPATH': PYTHON_PATH})" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Put tarball inside the container. For this we will:\n", | ||
" * Download tarball https://api.github.com/repos/gem-pasteur/Integron_Finder/tarball" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"c.put(CURRENT_PATH + \"/tool.tar\", \"/\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Let's create an executional context and a helper to execute the commands in it." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"WORKDIR = \"/\" + TOOL_NAME" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def cd(path, cmd):\n", | ||
" return \"bash -c 'cd \" + path + \" && \" + cmd + \"'\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Let's do it!" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cwl_tool = '' \n", | ||
"with c:\n", | ||
" exe1 = c.exec(cd(WORKDIR, \"pip2 install .\"))\n", | ||
" for line in exe1:\n", | ||
" print(line)\n", | ||
" \n", | ||
" exe2 = c.exec(cd(WORKDIR, \"pip2 install argparse2tool\"))\n", | ||
" for line in exe2:\n", | ||
" print(line)\n", | ||
" \n", | ||
" exe3 = c.exec(cd(WORKDIR, 'integron_finder --generate_cwl_tool')) # TODO: find a way to get the toolname\n", | ||
" for line in exe3:\n", | ||
" cwl_tool += line.decode(\"utf-8\")[:-1]\n", | ||
" \n", | ||
" write_to_file(OUTPUT_FILENAME, cwl_tool)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 1 | ||
} |
Oops, something went wrong.