diff data_manager/data_manager_amrfinderplus.py @ 1:254479b50f86 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_amrfinderplus commit 25a0413337c540dc9f26bc7ee097d493f0d148ca-dirty
author pimarin
date Mon, 14 Nov 2022 13:40:22 +0000
parents 8e1bbef44e19
children
line wrap: on
line diff
--- a/data_manager/data_manager_amrfinderplus.py	Thu Nov 10 15:10:15 2022 +0000
+++ b/data_manager/data_manager_amrfinderplus.py	Mon Nov 14 13:40:22 2022 +0000
@@ -2,9 +2,10 @@
 import json
 import os
 import re
+import subprocess as sp
+
 from datetime import datetime
 from pathlib import Path
-import subprocess as sp
 
 
 class GetDataManager:
@@ -36,22 +37,23 @@
         self.amrfinderplus_table_list["data_tables"][self.data_table_name] = [data_info]
         return self.amrfinderplus_table_list
 
-    def update_amrfinderplus_db(self, path):
-        amrfinderplus_db_path = path.joinpath(self._db_name)
+    def update_amrfinderplus_db(self):
+        amrfinderplus_db_path = Path(self._db_path).joinpath(self._db_name)
         cmd = [
             'amrfinder_update',
             '--database', str(amrfinderplus_db_path),
             '--force_update'
         ]
-        print('cmd=%s', cmd)
+        print(cmd)
         proc = sp.run(
             cmd,
             stdout=sp.PIPE,
             stderr=sp.PIPE,
             universal_newlines=True
         )
-        if(proc.returncode != 0):
-            print(f"ERROR: AMRFinderPlus failed! command: 'amrfinder_update --force_update --database {amrfinderplus_db_path}', error code: {proc.returncode}")
+        if (proc.returncode != 0):
+            print(
+                f"ERROR: AMRFinderPlus failed! command: 'amrfinder_update --force_update --database {amrfinderplus_db_path}', error code: {proc.returncode}")
         else:
             return amrfinderplus_db_path
 
@@ -75,7 +77,7 @@
             params = json.load(fh)
         target_dir = params['output_data'][0]['extra_files_path']
         os.makedirs(target_dir)
-        return target_dir
+        return Path(target_dir)
 
     def write_json_infos(self, json_file_path, data_manager_infos):
         with open(json_file_path, 'w') as fh:
@@ -92,7 +94,7 @@
     # change the path to th json information
     amrfinderplus_download._db_path = path_to_download
     # download the last amrfinderplus database
-    amrfinder_output = amrfinderplus_download.update_amrfinderplus_db(amrfinderplus_download._db_path)
+    amrfinder_output = amrfinderplus_download.update_amrfinderplus_db()
     # extract the version number of the database
     amrfinder_version = amrfinderplus_download.get_amrfinderplus_version(amrfinder_output)
     # make a dic with database information