immucellai2 2.1.17__tar.gz → 2.1.19__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 (21) hide show
  1. {immucellai2-2.1.17 → immucellai2-2.1.19}/PKG-INFO +1 -1
  2. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/myfunction2.py +11 -73
  3. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2.egg-info/PKG-INFO +1 -1
  4. {immucellai2-2.1.17 → immucellai2-2.1.19}/setup.cfg +1 -1
  5. {immucellai2-2.1.17 → immucellai2-2.1.19}/README.md +0 -0
  6. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/__init__.py +0 -0
  7. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/myclasses.py +0 -0
  8. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/myconfig/Celltype.category +0 -0
  9. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/myconfig/MarkerUsedDeconvolution.txt +0 -0
  10. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/myconfig/reference_normalCelltypes.txt +0 -0
  11. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/myconfig/reference_tumorCelltypes.txt +0 -0
  12. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/myfunction1.py +0 -0
  13. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/myfunction3.py +0 -0
  14. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/myfunction4.py +0 -0
  15. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2/myfunction5.py +0 -0
  16. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2.egg-info/SOURCES.txt +0 -0
  17. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2.egg-info/dependency_links.txt +0 -0
  18. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2.egg-info/entry_points.txt +0 -0
  19. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2.egg-info/requires.txt +0 -0
  20. {immucellai2-2.1.17 → immucellai2-2.1.19}/immucellai2.egg-info/top_level.txt +0 -0
  21. {immucellai2-2.1.17 → immucellai2-2.1.19}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: immucellai2
3
- Version: 2.1.17
3
+ Version: 2.1.19
4
4
  Summary: A tool for immune cell type deconvolution
5
5
  Home-page: https://github.com/VyvyanYjm/ImmuCellAI2.0
6
6
  Author: YangJingmin
@@ -3,6 +3,7 @@ from .myclasses import CLASS_FOR_RUN
3
3
  from .myfunction3 import ObtainCellTypeCateogry
4
4
  import pandas
5
5
  import os
6
+ import importlib.util
6
7
  import re
7
8
  import sys
8
9
  import multiprocessing as mp
@@ -11,93 +12,30 @@ def Obtainmyconfigpath():
11
12
  script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
12
13
  return os.path.join(script_dir, "immucellai2", "myconfig", "")
13
14
 
15
+ def get_package_dir(package_name):
16
+ spec = importlib.util.find_spec(package_name)
17
+ if spec is None:
18
+ raise ModuleNotFoundError(f"Package '{package_name}' not found")
19
+ path = spec.origin or spec.submodule_search_locations[0]
20
+ return os.path.dirname(path)
21
+
14
22
  def SelectGeneForDeconvolution(DFReferenceProfile, FileCoveredGenes="", Method="UsedMarker"):
15
23
  print("Select the gene for the following deconvolution...")
16
24
  GeneUsedForDeconvolution = []
17
25
  DFReferenceProfileGenes = DFReferenceProfile.index.values
18
- print(f"[DEBUG] reference genes: {len(DFReferenceProfileGenes)}")
19
- print(f"[DEBUG] head: {DFReferenceProfileGenes[:5]}")
20
-
21
26
  if Method == "UsedMarker":
22
27
  if FileCoveredGenes == "":
23
- # ===== ͨ�û�·�����������ȼ��Ӹߵ��� =====
24
- FileCoveredGenes = None
25
-
26
- # ���ȼ�1����̬����immucellai2���ڵ�myconfigĿ¼�����ģ�
27
28
  try:
28
- # ��ʽ1��ͨ��ģ�鵼���ȡ����·�������ȶ����������а�װ��ʽ��
29
- import immucellai2.myconfig
30
- pkg_config_dir = os.path.dirname(immucellai2.myconfig.__file__)
31
- pkg_marker_path = os.path.join(pkg_config_dir, "MarkerUsedDeconvolution.txt")
29
+ pkg_marker_path = os.path.join(get_package_dir("immucellai2"), "myconfig/MarkerUsedDeconvolution.txt")
32
30
  if os.path.exists(pkg_marker_path):
33
31
  FileCoveredGenes = pkg_marker_path
34
32
  print(f"[INFO] Found marker file in immucellai2 package: {FileCoveredGenes}")
