diff change_title_to_metadata_value.py @ 15:7b6fd1c273cd draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit d9c51279c061a1da948a2582d5b502ca7573adbf
author bgruening
date Thu, 15 Aug 2024 11:03:49 +0000
parents f697d9601273
children
line wrap: on
line diff
--- a/change_title_to_metadata_value.py	Tue Nov 10 20:36:42 2020 +0000
+++ b/change_title_to_metadata_value.py	Thu Aug 15 11:03:49 2024 +0000
@@ -11,6 +11,7 @@
 import string
 
 from openbabel import openbabel, pybel
+
 openbabel.obErrorLog.StopLogging()
 
 
@@ -19,14 +20,19 @@
         description="Change the title from a molecule file to metadata \
                      value of a given-id of the same molecule file.",
     )
-    parser.add_argument('--infile', '-i', required=True,
-                        help="path to the input file")
-    parser.add_argument('--outfile', '-o', required=True,
-                        help="path to the output file")
-    parser.add_argument('--key', '-k', required=True,
-                        help="the metadata key from the sdf file which should inlcude the new title")
-    parser.add_argument('--random', '-r', action="store_true",
-                        help="Add random suffix to the title.")
+    parser.add_argument("--infile", "-i", required=True, help="path to the input file")
+    parser.add_argument(
+        "--outfile", "-o", required=True, help="path to the output file"
+    )
+    parser.add_argument(
+        "--key",
+        "-k",
+        required=True,
+        help="the metadata key from the sdf file which should inlcude the new title",
+    )
+    parser.add_argument(
+        "--random", "-r", action="store_true", help="Add random suffix to the title."
+    )
 
     args = parser.parse_args()
 
@@ -35,8 +41,11 @@
         if args.key in mol.data:
             mol.title = mol.data[args.key]
             if args.random:
-                suffix = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(13))
-                mol.title += '__%s' % suffix
+                suffix = "".join(
+                    random.choice(string.ascii_lowercase + string.digits)
+                    for _ in range(13)
+                )
+                mol.title += "__%s" % suffix
         output.write(mol)
 
     output.close()