pythonflex 0.2.2__tar.gz → 0.2.4__tar.gz

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.
Files changed (24) hide show
  1. {pythonflex-0.2.2 → pythonflex-0.2.4}/PKG-INFO +1 -1
  2. {pythonflex-0.2.2 → pythonflex-0.2.4}/pyproject.toml +1 -1
  3. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/utils.py +26 -49
  4. {pythonflex-0.2.2 → pythonflex-0.2.4}/.gitignore +0 -0
  5. {pythonflex-0.2.2 → pythonflex-0.2.4}/.python-version +0 -0
  6. {pythonflex-0.2.2 → pythonflex-0.2.4}/README.md +0 -0
  7. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/__init__.py +0 -0
  8. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/analysis.py +0 -0
  9. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/data/dataset/liver_cell_lines_500_genes.csv +0 -0
  10. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/data/dataset/melanoma_cell_lines_500_genes.csv +0 -0
  11. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/data/dataset/neuroblastoma_cell_lines_500_genes.csv +0 -0
  12. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/data/gold_standard/CORUM.parquet +0 -0
  13. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/data/gold_standard/GOBP.parquet +0 -0
  14. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/data/gold_standard/PATHWAY.parquet +0 -0
  15. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/data/gold_standard/corum.csv +0 -0
  16. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/data/gold_standard/gobp.csv +0 -0
  17. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/data/gold_standard/pathway.csv +0 -0
  18. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/examples/basic_usage.py +0 -0
  19. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/examples/dataset_filtering.py +0 -0
  20. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/examples/test.py +0 -0
  21. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/logging_config.py +0 -0
  22. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/plotting.py +0 -0
  23. {pythonflex-0.2.2 → pythonflex-0.2.4}/src/pythonflex/preprocessing.py +0 -0
  24. {pythonflex-0.2.2 → pythonflex-0.2.4}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonflex
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: pythonFLEX is a benchmarking toolkit for evaluating CRISPR screen results against biological gold standards. The toolkit computes gene-level and complex-level performance metrics, helping researchers systematically assess the biological relevance and resolution of their CRISPR screening data.
5
5
  Author-email: Yasir Demirtaş <tyasird@hotmail.com>
6
6
  Requires-Python: >=3.9
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pythonflex"
3
- version = "0.2.2"
3
+ version = "0.2.4"
4
4
  description = "pythonFLEX is a benchmarking toolkit for evaluating CRISPR screen results against biological gold standards. The toolkit computes gene-level and complex-level performance metrics, helping researchers systematically assess the biological relevance and resolution of their CRISPR screening data."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -1,27 +1,13 @@
1
1
  import os
2
- import re # For sanitization (built-in, minimal regex)
2
+ import re
3
3
  import tempfile
4
4
  import joblib
5
5
  import numpy as np
6
6
  import pandas as pd
7
7
 
8
- # Constants - ADD .parquet to valid extensions
8
+ # Constants
9
9
  TMP_ROOT = ".tmp"
10
- VALID_EXTS = {".feather", ".parquet", ".npy", ".pkl"}
11
-
12
- # Minimal fix - just patch the problematic save
13
- original_to_feather = pd.DataFrame.to_feather
14
- def safe_to_feather(self, path, **kwargs):
15
- try:
16
- return original_to_feather(self, path, **kwargs)
17
- except ValueError as e:
18
- if "feather does not support serializing" in str(e):
19
- # FIXED: Better path handling
20
- parquet_path = os.path.splitext(path)[0] + '.parquet'
21
- self.to_parquet(parquet_path, **kwargs)
22
- else:
23
- raise
24
- pd.DataFrame.to_feather = safe_to_feather
10
+ VALID_EXTS = {".parquet", ".npy", ".pkl"} # Removed .feather
25
11
 
26
12
  # Helper to sanitize names (make filesystem-safe)
27
13
  def _sanitize(name):
@@ -40,36 +26,36 @@ def _safe_path(category, name=None, ext=".pkl"):
40
26
  safe_name = _sanitize(name) if name else "data"
41
27
  return os.path.join(dir_path, f"{safe_name}{ext}")
42
28
 
43
- # Save function
44
- def dsave(data, category, name=None, path=None): # 'path' ignored for compatibility with old code
29
+ # Save function - Parquet for DataFrames
30
+ def dsave(data, category, name=None, path=None):
45
31
  # If data is dict and no name, recurse on each item
46
32
  if name is None and isinstance(data, dict):
47
33
  for k, v in data.items():
48
34
  dsave(v, category, k)
49
35
  return
50
36
 
