Previous changeset 13:3153b6f3087c (2020-10-19) Next changeset 15:f70b83b730ac (2024-08-15) |
Commit message:
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 327c29cc43f56d7067ab9fa51323ea31951db98b" |
modified:
macros.xml ob_remIons.py ob_remIons.xml |
added:
test-data/multiple.inchi test-data/multiple_obrmions.inchi |
b |
diff -r 3153b6f3087c -r 4e3b2049a4d3 macros.xml --- a/macros.xml Mon Oct 19 14:43:01 2020 +0000 +++ b/macros.xml Tue Nov 10 20:32:05 2020 +0000 |
b |
@@ -4,7 +4,7 @@ <xml name="requirements"> <requirements> <requirement type="package" version="@TOOL_VERSION@">openbabel</requirement> - <requirement type="package" version="3">python</requirement> + <requirement type="package" version="3.6">python</requirement> <yield /> </requirements> </xml> |
b |
diff -r 3153b6f3087c -r 4e3b2049a4d3 ob_remIons.py --- a/ob_remIons.py Mon Oct 19 14:43:01 2020 +0000 +++ b/ob_remIons.py Tue Nov 10 20:32:05 2020 +0000 |
[ |
@@ -1,4 +1,5 @@ #!/usr/bin/env python + """ Input: molecular input file. Output: Molecule file with removed ions and fragments. @@ -15,20 +16,24 @@ parser.add_argument('-iformat', default='sdf', help='input file format') parser.add_argument('-i', '--input', required=True, help='input file name') parser.add_argument('-o', '--output', required=True, help='output file name') + parser.add_argument('-idx', default=False, action='store_true', help='should output be an indexed text table? works only for inchi/smiles, otherwise is ignored') return parser.parse_args() def remove_ions(args): - outfile = pybel.Outputfile(args.iformat, args.output, overwrite=True) - for mol in pybel.readfile(args.iformat, args.input): - if mol.OBMol.NumHvyAtoms() > 5: - mol.OBMol.StripSalts(0) - if 'inchi' in mol.data: - del mol.data['inchi'] # remove inchi cache so modified mol is saved - # Check if new small fragments have been created and remove them + with open(args.output, 'w') as outfile: + for index, mol in enumerate(pybel.readfile(args.iformat, args.input)): if mol.OBMol.NumHvyAtoms() > 5: - outfile.write(mol) - outfile.close() + mol.OBMol.StripSalts(0) + if 'inchi' in mol.data: + del mol.data['inchi'] # remove inchi cache so modified mol is saved + + mol = mol.write(args.iformat) if mol.OBMol.NumHvyAtoms() > 5 else '\n' + + if args.idx and args.iformat in ['inchi', 'smi']: + outfile.write(f'{index}\t{mol}') + elif mol != '\n': + outfile.write(f'{mol}') def __main__(): |
b |
diff -r 3153b6f3087c -r 4e3b2049a4d3 ob_remIons.xml --- a/ob_remIons.xml Mon Oct 19 14:43:01 2020 +0000 +++ b/ob_remIons.xml Tue Nov 10 20:32:05 2020 +0000 |
[ |
@@ -3,7 +3,7 @@ <!--parallelism method="multi" split_inputs="infile" split_mode="to_size" split_size="50000" shared_inputs="" merge_outputs="outfile"></parallelism--> <macros> <import>macros.xml</import> - <token name="@GALAXY_VERSION@">1</token> + <token name="@GALAXY_VERSION@">2</token> </macros> <expand macro="requirements"/> <command detect_errors="aggressive"> @@ -12,10 +12,12 @@ -i '${infile}' -iformat '${infile.ext}' -o '${outfile}' + $index ]]> </command> <inputs> <expand macro="infile_all_types"/> + <param name="index" type="boolean" checked="false" truevalue="-idx" falsevalue="" label="Output indexed tab-separated table?" help="Add an index column to the output file. This option will work only when input format is InChI or SMILES, otherwise it will be ignored." /> </inputs> <outputs> <expand macro="output_like_input"/> @@ -29,6 +31,11 @@ <param name="infile" ftype="inchi" value="na-sal.inchi"/> <output name="outfile" ftype="inchi" file="na-sal_obrmions.inchi" /> </test> + <test> + <param name="infile" ftype="inchi" value="multiple.inchi"/> + <param name="index" value="true"/> + <output name="outfile" ftype="inchi" file="multiple_obrmions.inchi" /> + </test> </tests> <help> <![CDATA[ |
b |
diff -r 3153b6f3087c -r 4e3b2049a4d3 test-data/multiple.inchi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/multiple.inchi Tue Nov 10 20:32:05 2020 +0000 |
b |
@@ -0,0 +1,3 @@ +InChI=1S/C2H5ClO/c3-1-2-4/h4H,1-2H2 +InChI=1S/C18H29NO3/c1-14(2)19-11-17(20)13-22-18-7-5-15(6-8-18)9-10-21-12-16-3-4-16/h5-8,14,16-17,19-20H,3-4,9-13H2,1-2H3 +InChI=1S/C13H22NO3PS/c1-6-16-18(15,14-10(2)3)17-12-7-8-13(19-5)11(4)9-12/h7-10H,6H2,1-5H3,(H,14,15) |
b |
diff -r 3153b6f3087c -r 4e3b2049a4d3 test-data/multiple_obrmions.inchi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/multiple_obrmions.inchi Tue Nov 10 20:32:05 2020 +0000 |
b |
@@ -0,0 +1,3 @@ +0 +1 InChI=1S/C18H29NO3/c1-14(2)19-11-17(20)13-22-18-7-5-15(6-8-18)9-10-21-12-16-3-4-16/h5-8,14,16-17,19-20H,3-4,9-13H2,1-2H3 +2 InChI=1S/C13H22NO3PS/c1-6-16-18(15,14-10(2)3)17-12-7-8-13(19-5)11(4)9-12/h7-10H,6H2,1-5H3,(H,14,15) |