Skip to content

Commit

Permalink
Chemical toolbox updates (#1476)
Browse files Browse the repository at this point in the history
* Updated ob_convert to allow appending properties to the title

* lint fixes

* bump ob depiction version

* fixed linter

* fixed linter by updating documentation

* removed accidentally added files

* fixed obconvert tests

* fixed simsearch test

* fixed test results as knn is now passed correctly

* first round linting updates

* fixing merger and fragmenter tools

* fixed linting merger

* added citations to pgchem tools

* added citations

* fixed linting

* fixed linting and introduced macro file

* fixed fragmenter tests

* fixed doclink

* started repairing fragmented

* copied needed functions and removed import.

* lint

* added .shed.yml file

* xchem shedfile

* fixed long description

* removed tests for merger

* fixed repo name

* fixed openbabel version

* update to openbabel 3

* renamed repository

* Apply suggestions from code review

* Update fragmenter.xml

* Rename .shed.yml to __not_deployed_.shed.yml

* Rename .shed.yml to _not_deployed_.shed.yml

---------

Co-authored-by: Björn Grüning <[email protected]>
  • Loading branch information
hechth and bgruening authored Sep 22, 2024
1 parent d4f36c4 commit fa68c4b
Show file tree
Hide file tree
Showing 21 changed files with 260 additions and 271 deletions.
10 changes: 5 additions & 5 deletions chemicaltoolbox/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -476,17 +476,17 @@ We highly recommend to use PostgreSQL for any kind of production system.
.. _molecular frameworks and the reduced molecular frameworks: http://peter-ertl.com/reprints/Schuffenhauer-JCIM-47-47-2007.pdf
.. _scaffold topologies: http://www.ncbi.nlm.nih.gov/pubmed/18605680
.. _gaussian volumes as descriptor for molecular shape: http://pubs.acs.org/doi/abs/10.1021/j100011a016
.. _obgrep: http://openbabel.org/wiki/Obgrep
.. _FastSearch: http://openbabel.org/wiki/FastSearch
.. _obgrep: https://open-babel.readthedocs.io/en/latest/Command-line_tools/babel.html#filtering-molecules-from-a-multimolecule-file
.. _FastSearch: https://open-babel.readthedocs.io/en/latest/Command-line_tools/babel.html#substructure-and-similarity-searching
.. _Silicos: http://www.silicos.be/technologies/spectrophore
.. _chemfp: http://chemfp.com/
.. _Open Babel command prompt converters: http://openbabel.org/docs/2.3.0/FileFormats/Overview.html
.. _Open Babel: http://openbabel.org/wiki/Main_Page
.. _Open Babel: https://open-babel.readthedocs.io/en/latest/index.html
.. _OpenEye: http://www.eyesopen.com/
.. _RDKit: http://www.rdkit.org/
.. _Taylor-Butina clustering: http://www.redbrick.dcu.ie/~noel/R_clustering.html
.. _PNG: http://openbabel.org/docs/dev/FileFormats/PNG_2D_depiction.html
.. _SVG: http://openbabel.org/docs/dev/FileFormats/SVG_2D_depiction.html
.. _PNG: https://open-babel.readthedocs.io/en/latest/FileFormats/PNG_2D_depiction.html
.. _SVG: https://open-babel.readthedocs.io/en/latest/FileFormats/SVG_2D_depiction.html
.. _OSRA: http://cactus.nci.nih.gov/osra/
.. _Confab: https://code.google.com/p/confab/
.. _numpy: http://www.numpy.org/
Expand Down
16 changes: 8 additions & 8 deletions chemicaltoolbox/chemfp/mol2fps.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<tool id="ctb_chemfp_mol2fps" name="Molecule to fingerprint" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@">
<tool id="ctb_chemfp_mol2fps" name="Molecule to fingerprint" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="23.0">
<description>conversion to several different fingerprint formats</description>
<!--parallelism method="multi" split_inputs="infile" split_mode="to_size" split_size="10000" merge_outputs="outfile"></parallelism-->
<requirements>
<requirement type="package" version="@TOOL_VERSION@">chemfp</requirement>
</requirements>
<macros>
<token name="@TOOL_VERSION@">1.6.1</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@VERSION_SUFFIX@">1</token>
</macros>
<requirements>
<requirement type="package" version="@TOOL_VERSION@">chemfp</requirement>
</requirements>
<command>
<![CDATA[
Expand Down Expand Up @@ -191,9 +191,9 @@
<param name="infile" value="CID_2244.smi" ftype="smi" />
<conditional name="fp_opts">
<param name="fp_opts_selector" value="--torsions" />
<param name="fpSize" value="2048" />
<param name="targetSize" value="4" />
</conditional>
<param name="fp_opts.fpSize" value="2048" />
<param name="fp_opts.targetSize" value="4" />
<output name="outfile" file="CID_2244_torsions.fps" ftype="fps" lines_diff="4"/>
</test>
</tests>
Expand All @@ -209,7 +209,7 @@ This tool uses chemfp to calculate molecular fingerprints, supporting a number o
For more information check the websites listed below::
- http://www.rdkit.org/docs/GettingStartedInPython.html#fingerprinting-and-molecular-similarity
- http://openbabel.org/wiki/Tutorial:Fingerprints
- https://open-babel.readthedocs.io/en/latest/Fingerprints/intro.html
-----
Expand Down
4 changes: 2 additions & 2 deletions chemicaltoolbox/chemfp/nxn_clustering.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<description>of molecular fingerprints</description>
<macros>
<token name="@TOOL_VERSION@">1.6.1</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@VERSION_SUFFIX@">1</token>
</macros>
<requirements>
<requirement type="package" version="@TOOL_VERSION@">chemfp</requirement>
Expand Down Expand Up @@ -49,7 +49,7 @@
</data>
</outputs>
<tests>
<test>
<test expect_num_outputs="2">
<param name="infile" ftype="fps" value="targets.fps" />
<param name='threshold' value='0.75' />
<param name='oformat' value='svg' />
Expand Down
16 changes: 16 additions & 0 deletions chemicaltoolbox/fragmenter/__not_deployed_.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: bgchem
owner: bgruening
remote_repository_url: "https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/fragmenter"
homepage_url: "https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/fragmenter"
categories:
- Computational chemistry
description: "Tools for fragmentation."
long_description: |
"Tools to fragment compounds and merge them together."
auto_tool_repositories:
name_template: "{{ tool_id }}"
description_template: "{{ tool_name }} tool from the bgchem Chemical Toolbox"
suite:
name: suite_bgchem
description: tools from the bgchem Chemical Toolbox are used to fragment compounds and merge them together
type: repository_suite_definition
3 changes: 1 addition & 2 deletions chemicaltoolbox/fragmenter/fragmenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import sys

import openbabel
import pybel

from openbabel import pybel
openbabel.obErrorLog.StopLogging()


Expand Down
16 changes: 8 additions & 8 deletions chemicaltoolbox/fragmenter/fragmenter.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<tool id="fragmenter" name="Fragmenter" version="0.1">
<tool id="fragmenter" name="Fragmenter" version="0.1+galaxy0" profile="23.0">
<description>- splits a molecule into fragments</description>
<parallelism method="multi" split_inputs="infile" split_mode="to_size" split_size="100000" merge_outputs="outfile,fragment_file"></parallelism>
<requirements>
<requirement type="package" version="0.1">cheminfolib</requirement>
<requirement type="package" version="2.4.2">openbabel</requirement>
<requirement type="package" version="3.1.1">openbabel</requirement>
</requirements>
<command>
<command detect_errors="exit_code">
<![CDATA[
python '$__tool_directory__/fragmenter.py'
-i $infile
Expand Down Expand Up @@ -34,7 +33,7 @@
<option value='mol2'>mol2</option>
</param>
<param name='mark' type='boolean' label='Replaces the newly created free ends on each bond break with some marker atoms' truevalue='--mark-sticky-ends' falsevalue='' help='This option is usefull if you want to to merge the fragments afterwarts.' />
<param name='non_fragment_file' type='boolean' label='Output an additional file with all molecules that are not fragmented' truevalue='' falsevalue='' help='Without that option such molecules will also appear in the regular output file.' />
<param name='non_fragment_file' type='boolean' label='Output an additional file with all molecules that are not fragmented' truevalue='True' falsevalue='False' help='Without that option such molecules will also appear in the regular output file.' />
</inputs>
<outputs>
<data format="smi" name="outfile">
Expand All @@ -44,18 +43,18 @@
<when input="oformat" value="mol2" format="mol2"/>
</change_format>
</data>
<data format="smi" name="fragment_file">
<data format="smi" name="fragment_file" label="Fragments generated by ${tool.name} on ${on_string}">
<filter>non_fragment_file is True</filter>
</data>
</outputs>
<tests>
<test>
<test expect_num_outputs="1">
<param name="infile" ftype="sdf" value="CID_2244.sdf"/>
<param name='rules' value='recap' />
<param name='oformat' value='smi' />
<output name="outfile" ftype="smi" file='fragmenter_on_CID_2244_recap.smi'/>
</test>
<test>
<test expect_num_outputs="1">
<param name="infile" ftype="sdf" value="CID_2244.sdf"/>
<param name='rules' value='recap' />
<param name='oformat' value='smi' />
Expand Down Expand Up @@ -101,5 +100,6 @@ Copyright 2009-2012 TJ O'Donnell, B Gruening
]]>
</help>
<citations>
<citation type="doi">10.1186/1758-2946-3-33</citation>
</citations>
</tool>
33 changes: 30 additions & 3 deletions chemicaltoolbox/fragmenter/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import tempfile

import openbabel
import pybel
from cheminfolib import CountLines, split_smi_library
from openbabel import pybel

openbabel.obErrorLog.StopLogging()

Expand Down Expand Up @@ -52,6 +51,34 @@
)


def CountLines(path):
out = subprocess.Popen(
["wc", "-l", path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
).communicate()[0]
return int(out.partition(b" ")[0])


def split_smi_library(smiles_file, structures_in_one_file):
"""
Split a file with SMILES to several files for multiprocessing usage.
Usage: split_smi_library( smiles_file, 10 )
"""
output_files = []
tfile = tempfile.NamedTemporaryFile(delete=False)

smiles_handle = open(smiles_file, "r")
for count, line in enumerate(smiles_handle):
if count % structures_in_one_file == 0 and count != 0:
tfile.close()
output_files.append(tfile.name)
tfile = tempfile.NamedTemporaryFile(delete=False)
tfile.write(bytes(line, "utf-8"))
tfile.close()
output_files.append(tfile.name)
smiles_handle.close()
return output_files


def unique_files(file_paths, unique_file, temp=False):
"""
Concatenate files and makes them unique afterwarts, utilising the GNU `sort` and `cat` tools.
Expand Down Expand Up @@ -595,7 +622,7 @@ def filter_input_files(input_file):
for line in open(temp_final_result.name):
options.output.write("%s\t\n" % line.strip().split("\t")[0])

if not type(options.output.name) != str():
if isinstance(options.output.name, str):
logging.info(
"Results are written to %s (%s)."
% (options.output.name, CountLines(options.output.name))
Expand Down
25 changes: 6 additions & 19 deletions chemicaltoolbox/fragmenter/merger.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<tool id="bgchem_fragment_merger" name="Merging" version="0.1">
<tool id="bgchem_fragment_merger" name="Merging" version="0.1+galaxy0" profile="23.0">
<description>fragmented molecules</description>
<requirements>
<requirement type="package" version="0.1">cheminfolib</requirement>
<requirement type="package" version="2.4.1">openbabel</requirement>
<requirement type="package" version="3.1.1">openbabel</requirement>
</requirements>
<command>
<command detect_errors="exit_code">
<![CDATA[
'$__tool_directory__/merger.py'
python '$__tool_directory__/merger.py'
-i $infile
-o $outfile
--molwt-cutoff $molwt_cutoff
Expand All @@ -31,19 +30,7 @@
<data format="smi" name="outfile" label="Fragment merging on ${on_string}"/>
</outputs>
<tests>
<test>
<param name="infile" ftype="sdf" value="CID_2244.sdf"/>
<param name='rules' value='recap' />
<param name='oformat' value='smi' />
<output name="outfile" ftype="smi" file='fragmenter_on_CID_2244_recap.smi'/>
</test>
<test>
<param name="infile" ftype="sdf" value="CID_2244.sdf"/>
<param name='rules' value='recap' />
<param name='oformat' value='smi' />
<param name='mark' value='--mark-sticky-ends' />
<output name="outfile" ftype="smi" file='fragmenter_on_CID_2244_recap_mark.smi'/>
</test>
<test expect_failure="true" />
</tests>
<help>
<![CDATA[
Expand Down Expand Up @@ -93,8 +80,8 @@ A molecule file with new created/merged molecules.
]]>
</help>

<citations>
<citation type="doi">10.1186/1758-2946-3-33</citation>
</citations>

</tool>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Oc1ccccc1C(=O)O
O=CC
[O]c1c(cccc1)C(=O)O
O=[C]C
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[U]c1ccccc1C(=O)O
[U]c1c(cccc1)C(=O)O
O=[Pa]C
10 changes: 5 additions & 5 deletions chemicaltoolbox/openmg/openmg.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<tool id="ctb_openmg" name="Open Molecule Generator" version="@TOOL_VERSION@+galaxy@GALAXY_VERSION@">
<tool id="ctb_openmg" name="Open Molecule Generator" version="@TOOL_VERSION@+galaxy@GALAXY_VERSION@" profile="23.0">
<description>- exhaustive generation of chemical structures</description>
<macros>
<token name="@TOOL_VERSION@">0.1</token>
<token name="@GALAXY_VERSION@">0</token>
<token name="@GALAXY_VERSION@">1</token>
</macros>
<description>- exhaustive generation of chemical structures</description>
<requirements>
<requirement type="package" version="@TOOL_VERSION@">openmg</requirement>
<requirement type="package" version="8.0.112">java-jdk</requirement>
Expand All @@ -26,12 +26,12 @@
</inputs>
<outputs>
<data format="sdf" name="outfile" />
<data format="sdf" name="sdf_outfile">
<data format="sdf" name="sdf_outfile" label="Substructures detected by ${tool.name} on ${on_string}">
<filter>fr is True</filter>
</data>
</outputs>
<tests>
<test>
<test expect_num_outputs="1">
<param name="ec" value="C6H6"/>
<output name="outfile" file="openmg_results.sdf" lines_diff="440"/>
</test>
Expand Down
16 changes: 16 additions & 0 deletions chemicaltoolbox/pgchem/pgchem/_not_deployed_.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pgchem
owner: bgruening
remote_repository_url: "https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/pgchem"
homepage_url: "https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/pgchem"
categories:
- Computational chemistry
description: "Tools for chemical database manipulation."
long_description: |
"Tools for chemical database manipulation."
auto_tool_repositories:
name_template: "{{ tool_id }}"
description_template: "{{ tool_name }} tool from the bgchem Chemical Toolbox"
suite:
name: suite_pgchem
description: tools from the pgchem Chemical Toolbox.
type: repository_suite_definition
Loading

0 comments on commit fa68c4b

Please sign in to comment.