35
- except ImportError:
36
- # ��ʽ2��ͨ��importlib.resources.files����������Դ�����ã�
37
- try:
38
- marker_resource = files("immucellai2.myconfig").joinpath("MarkerUsedDeconvolution.txt")
39
- with as_file(marker_resource) as marker_path:
40
- if marker_path.exists():
41
- FileCoveredGenes = str(marker_path)
42
- print(f"[INFO] Found marker file in immucellai2 package (resources API): {FileCoveredGenes}")
43
- except Exception as e:
44
- pass # ����������һ������
45
-
46
- # ���ȼ�2���û��Զ��廷������������Դ������/�DZ�׼��װ��
47
- if FileCoveredGenes is None:
48
- config_dir = os.getenv("IMMUCELLAI_CONFIG_DIR")
49
- if config_dir:
50
- env_marker_path = os.path.join(config_dir, "MarkerUsedDeconvolution.txt")
51
- if os.path.exists(env_marker_path):
52
- FileCoveredGenes = env_marker_path
53
- print(f"[WARNING] Use marker file from env IMMUCELLAI_CONFIG_DIR: {FileCoveredGenes}")
54
-
55
- # ���ȼ�3����ǰ����Ŀ¼�µ�myconfig�������ֶ�����
56
- if FileCoveredGenes is None:
57
- cwd_config_dir = os.path.join(os.getcwd(), "myconfig")
58
- cwd_marker_path = os.path.join(cwd_config_dir, "MarkerUsedDeconvolution.txt")
59
- if os.path.exists(cwd_marker_path):
60
- FileCoveredGenes = cwd_marker_path
61
- print(f"[WARNING] Use marker file from current directory: {FileCoveredGenes}")
62
-
63
- # �������ȼ���ʧ�ܣ���ʾ�û�
64
- if FileCoveredGenes is None:
65
- print("[ERROR] Marker file 'MarkerUsedDeconvolution.txt' not found!")
66
- print("Solutions for users:")
67
- print(" 1. Install immucellai2 correctly: pip install --upgrade immucellai2")
68
- print(" 2. Set environment variable: export IMMUCELLAI_CONFIG_DIR='/path/to/your/myconfig/'")
69
- print(" 3. Put MarkerUsedDeconvolution.txt in ./myconfig/ (current working directory)")
70
- return []
71
-
72
- # ===== ͨ�û��ļ���ȡ�����ݸ�ʽ+³���� =====
73
- try:
74
- print(f"[DEBUG] getwd: {FileCoveredGenes}")
75
- # �޸�iloc[1] �� iloc[:,0]����ȡ��һ�������У����䵥�б���ļ���
76
- # ����error_bad_lines=False��������ʽ�������
77
- df_marker = pd.read_table(
78
- FileCoveredGenes,
79
- sep="\t",
80
- header=None,
81
- error_bad_lines=False,
82
- warn_bad_lines=True
83
- )
84
- # ��ȡ��һ�У�ȥ��+ȥ��+ת��д�����ݻ�������Сд��
85
- GeneUsedForDeconvolution0 = df_marker.iloc[:, 0].astype(str).str.strip()
86
- GeneUsedForDeconvolution0 = [gene.upper() for gene in GeneUsedForDeconvolution0 if gene and not gene.isdigit()]
87
- GeneUsedForDeconvolution0 = list(set(GeneUsedForDeconvolution0)) # ȥ��
88
-
89
- # �ο��׻�����Ҳת��д��ȷ������ƥ��
90
- DFReferenceProfileGenes_upper = [gene.upper() for gene in DFReferenceProfileGenes]
91
- # ȡ����
92
- GeneUsedForDeconvolution = list(set(GeneUsedForDeconvolution0) & set(DFReferenceProfileGenes_upper))
93
-
94
- print(f"[DEBUG] marker genes head: {GeneUsedForDeconvolution0[:5]}")
95
- print(f"Successfully loaded {len(GeneUsedForDeconvolution)} valid marker genes (total: {len(GeneUsedForDeconvolution0)})")
33
+ GeneUsedForDeconvolution0 = (pandas.read_table(FileCoveredGenes, sep= "\t")).iloc[0].to_list()
34
+ GeneUsedForDeconvolution = list(set(GeneUsedForDeconvolution0).intersection(set(DFReferenceProfileGenes)))
96
35
  except Exception as e:
97
36
  print(f"[ERROR] Failed to read marker file: {str(e)}")
98
37
  print("Tips for users: Check if MarkerUsedDeconvolution.txt is in 'single-column, no header' format")
99
38
  return []
100
-
101
39
  return GeneUsedForDeconvolution
102
40
 
103
41
  def CelltypeCategoryCheck(FileCellTypeCategory = "", celltypelist = [] ):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: immucellai2
3
- Version: 2.1.17
3
+ Version: 2.1.19
4
4
  Summary: A tool for immune cell type deconvolution
5
5
  Home-page: https://github.com/VyvyanYjm/ImmuCellAI2.0
6
6
  Author: YangJingmin
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = immucellai2
3
- version = 2.1.17
3
+ version = 2.1.19
4
4
  author = YangJingmin
5
5
  author_email = yangjingmin2021@163.com
6
6
  description = A tool for immune cell type deconvolution
File without changes