diff --git a/.gitignore b/.gitignore index c9dca6c..8070d61 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,7 @@ nosetests.xml .pydevproject # Temp files - +.vscode/ *~ # Pipy codes diff --git a/.travis.yml b/.travis.yml index bcdb42d..7415bcb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,12 @@ python: - "3.6" # command to install dependencies install: + - pip install coveralls pytest-cov==2.6 pytest==3.2.3 - pip install -e . # command to run tests -script: pytest +script: + - python -m pytest -v --cov bioprinter --cov-report term-missing + +after_success: + - coveralls + \ No newline at end of file diff --git a/LICENCE.txt b/LICENCE.txt index eb3ae11..9c9818f 100644 --- a/LICENCE.txt +++ b/LICENCE.txt @@ -1,9 +1,6 @@ -The MIT License (MIT) -[OSI Approved License] +MIT License -The MIT License (MIT) - -Copyright (c) Edinburgh Genome Foundry 2015 +Copyright (c) 2015 Edinburgh Genome Foundry Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -12,14 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.rst b/README.rst index fbbc510..a10a330 100644 --- a/README.rst +++ b/README.rst @@ -1,33 +1,45 @@ +.. raw:: html + +

+ Bioprinter logo +

+

+ + BioPrinter -=========== +========== + .. image:: https://travis-ci.org/Edinburgh-Genome-Foundry/bioprinter.svg?branch=master :target: https://travis-ci.org/Edinburgh-Genome-Foundry/bioprinter :alt: Travis CI build status (Python 3) -Bioprinter (webpage here_ ) is a Python module to produce living art. It transforms an image into files that a liquid dispenser can use to *print* the image to a plate using pigmented yeast or bacteria. +.. image:: https://coveralls.io/repos/github/Edinburgh-Genome-Foundry/bioprinter/badge.svg?branch=master + :target: https://coveralls.io/github/Edinburgh-Genome-Foundry/bioprinter?branch=master + + +Bioprinter (webpage here_) is a Python package for producing living art. It transforms an image into files that a liquid dispenser can use to *print* the image to a plate using pigmented yeast or bacteria. Here are two examples of bio-art: .. figure:: https://raw.githubusercontent.com/Edinburgh-Genome-Foundry/bioprinter/master/docs/_static/images/bioprint_dolly.jpeg :align: center - Dolly drawn with baker yeast (white), violacein-producing yeast (black), and carotene-producing yeast (orange) + Dolly drawn with baker yeast (white), violacein-producing yeast (black), and carotene-producing yeast (orange). .. figure:: https://raw.githubusercontent.com/Edinburgh-Genome-Foundry/bioprinter/master/docs/_static/images/bioprint_england.jpeg :align: center - England flag drawn with 3 different strains of the bacterium *E. coli*. + British flag drawn with 3 different strains of the bacterium *E. coli*. These bio-prints (and many others!) were presented at the University of Edinburgh's SynthSys Open days 2016 (strain selection and acoustic printing by Paulina Kanigowska). -Bioprinter is released on Github_ under the MIT licence (¢ Edinburgh Genome Foundry), everyone is welcome to contribute ! +Bioprinter is released on Github_ under the MIT licence (Copyright 2015 Edinburgh Genome Foundry), everyone is welcome to contribute! -Bioprinter was written at the Edinburgh Genome Foundry by Zulko_ after an original idea and Matlab code by Mike Shen (`Mike's project on Github `_). +Bioprinter was written at the Edinburgh Genome Foundry by Zulko_ after an original idea and Matlab code by Mike Shen (`project on Github `_). Installation --------------- - +------------ If you have PIP installed: :: @@ -39,32 +51,32 @@ Or unzip the source code in a directory and type in a terminal: :: Usage --------- +----- -In the same folder as your code, place an image. It can have any resolution, but keep in mind that the width/height ratio of the plate it is printed on is 1.5. Make sure that a specific color is used to mark the un-pigmented background of the image, here we use blue: +The image file to be printed can have any resolution, but note that the width/height ratio of the plate the image is printed on is 1.5. Ensure that a specific color is used to mark the un-pigmented background of the image, here we use blue: .. figure:: https://raw.githubusercontent.com/Edinburgh-Genome-Foundry/bioprinter/master/docs/_static/images/dolly.jpeg :align: center -Then write the following code in ``dolly.py``: +Run the following code in Python or save in ``dolly.py``: .. code:: python from bioprinter import bioprint bioprint( - image_filename="../docs/_static/images/dolly.jpeg", + image_filename="/path/to/image/dolly.jpeg", output_filename="dolly.csv", - bg_color=[0, 0, 255], # blue background represents empty wells - pigments_wells={"A1": [0, 0, 0], # black yeast in source well A1 - "A2": [250, 120, 10], # orange yeast in well A2 - "A3": [255, 255, 255]}, # white yeast in well A3 + bg_color=[0, 0, 255], # blue background represents empty wells + pigments_wells={"A1": [0, 0, 0], # black yeast in source well A1 + "A2": [250, 120, 10], # orange yeast in well A2 + "A3": [255, 255, 255]}, # white yeast in well A3 quantified_image_filename="dolly_preview.jpeg" ) -Execute in a terminal with ``python dolly.py``. This will produce a ``dolly.csv`` file as well as a preview image of the final printing (so that you can check if the image looks good at this low resolution). +The saved script can be executed in a terminal with ``python dolly.py``. This will produce a ``dolly.csv`` file as well as a preview image of the final printing (so that you can check if the image looks good at this low resolution). -Prepare a source plate with the right pigmented yeasts in wells A1, A2, A3, use an agar plate as the destination plate, and feed ``dolly.csv`` to the `Labcyte Echo `_. Once the printing is finished, incubate 2 days at 30C (it would be one day at 37C for bacteria). Enjoy the result ! +Prepare a source plate with the right pigmented yeasts in wells A1, A2, A3, use an agar plate as the destination plate, and feed ``dolly.csv`` to the `Labcyte Echo Acoustic Liquid Handler `_ (tested with Labcyte Echo 555 Series). Once the printing is finished, incubate 2 days at 30C (it would be one day at 37C for bacteria). Enjoy the result! .. _here: http://edinburgh-genome-foundry.github.io/bioprinter/ diff --git a/bioprinter/__init__.py b/bioprinter/__init__.py index 017c139..3e9b3ff 100644 --- a/bioprinter/__init__.py +++ b/bioprinter/__init__.py @@ -14,4 +14,3 @@ from .bioprinter import bioprint from .version import __version__ - diff --git a/bioprinter/bioprinter.py b/bioprinter/bioprinter.py index bb2353c..69da28a 100644 --- a/bioprinter/bioprinter.py +++ b/bioprinter/bioprinter.py @@ -16,6 +16,7 @@ import numpy as np from PIL import Image + def _rownumber_to_rowname(num): """Return the row name corresponding to the row number. @@ -24,14 +25,22 @@ def _rownumber_to_rowname(num): if num < 26: return "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[num] else: - return "".join([_rownumber_to_rowname(int(num / 26) - 1), - _rownumber_to_rowname(num % 26)]) + return "".join( + [_rownumber_to_rowname(int(num / 26) - 1), _rownumber_to_rowname(num % 26)] + ) -def bioprint(image_filename, output_filename, bg_color, pigments_wells, - resolution=(192, 128), transfer_volume=2.5, - pigment_well_capacity=25000, transfer_rate=150, - quantified_image_filename=None): +def bioprint( + image_filename, + output_filename, + bg_color, + pigments_wells, + resolution=(192, 128), + transfer_volume=2.5, + pigment_well_capacity=25000, + transfer_rate=150, + quantified_image_filename=None, +): """Generate a CSV that can be used in the Echo to print the given picture. Example @@ -39,7 +48,7 @@ def bioprint(image_filename, output_filename, bg_color, pigments_wells, # Let's print the EGF logo ! bioprint( - img_filename = "egf_logo.jpeg", + image_filename = "egf_logo.jpeg", output_filename = "egf_logo.csv", bg_color=[255,255,255], # The background of the image is white pigments_wells= { "A1": [0,0,0], # black @@ -82,7 +91,7 @@ def bioprint(image_filename, output_filename, bg_color, pigments_wells, value on our Echo. pigment_well_capacity - Volume in microliters that one pigments well can dispense. The + Volume in microliters that one pigment well can dispense. The function raises an error if the total number of pixels for one color exceeds the content of one pigment well, i.e. if transfer_volume * number_pixels > well_capacity @@ -94,13 +103,11 @@ def bioprint(image_filename, output_filename, bg_color, pigments_wells, quantified_image_filename If a path is provided, the quantified picture will be saved as an image file under this name. - """ pigments_wells, pigments_colors = zip(*pigments_wells.items()) # Constants of the problem - colors = np.vstack([np.array(bg_color), - np.array(pigments_colors)]).astype(float) + colors = np.vstack([np.array(bg_color), np.array(pigments_colors)]).astype(float) resolution_w, resolution_h = resolution resolution_ratio = 1.0 * resolution_w / resolution_h @@ -125,13 +132,14 @@ def bioprint(image_filename, output_filename, bg_color, pigments_wells, image = image.resize(image, new_size) image = np.array(image) - # QUANTIFY THE ORIGINAL IMAGE WITH THE PROVIDED PIGMENTS COLORS - image_color_distances = np.dstack([ - ((1.0*image - color.reshape((1, 1, 3)))**2).sum(axis=2) - for color in colors - ]) + image_color_distances = np.dstack( + [ + ((1.0 * image - color.reshape((1, 1, 3))) ** 2).sum(axis=2) + for color in colors + ] + ) # now image_color_distances[x,y,i] represents the distance between color # i and the color of the image pixel at [x,y]. image_quantnumbers = image_color_distances.argmin(axis=2) @@ -142,36 +150,38 @@ def bioprint(image_filename, output_filename, bg_color, pigments_wells, counter = Counter(image_quantnumbers.flatten()) for color, count in counter.items(): if (color != 0) and (count > max_pixels_per_color): - err_message = ("Too much pixels of color #%d. " % (color) + - "Counted %d, max authorized %d" % ( - count, max_pixels_per_color)) + err_message = "Too much pixels of color #%d. " % ( + color + ) + "Counted %d, max authorized %d" % (count, max_pixels_per_color) raise ValueError(err_message) # WRITE THE CSV # TO DO: write the wells in an order that miminizes the Echo's travels. - with open(output_filename, 'w') as csvfile: - writer = csv.writer(csvfile, delimiter=',') - writer.writerow([u'Source Well', - u'Destination Well', - u'Transfer Volume']) + with open(output_filename, "w") as csvfile: + writer = csv.writer(csvfile, delimiter=",") + writer.writerow([u"Source Well", u"Destination Well", u"Transfer Volume"]) for i, row in enumerate(image_quantnumbers): for j, color in enumerate(row): if color != 0: - writer.writerow([ - pigments_wells[color-1], # source well - _rownumber_to_rowname(i) + str(j+1), # target "well" - transfer_volume]) + writer.writerow( + [ + pigments_wells[color - 1], # source well + _rownumber_to_rowname(i) + str(j + 1), # target "well" + transfer_volume, + ] + ) # ESTIMATE THE PRINTING TIME - total_pixels = sum([count for (color, count) in counter.items() - if color > 0]) - print("%d pixels will be printed in appr. %.1f minutes" % ( - total_pixels, total_pixels / transfer_rate)) + total_pixels = sum([count for (color, count) in counter.items() if color > 0]) + print( + "%d pixels will be printed in appr. %.1f minutes" + % (total_pixels, total_pixels / transfer_rate) + ) # SAVE THE QUANTIFIED VERSION OF THE IMAGE IF A FILENAME IS PROVIDED if quantified_image_filename is not None: image_quantified = np.array([colors[y] for y in image_quantnumbers]) - pil_image = Image.fromarray(image_quantified.astype('uint8')) + pil_image = Image.fromarray(image_quantified.astype("uint8")) pil_image.save(quantified_image_filename) diff --git a/bioprinter/version.py b/bioprinter/version.py index b3f4756..ae73625 100644 --- a/bioprinter/version.py +++ b/bioprinter/version.py @@ -1 +1 @@ -__version__ = "0.1.2" +__version__ = "0.1.3" diff --git a/docs/conf.py b/docs/conf.py index e3af98c..ac6bdd5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,78 +16,83 @@ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.viewcode', 'numpydoc'] +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.todo", + "sphinx.ext.viewcode", + "numpydoc", +] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = ['.rst'] +source_suffix = [".rst"] # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'bioprinter' -copyright = u'2015, Edinburgh Genome Foundry' +project = u"bioprinter" +copyright = u"2015, Edinburgh Genome Foundry" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '0.1.0' +version = "0.1.3" # The full version, including alpha/beta/rc tags. -release = '0.1.0' +release = "0.1.3" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # -- Options for HTML output --------------------------------------------------- @@ -96,158 +101,157 @@ # a list of builtin themes. import sphinx_rtd_theme -sys.path.append(os.path.abspath('_themes')) + +sys.path.append(os.path.abspath("_themes")) sys.path.append("../bioprinter") -#html_theme_path = ['_themes'] -html_theme = "sphinx_rtd_theme" # formerly 'kr' +# html_theme_path = ['_themes'] +html_theme = "sphinx_rtd_theme" # formerly 'kr' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] -on_rtd = os.environ.get('READTHEDOCS', None) == 'True' +on_rtd = os.environ.get("READTHEDOCS", None) == "True" if not on_rtd: # only import and set the theme if we're building docs locally import sphinx_rtd_theme - html_theme = 'sphinx_rtd_theme' + + html_theme = "sphinx_rtd_theme" html_theme_path = sphinx_rtd_theme.get_html_theme_path() + def setup(app): - app.add_stylesheet('css/main.css') + app.add_stylesheet("css/main.css") + + else: html_context = { - 'css_files': [ - 'https://media.readthedocs.org/css/sphinx_rtd_theme.css', - 'https://media.readthedocs.org/css/readthedocs-doc-embed.css', - '_static/css/main.css', - ], + "css_files": [ + "https://media.readthedocs.org/css/sphinx_rtd_theme.css", + "https://media.readthedocs.org/css/readthedocs-doc-embed.css", + "_static/css/main.css", + ], } -#sys.path.append(os.path.abspath('_themes')) -#html_theme_path = ['_themes'] -#html_theme = 'jdoctest' +# sys.path.append(os.path.abspath('_themes')) +# html_theme_path = ['_themes'] +# html_theme = 'jdoctest' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'bioprinterdoc' +htmlhelp_basename = "bioprinterdoc" # -- Options for LaTeX output -------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'bioprinter.tex', u'bioprinter Documentation', - u'Zulko', 'manual'), + ("index", "bioprinter.tex", u"bioprinter Documentation", u"Zulko", "manual"), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'bioprinter', u'PACKAGE_NAME Documentation', - [u'Zulko'], 1) -] +man_pages = [("index", "bioprinter", u"PACKAGE_NAME Documentation", [u"Zulko"], 1)] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ @@ -256,79 +260,86 @@ def setup(app): # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'bioprinter', u'bioprinter Documentation', - u'Zulko', 'bioprinter', 'One line description of project.', - 'Miscellaneous'), + ( + "index", + "bioprinter", + u"bioprinter Documentation", + u"Zulko", + "bioprinter", + "One line description of project.", + "Miscellaneous", + ), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False # -- Options for Epub output --------------------------------------------------- # Bibliographic Dublin Core info. -epub_title = u'bioprinter' -epub_author = u'Zulko' -epub_publisher = u'Zulko' -epub_copyright = u'2016, Edinburgh Genome Foundry' +epub_title = u"bioprinter" +epub_author = u"Zulko" +epub_publisher = u"Zulko" +epub_copyright = u"2016, Edinburgh Genome Foundry" # The language of the text. It defaults to the language option # or en if the language is not set. -#epub_language = '' +# epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. -#epub_scheme = '' +# epub_scheme = '' # The unique identifier of the text. This can be a ISBN number # or the project homepage. -#epub_identifier = '' +# epub_identifier = '' # A unique identification for the text. -#epub_uid = '' +# epub_uid = '' # A tuple containing the cover image and cover page html template filenames. -#epub_cover = () +# epub_cover = () # A sequence of (type, uri, title) tuples for the guide element of content.opf. -#epub_guide = () +# epub_guide = () # HTML files that should be inserted before the pages created by sphinx. # The format is a list of tuples containing the path and title. -#epub_pre_files = [] +# epub_pre_files = [] # HTML files shat should be inserted after the pages created by sphinx. # The format is a list of tuples containing the path and title. -#epub_post_files = [] +# epub_post_files = [] # A list of files that should not be packed into the epub file. -#epub_exclude_files = [] +# epub_exclude_files = [] # The depth of the table of contents in toc.ncx. -#epub_tocdepth = 3 +# epub_tocdepth = 3 # Allow duplicate toc entries. -#epub_tocdup = True +# epub_tocdup = True # Fix unsupported image types using the PIL. -#epub_fix_images = False +# epub_fix_images = False # Scale large images. -#epub_max_image_width = 0 +# epub_max_image_width = 0 # If 'no', URL addresses will not be shown. -#epub_show_urls = 'inline' +# epub_show_urls = 'inline' # If false, no index is generated. -#epub_use_index = True +# epub_use_index = True + +# autodoc_member_order = 'bysource' -#autodoc_member_order = 'bysource' diff --git a/docs/index.rst b/docs/index.rst index aa8a164..6c2af37 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -8,14 +8,14 @@ Bioprinter Documentation :width: 550px :align: center -Bioprinter is a Python module to produce living art. It transforms an image into files that a liquid dispenser can use to *print* the image to a plate using pigmented yeast or bacteria. +Bioprinter is a Python package for producing living art. It transforms an image into files that a liquid dispenser can use to *print* the image to a plate using pigmented yeast or bacteria. Here are two examples of bio-art: .. figure:: _static/images/bioprint_dolly.jpeg :align: center - Dolly drawn with baker yeast (white), violacein-producing yeast (black), and carotene-producing yeast (orange) + Dolly drawn with baker yeast (white), violacein-producing yeast (black), and carotene-producing yeast (orange). .. figure:: _static/images/bioprint_england.jpeg @@ -24,14 +24,14 @@ Here are two examples of bio-art: England flag drawn with 3 different strains of the bacterium *E. coli*. -Bioprinter is released on Github_ under the MIT licence (¢ Edinburgh Genome Foundry), everyone is welcome to contribute ! +Bioprinter is released on Github_ under the MIT licence (Copyright 2015 Edinburgh Genome Foundry), everyone is welcome to contribute! Bioprinter was written at the Edinburgh Genome Foundry by Zulko_ after an original idea -and Matlab code by Mike Shen at the Boeke Lab (`Mike's project on Github `_). +and Matlab code by Mike Shen at the Boeke Lab (`project on Github `_). Installation --------------- +------------ If you have PIP installed: :: @@ -43,36 +43,36 @@ Or unzip the source code in a directory and type in a terminal: :: Usage --------- +----- -In the same folder as your code, place an image. It can have any resolution, but keep in mind that the width/height ratio of the plate it is printed on is 1.5. Make sure that a specific color is used to mark the un-pigmented background of the image, here we use blue: +The image file to be printed can have any resolution, but note that the width/height ratio of the plate the image is printed on is 1.5. Ensure that a specific color is used to mark the un-pigmented background of the image, here we use blue: .. figure:: _static/images/dolly.jpeg :align: center -Then write the following code in ``dolly.py``: +Run the following code in Python or save in ``dolly.py``: :: from bioprinter import bioprint bioprint( - image_filename="../docs/images/dolly.jpeg", + image_filename="/path/to/image/dolly.jpeg", output_filename="dolly.csv", - bg_color=[0, 0, 255], # blue background represents empty wells - pigments_wells={"A1": [0, 0, 0], # black yeast in source well A1 - "A2": [250, 120, 10], # orange yeast in well A2 - "A3": [255, 255, 255]}, # white yeast in well A3 + bg_color=[0, 0, 255], # blue background represents empty wells + pigments_wells={"A1": [0, 0, 0], # black yeast in source well A1 + "A2": [250, 120, 10], # orange yeast in well A2 + "A3": [255, 255, 255]}, # white yeast in well A3 quantified_image_filename="dolly_preview.jpeg" ) -Execute in a terminal with ``python dolly.py``. This will produce a ``dolly.csv`` file as well as a preview image of the final printing (so that you can check if the image looks good at this low resolution). +The saved script can be executed in a terminal with ``python dolly.py``. This will produce a ``dolly.csv`` file as well as a preview image of the final printing (so that you can check if the image looks good at this low resolution). .. figure:: _static/images/dolly_preview.png :align: center -Prepare a source plate with the right pigmented yeasts in wells A1, A2, A3, use an agar plate as the destination plate, and feed ``dolly.csv`` to the `Labcyte Echo `_. Once the printing is finished, incubate 2 days at 30C (it would be one day at 37C for bacteria). Enjoy the result ! +Prepare a source plate with the right pigmented yeasts in wells A1, A2, A3, use an agar plate as the destination plate, and feed ``dolly.csv`` to the `Labcyte Echo `_. Once the printing is finished, incubate 2 days at 30C (it would be one day at 37C for bacteria). Enjoy the result! Reference manual ------------------ +---------------- .. autofunction:: bioprinter.bioprint diff --git a/examples/dolly_bioprint.py b/examples/dolly_bioprint.py index 5b5b20c..2fc1562 100644 --- a/examples/dolly_bioprint.py +++ b/examples/dolly_bioprint.py @@ -3,9 +3,11 @@ bioprint( image_filename="../tests/assets/dolly.jpeg", output_filename="dolly.csv", - bg_color=[0, 0, 255], # blue background represents empty wells - pigments_wells={"A1": [0, 0, 0], # black yeast in source well A1 - "A2": [250, 120, 10], # orange yeast in well A2 - "A3": [255, 255, 255]}, # white yeast in well A3 - quantified_image_filename="dolly_preview.png" + bg_color=[0, 0, 255], # blue background represents empty wells + pigments_wells={ + "A1": [0, 0, 0], # black yeast in source well A1 + "A2": [250, 120, 10], # orange yeast in well A2 + "A3": [255, 255, 255], # white yeast in well A3 + }, + quantified_image_filename="dolly_preview.png", ) diff --git a/setup.py b/setup.py index df1d31b..305091c 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,20 @@ import ez_setup + ez_setup.use_setuptools() from setuptools import setup, find_packages -exec(open('bioprinter/version.py').read()) # loads __version__ +exec(open("bioprinter/version.py").read()) # loads __version__ -setup(name='bioprinter', - version=__version__, - author='Zulko', - description='', - long_description=open('README.rst').read(), - license='MIT', - url='https://github.com/Edinburgh-Genome-Foundry/bioprinter', - keywords="bioprinter pointillism living art", - packages=find_packages(exclude='docs'), - install_requires=['numpy', 'Pillow', 'pytest']) +setup( + name="bioprinter", + version=__version__, + author="Zulko", + description="", + long_description=open("README.rst").read(), + license="MIT", + url="https://github.com/Edinburgh-Genome-Foundry/bioprinter", + keywords="bioprinter pointillism living art", + packages=find_packages(exclude="docs"), + install_requires=["numpy", "Pillow", "pytest"], +) diff --git a/tests/test_basics.py b/tests/test_basics.py index 8980c93..a450030 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -6,6 +6,7 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + def test_basics(): quantified_image_filename = tempfile.mktemp(".jpeg") output_filename = tempfile.mktemp(".csv") @@ -13,11 +14,13 @@ def test_basics(): bioprint( image_filename=os.path.join(THIS_DIR, "assets", "dolly.jpeg"), output_filename=output_filename, - bg_color=[0, 0, 255], # blue background represents empty wells - pigments_wells={"A1": [0, 0, 0], # black yeast in source well A1 - "A2": [250, 120, 10], # orange yeast in well A2 - "A3": [255, 255, 255]}, # white yeast in well A3 - quantified_image_filename=quantified_image_filename + bg_color=[0, 0, 255], # blue background represents empty wells + pigments_wells={ + "A1": [0, 0, 0], # black yeast in source well A1 + "A2": [250, 120, 10], # orange yeast in well A2 + "A3": [255, 255, 255], + }, # white yeast in well A3 + quantified_image_filename=quantified_image_filename, ) assert os.path.exists(quantified_image_filename) assert os.path.exists(output_filename)