AMR 2.1.1.9128__py3-none-any.whl → 2.1.1.9131__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
AMR/datasets.py CHANGED
@@ -1,7 +1,3 @@
1
- BLUE = '\033[94m'
2
- GREEN = '\033[32m'
3
- RESET = '\033[0m'
4
-
5
1
  import os
6
2
  import sys
7
3
  from rpy2 import robjects
@@ -17,18 +13,22 @@ venv_path = sys.prefix
17
13
  r_lib_path = os.path.join(venv_path, "R_libs")
18
14
  # Ensure the R library path exists
19
15
  os.makedirs(r_lib_path, exist_ok=True)
20
- # Set the R library path in .libPaths
16
+
17
+ # Import base and utils
21
18
  base = importr('base')
22
- # Turn off warnings
23
- base.options(warn = -1)
19
+ utils = importr('utils')
24
20
 
25
- base._libPaths(r_lib_path)
21
+ # Override R library paths globally for the session
22
+ robjects.r(f'.Library <- "{r_lib_path}"') # Replace default library
23
+ robjects.r(f'.Library.site <- "{r_lib_path}"') # Replace site-specific library
24
+ base._libPaths(r_lib_path) # Override .libPaths() as well
25
+
26
+ # Get the effective library path
26
27
  r_amr_lib_path = base._libPaths()[0]
27
28
 
28
29
  # Check if the AMR package is installed in R
29
- if not isinstalled('AMR', lib_loc = r_amr_lib_path):
30
- utils = importr('utils')
31
- print(f"{BLUE}AMR:{RESET} Installing AMR package to {BLUE}{r_amr_lib_path}/{RESET}...", flush=True)
30
+ if not isinstalled('AMR', lib_loc=r_amr_lib_path):
31
+ print(f"AMR: Installing latest AMR R package to {r_amr_lib_path}...", flush=True)
32
32
  utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
33
33
 
34
34
  # Python package version of AMR
@@ -43,16 +43,12 @@ r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_li
43
43
  # Compare R and Python package versions
44
44
  if r_amr_version != python_amr_version:
45
45
  try:
46
- print(f"{BLUE}AMR:{RESET} Updating AMR package in {BLUE}{r_amr_lib_path}/{RESET}...", flush=True)
47
- utils = importr('utils')
46
+ print(f"AMR: Updating AMR package in {r_amr_lib_path}...", flush=True)
48
47
  utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
49
48
  except Exception as e:
50
- print(f"{BLUE}AMR:{RESET} Could not update: {e}{RESET}", flush=True)
51
-
52
- # Restore warnings to default
53
- base.options(warn = 0)
49
+ print(f"AMR: Could not update: {e}", flush=True)
54
50
 
55
- print(f"{BLUE}AMR:{RESET} Setting up R environment and AMR datasets...", flush=True)
51
+ print(f"AMR: Setting up R environment and AMR datasets...", flush=True)
56
52
 
57
53
  # Activate the automatic conversion between R and pandas DataFrames
58
54
  pandas2ri.activate()
@@ -77,4 +73,4 @@ microorganisms = pandas2ri.rpy2py(robjects.r('AMR::microorganisms[, !sapply(AMR:
77
73
  antibiotics = pandas2ri.rpy2py(robjects.r('AMR::antibiotics[, !sapply(AMR::antibiotics, is.list)]'))
78
74
  clinical_breakpoints = pandas2ri.rpy2py(robjects.r('AMR::clinical_breakpoints[, !sapply(AMR::clinical_breakpoints, is.list)]'))
79
75
 
80
- print(f"{BLUE}AMR:{RESET} {GREEN}Done.{RESET}", flush=True)
76
+ print(f"AMR: Done.", flush=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: AMR
3
- Version: 2.1.1.9128
3
+ Version: 2.1.1.9131
4
4
  Summary: A Python wrapper for the AMR R package
5
5
  Home-page: https://github.com/msberends/AMR
6
6
  Author: Matthijs Berends
@@ -0,0 +1,7 @@
1
+ AMR/__init__.py,sha256=-3zoWVuhybnYkXePzljDrtcxxaAQscPpCPP75EiqLfQ,7540
2
+ AMR/datasets.py,sha256=t3ilqlqKu0rr4iHjG79fyWAXbdUw-WhCYyyeyZWxqoo,2629
3
+ AMR/functions.py,sha256=JSh-0_mfrAj7ajpazlv2KFyEtRAglj7oQV9Iiaux7eo,45557
4
+ AMR-2.1.1.9131.dist-info/METADATA,sha256=DiSb3VbJq3AYOELVYt8VEPdal0gyzkQZVKu-BTfvoDE,9624
5
+ AMR-2.1.1.9131.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
6
+ AMR-2.1.1.9131.dist-info/top_level.txt,sha256=7K6Mq_X_OHdXOzQM5y06VUadXjYkze6yzufL1d7_6xc,4
7
+ AMR-2.1.1.9131.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- AMR/__init__.py,sha256=-3zoWVuhybnYkXePzljDrtcxxaAQscPpCPP75EiqLfQ,7540
2
- AMR/datasets.py,sha256=tNLt7ERRxR-HYWD_gY6NwkMjdTIkg0bqtdi98U7sCyQ,2673
3
- AMR/functions.py,sha256=JSh-0_mfrAj7ajpazlv2KFyEtRAglj7oQV9Iiaux7eo,45557
4
- AMR-2.1.1.9128.dist-info/METADATA,sha256=QnZSp517HzD7Z-fb-IBsRM2Yl0rrcib0ikS4di8j2gE,9624
5
- AMR-2.1.1.9128.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
6
- AMR-2.1.1.9128.dist-info/top_level.txt,sha256=7K6Mq_X_OHdXOzQM5y06VUadXjYkze6yzufL1d7_6xc,4
7
- AMR-2.1.1.9128.dist-info/RECORD,,