51
- # Choose best extension based on type
37
+ # Choose format based on type
52
38
  if isinstance(data, pd.DataFrame):
53
- ext = ".feather"
54
- save_func = lambda p: data.to_feather(p)
39
+ ext = ".parquet"
40
+ save_func = lambda p: data.to_parquet(p)
55
41
  elif isinstance(data, np.ndarray):
56
42
  ext = ".npy"
57
43
  save_func = lambda p: np.save(p, data, allow_pickle=False)
58
44
  else:
59
45
  ext = ".pkl"
60
- save_func = lambda p: joblib.dump(data, p, compress=0) # Add compress=3 if needed
46
+ save_func = lambda p: joblib.dump(data, p, compress=0)
61
47
 
62
48
  target = _safe_path(category, name, ext)
63
49
 
64
50
  # Atomic save: Write to temp file, then rename
65
- with tempfile.NamedTemporaryFile(dir=os.path.dirname(target), delete=False) as tf:
51
+ with tempfile.NamedTemporaryFile(dir=os.path.dirname(target), delete=False, suffix=ext) as tf:
66
52
  tmp_path = tf.name
67
- tf.close() # Close so save_func can write
53
+ tf.close()
68
54
  save_func(tmp_path)
69
- os.replace(tmp_path, target) # Atomic move
55
+ os.replace(tmp_path, target)
70
56
 
71
- # Load function - FIXED: Added parquet support
72
- def dload(category, name=None, path=None): # 'path' ignored for compatibility
57
+ # Load function - Parquet for DataFrames
58
+ def dload(category, name=None, path=None):
73
59
  dir_path = os.path.join(TMP_ROOT, _sanitize(category))
74
60
 
75
61
  if not os.path.exists(dir_path):
@@ -81,44 +67,35 @@ def dload(category, name=None, path=None): # 'path' ignored for compatibility
81
67
  for filename in os.listdir(dir_path):
82
68
  if not any(filename.endswith(ext) for ext in VALID_EXTS):
83
69
  continue
84
- k = os.path.splitext(filename)[0] # Key from filename (without ext)
70
+ k = os.path.splitext(filename)[0]
85
71
  full_path = os.path.join(dir_path, filename)
86
72
  try:
87
- if filename.endswith(".feather"):
88
- out[k] = pd.read_feather(full_path)
89
- elif filename.endswith(".parquet"): # ADDED
73
+ if filename.endswith(".parquet"):
90
74
  out[k] = pd.read_parquet(full_path)
91
75
  elif filename.endswith(".npy"):
92
- out[k] = np.load(full_path, mmap_mode="r") # MMap for perf
76
+ out[k] = np.load(full_path, mmap_mode="r")
93
77
  elif filename.endswith(".pkl"):
94
- out[k] = joblib.load(full_path, mmap_mode="r") # MMap for perf
78
+ out[k] = joblib.load(full_path, mmap_mode="r")
95
79
  except (EOFError, ValueError, OSError):
96
80
  print(f"Warning: '{full_path}' is corrupted. Skipping...")
97
- os.remove(full_path) # Delete corrupted file
81
+ os.remove(full_path)
98
82
  return out
99
83
 
100
- # Load specific name (try extensions in order - PREFER PARQUET over FEATHER)
101
- # Check parquet first since it's more reliable for complex data
102
- preferred_order = [".parquet", ".feather", ".npy", ".pkl"]
103
-
104
- for ext in preferred_order:
105
- if ext not in VALID_EXTS:
106
- continue
84
+ # Load specific name - try extensions in order
85
+ for ext in VALID_EXTS:
107
86
  target = _safe_path(category, name, ext)
108
87
  if os.path.exists(target):
109
88
  try:
110
- if ext == ".feather":
111
- return pd.read_feather(target)
112
- elif ext == ".parquet":
89
+ if ext == ".parquet":
113
90
  return pd.read_parquet(target)
114
91
  elif ext == ".npy":
115
- return np.load(target, mmap_mode="r") # MMap for perf
92
+ return np.load(target, mmap_mode="r")
116
93
  elif ext == ".pkl":
117
- return joblib.load(target, mmap_mode="r") # MMap for perf
94
+ return joblib.load(target, mmap_mode="r")
118
95
  except (EOFError, ValueError, OSError) as e:
119
96
  print(f"Warning: '{target}' is corrupted ({e}). Trying next format...")
120
- os.remove(target) # Delete corrupted file
121
- continue # Try next format instead of returning {}
97
+ os.remove(target)
98
+ continue
122
99
 
123
100
  print(f"Warning: No valid file found for {category}/{name}")
124
101
  return {}
File without changes
File without changes
File without changes
File without changes