# HG changeset patch
# User bgruening
# Date 1605040325 0
# Node ID 4e3b2049a4d301464714f63bbcd8883571e0d85e
# Parent 3153b6f3087c89ecbeb7fa3180d997a7376ac995
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 327c29cc43f56d7067ab9fa51323ea31951db98b"
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
@@ -4,7 +4,7 @@
openbabel
- python
+ python
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__():
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 @@
macros.xml
- 1
+ 2
@@ -12,10 +12,12 @@
-i '${infile}'
-iformat '${infile.ext}'
-o '${outfile}'
+ $index
]]>
+
@@ -29,6 +31,11 @@
+
+
+
+
+