diff --git a/setup.py b/setup.py index c4976767a5f97be7c5a85d207a9f11a0a600bf32..80c9bc431406002a6d0bc3263222f5abf1e16e3a 100644 --- a/setup.py +++ b/setup.py @@ -8,5 +8,6 @@ setup(name='solventmapcreator', author_email='mdd31@cam.ac.uk', license='TBD', packages=setuptools.find_packages(), - package_data={'test/resources':['test/resources']}, + package_data={'test/resources':['test/resources'], + 'solvationcalculation/resources':['solvationcalculation/resources']}, zip_safe=False) diff --git a/solventmapcreator/solvationcalculation/fgipmaker.py b/solventmapcreator/solvationcalculation/fgipmaker.py new file mode 100644 index 0000000000000000000000000000000000000000..a2404d9b344d60ed4acde8835783945608b70bb1 --- /dev/null +++ b/solventmapcreator/solvationcalculation/fgipmaker.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Script for merging the molecules to the solvent map to create the functional +group interaction profile. + +@author: mark +""" + +import logging +import os +import svgutils.transform as svgt + +logging.basicConfig() +LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.WARN) + +FGIP_MOLECULES_FILENAME = os.path.join(os.path.dirname(__file__), + "resources/FGIPmolecules.svg") + +def create_fgip_from_map(map_filename): + """This creates a FGIP from the given solvent map. + """ + svg_figure = create_svgfigure() + map_plot = get_svg_plot(map_filename) + map_plot.moveto(0.0,150.0, scale=1.1) + molecules_plot = get_molecules() + + append_svg_plots(svg_figure, map_plot) + append_svg_plots(svg_figure, molecules_plot) + output_filename = create_output_filename(map_filename) + save_svg_figure(svg_figure, output_filename) + +def save_svg_figure(svg_figure, filename): + """This saves the figue to file. + """ + svg_figure.save(filename) + +def create_output_filename(filename, suffix="_solv_map.svg"): + """This returns the output filename to be used. + """ + return filename.replace(suffix, "_FGIP.svg") + +def append_svg_plots(svg_figure, svg_plot): + """This appends the plot to the figure. + """ + svg_figure.append(svg_plot) + +def get_molecules(): + """This gets the molecules. + """ + return get_svg_plot(FGIP_MOLECULES_FILENAME) + +def get_svg_plot(svg_filename): + """This gets the plot elements. + """ + figure = svgt.fromfile(svg_filename) + return figure.getroot() + +def create_svgfigure(): + """This creates SVG figure with default size. + """ + return svgt.SVGFigure(width="725.05334pt", height="676.02484pt") +