Mercurial > repos > bgruening > openbabel_filter
changeset 12:2213bfc4567a draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit cda909c5e0b88fa3d12abe43fc72b8dd0729417a"
author | bgruening |
---|---|
date | Thu, 09 Apr 2020 13:55:49 +0000 |
parents | 24b5d5f8a5ff |
children | 1c0e4c2ac9ce |
files | macros.xml ob_filter.py ob_filter.xml |
diffstat | 3 files changed, 57 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/macros.xml Wed Mar 25 20:39:01 2020 +0000 +++ b/macros.xml Thu Apr 09 13:55:49 2020 +0000 @@ -1,5 +1,5 @@ <macros> - <token name="@VERSION@">2.4.2.1</token> + <token name="@VERSION@">2.4.2.2</token> <xml name="requirements"> <requirements>
--- a/ob_filter.py Wed Mar 25 20:39:01 2020 +0000 +++ b/ob_filter.py Thu Apr 09 13:55:49 2020 +0000 @@ -40,7 +40,7 @@ for mol in pybel.readfile('sdf', args.input): for key, elem in filters.items(): # map the short description to the larger metadata names stored in the sdf file - property = cheminfolib.ColumnNames[key] + property = cheminfolib.ColumnNames.get(key, key) min = elem[0] max = elem[1] if float(mol.data[property]) >= float(min) and float(mol.data[property]) <= float(max): @@ -113,7 +113,7 @@ # Check if the sdf file contains all of the required metadata to invoke the precalculation filtering mol = next(pybel.readfile('sdf', args.input)) for key, elem in filters.items(): - property = cheminfolib.ColumnNames[key] + property = cheminfolib.ColumnNames.get(key, key) if not property in mol.data: break else:
--- a/ob_filter.xml Wed Mar 25 20:39:01 2020 +0000 +++ b/ob_filter.xml Thu Apr 09 13:55:49 2020 +0000 @@ -10,40 +10,45 @@ python '$__tool_directory__/ob_filter.py' -i '${infile}' -o '${outfile}' - -iformat '${infile.ext}' - -oformat '${infile.ext}' + -iformat "${infile.ext}" + -oformat "${infile.ext}" #if $filter_methods.filter_methods_opts == "__filter_by_name__": --list_of_names '$name_file' --filters '__filter_by_name__' #else - --filters '{ - #if $filter_methods.filter_methods_opts == "ruleof5": - "hbd" : [0, 5], - "hba" : [0, 10], - "molwt" : [0, 500], - "logp" : [-5, 5], - #elif $filter_methods.filter_methods_opts == "LeadLike": - "rotbonds" : [0, 7], - "molwt" : [0, 350], - "logp" : [-5, 3.5], - #elif $filter_methods.filter_methods_opts == "DrugLike": - "hba" : [0, 10], - "rotbonds" : [0, 8], - "molwt" : [150, 500], - "logp" : [-5, 5], - "psa" : [0, 150], - #elif $filter_methods.filter_methods_opts == "FragmentLike": - "rotbonds" : [0, 5], - "molwt" : [0, 250], - "logp" : [-5, 2.5], - #else: - #for $filter in $filter_methods.filter_set: + --filters '{ + #if $filter_methods.filter_methods_opts == "ruleof5": + "hbd" : [0, 5], + "hba" : [0, 10], + "molwt" : [0, 500], + "logp" : [-5, 5], + #elif $filter_methods.filter_methods_opts == "LeadLike": + "rotbonds" : [0, 7], + "molwt" : [0, 350], + "logp" : [-5, 3.5], + #elif $filter_methods.filter_methods_opts == "DrugLike": + "hba" : [0, 10], + "rotbonds" : [0, 8], + "molwt" : [150, 500], + "logp" : [-5, 5], + "psa" : [0, 150], + #elif $filter_methods.filter_methods_opts == "FragmentLike": + "rotbonds" : [0, 5], + "molwt" : [0, 250], + "logp" : [-5, 2.5], + #else: + #for $filter in $filter_methods.filter_set: + #if $filter.filter_sel.filter_sel_opts == "field": + #set $filter_selected = $filter.filter_sel['field_name'] + "$filter_selected": [$filter.filter_sel['field_min'], $filter.filter_sel['field_max'] ], + #else: #set $filter_selected = $filter.filter_sel.filter_sel_opts #set $filter_min = $filter_selected + "_min" #set $filter_max = $filter_selected + "_max" "$filter_selected" : [$filter.filter_sel[$filter_min], $filter.filter_sel[$filter_max] ], - #end for - #end if + #end if + #end for + #end if }' #end if ]]> @@ -80,6 +85,7 @@ <option value="logp">Predicted value of logP</option> <option value="mr">Predicted value for the molecular refractivity</option> <option value="atoms">Number of atoms</option> + <option value="field">Filter by a user-defined SDF property</option> <!-- Add later, we need to add a new smarts pattern to plugindefines.txt <option value="hatoms">Number of heavy atoms</option>--> <!-- We skip that options, for further information please read: http://www.dalkescientific.com/writings/diary/archive/2011/06/04/dealing_with_sssr.html --> @@ -117,6 +123,19 @@ <param name="atoms_min" type="integer" value="" label="Minimum number of atoms"/> <param name="atoms_max" type="integer" value="" label="Maximum number of atoms"/> </when> + <when value="field"> + <param name="field_name" type="text" value="" label="Name of the SDF property to filter by"> + <sanitizer invalid_char=""> + <valid initial="string.ascii_letters,string.digits"> + <add value="_" /> + <add value="." /> + <add value=" " /> + </valid> + </sanitizer> + </param> + <param name="field_min" type="integer" value="" label="Minimum value"/> + <param name="field_max" type="integer" value="" label="Maximum value"/> + </when> <!--<when value="rings"> <param name="rings_min" type="integer" value="" label="Minimum number of rings"/> <param name="rings_max" type="integer" value="" label="Maximum number of rings"/> @@ -141,6 +160,15 @@ <param name="filter_methods_opts" value="ruleof5" /> <output name="outfile" ftype="smi" file="ob_filter_on_CID2244.smi" /> </test> + <test> + <param name="infile" ftype="sdf" value="CID_2244.sdf"/> + <param name="filter_methods_opts" value="user" /> + <param name="filter_sel_opts" value="field" /> + <param name="field_name" value="PUBCHEM_EXACT_MASS"/> + <param name="field_min" value="100"/> + <param name="field_max" value="200"/> + <output name="outfile" ftype="sdf" file="ob_filter_on_CID2244.sdf" lines_diff="2"/> + </test> <!-- Limitation of the test framework: https://trello.com/card/disambiguated-conditional-parameters-not-supported-in-unit-tests/506338ce32ae458f6d15e4b3/820