cap-anndata 0.2.1__tar.gz → 0.3.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. cap_anndata-0.3.0/PKG-INFO +54 -0
  2. cap_anndata-0.3.0/README.md +33 -0
  3. {cap_anndata-0.2.1 → cap_anndata-0.3.0}/cap_anndata/__init__.py +1 -1
  4. cap_anndata-0.3.0/cap_anndata/backed_dict.py +34 -0
  5. cap_anndata-0.3.0/cap_anndata/cap_anndata.py +600 -0
  6. cap_anndata-0.3.0/cap_anndata/reader.py +57 -0
  7. cap_anndata-0.3.0/cap_anndata.egg-info/PKG-INFO +54 -0
  8. {cap_anndata-0.2.1 → cap_anndata-0.3.0}/cap_anndata.egg-info/SOURCES.txt +2 -2
  9. {cap_anndata-0.2.1 → cap_anndata-0.3.0}/cap_anndata.egg-info/requires.txt +2 -3
  10. {cap_anndata-0.2.1 → cap_anndata-0.3.0}/setup.py +3 -4
  11. cap_anndata-0.3.0/test/test_backed_df.py +81 -0
  12. cap_anndata-0.3.0/test/test_backed_dict.py +36 -0
  13. {cap_anndata-0.2.1 → cap_anndata-0.3.0}/test/test_cap_anndata.py +275 -15
  14. cap_anndata-0.3.0/test/test_reader.py +63 -0
  15. cap_anndata-0.2.1/PKG-INFO +0 -253
  16. cap_anndata-0.2.1/README.md +0 -231
  17. cap_anndata-0.2.1/cap_anndata/backed_uns.py +0 -28
  18. cap_anndata-0.2.1/cap_anndata/cap_anndata.py +0 -287
  19. cap_anndata-0.2.1/cap_anndata/reader.py +0 -44
  20. cap_anndata-0.2.1/cap_anndata.egg-info/PKG-INFO +0 -253
  21. cap_anndata-0.2.1/test/test_backed_df.py +0 -81
  22. cap_anndata-0.2.1/test/test_backed_uns.py +0 -36
  23. cap_anndata-0.2.1/test/test_reader.py +0 -22
  24. {cap_anndata-0.2.1 → cap_anndata-0.3.0}/LICENSE +0 -0
  25. {cap_anndata-0.2.1 → cap_anndata-0.3.0}/cap_anndata/backed_df.py +0 -0
  26. {cap_anndata-0.2.1 → cap_anndata-0.3.0}/cap_anndata.egg-info/dependency_links.txt +0 -0
  27. {cap_anndata-0.2.1 → cap_anndata-0.3.0}/cap_anndata.egg-info/top_level.txt +0 -0
  28. {cap_anndata-0.2.1 → cap_anndata-0.3.0}/setup.cfg +0 -0
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.1
2
+ Name: cap_anndata
3
+ Version: 0.3.0
4
+ Summary: Partial read/write of AnnData (h5ad) files for low-memory operations with large datasets.
5
+ Home-page: https://github.com/cellannotation/cap-anndata
6
+ Author: R. Mukhin, A. Isaev
7
+ Author-email: roman@ebookapplications.com
8
+ Project-URL: Bug Tracker, https://github.com/cellannotation/cap-anndata/issues
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: License :: OSI Approved :: BSD License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: numpy>=1.23.5
16
+ Requires-Dist: pandas>=2.2.0
17
+ Requires-Dist: anndata>=0.10.0
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
20
+ Requires-Dist: setuptools~=69.1.1; extra == "dev"
21
+
22
+ # CAP-AnnData: Partial I/O for AnnData (.h5ad) Files
23
+
24
+ ## Overview
25
+ CAP-AnnData offering functionalities for selective reading and writing of [AnnData](https://pypi.org/project/anndata/)
26
+ file fields without the need for loading entire dataset (or even entire field) into memory.
27
+ For example, it allows to read and modify the single `obs` column taking nothing into memory except the column itself.
28
+ Package eager to replicate the original AnnData API as much as possible,
29
+ while providing additional features for efficient data manipulation for heavy datasets.
30
+
31
+ ## Installation
32
+ Install CAP-AnnData via pip:
33
+
34
+ ```commandline
35
+ pip install -U cap-anndata
36
+ ```
37
+
38
+ ## Basic Example
39
+
40
+ The example below displayes how to read a single `obs` column, create new obs column and propagate it to the `.h5ad` file.
41
+ ```python
42
+ from cap_anndata import read_h5ad
43
+
44
+ file_path = "your_data.h5ad"
45
+ with read_h5ad(file_path=file_path, edit=True) as cap_adata:
46
+ print(cap_adata.obs_keys()) # ['a', 'b', 'c']
47
+ print(cap_adata.obs) # Empty DataFrame
48
+ cap_adata.read_obs(columns=['a'])
49
+ print(cap_adata.obs.columns) # ['a']
50
+ cap_adata.obs['new_col'] = cap_adata.obs['a']
51
+ cap_adata.overwrite(fields=['obs'])
52
+ ```
53
+
54
+ More example can be found in the [How-TO](https://github.com/cellannotation/cap-anndata/blob/main/HOWTO.md) file.
@@ -0,0 +1,33 @@
1
+ # CAP-AnnData: Partial I/O for AnnData (.h5ad) Files
2
+
3
+ ## Overview
4
+ CAP-AnnData offering functionalities for selective reading and writing of [AnnData](https://pypi.org/project/anndata/)
5
+ file fields without the need for loading entire dataset (or even entire field) into memory.
6
+ For example, it allows to read and modify the single `obs` column taking nothing into memory except the column itself.
7
+ Package eager to replicate the original AnnData API as much as possible,
8
+ while providing additional features for efficient data manipulation for heavy datasets.
9
+
10
+ ## Installation
11
+ Install CAP-AnnData via pip:
12
+
13
+ ```commandline
14
+ pip install -U cap-anndata
15
+ ```
16
+
17
+ ## Basic Example
18
+
19
+ The example below displayes how to read a single `obs` column, create new obs column and propagate it to the `.h5ad` file.
20
+ ```python
21
+ from cap_anndata import read_h5ad
22
+
23
+ file_path = "your_data.h5ad"
24
+ with read_h5ad(file_path=file_path, edit=True) as cap_adata:
25
+ print(cap_adata.obs_keys()) # ['a', 'b', 'c']
26
+ print(cap_adata.obs) # Empty DataFrame
27
+ cap_adata.read_obs(columns=['a'])
28
+ print(cap_adata.obs.columns) # ['a']
29
+ cap_adata.obs['new_col'] = cap_adata.obs['a']
30
+ cap_adata.overwrite(fields=['obs'])
31
+ ```
32
+
33
+ More example can be found in the [How-TO](https://github.com/cellannotation/cap-anndata/blob/main/HOWTO.md) file.
@@ -1,5 +1,5 @@
1
1
  from .backed_df import CapAnnDataDF
2
- from .backed_uns import CapAnnDataUns
2
+ from .backed_dict import CapAnnDataDict
3
3
  from .cap_anndata import CapAnnData
4
4
  from .reader import (
5
5
  read_directly,
@@ -0,0 +1,34 @@
1
+ from typing import Set, Any
2
+
3
+
4
+ class CapAnnDataDict(dict):
5
+ __keys_to_remove: Set[str] = None
6
+
7
+ def __delitem__(self, __key: Any) -> None:
8
+ self.keys_to_remove.add(__key)
9
+ return super().__delitem__(__key)
10
+
11
+ def __setitem__(self, __key: Any, __value: Any) -> None:
12
+ if __value is not None:
13
+ if __key in self.keys_to_remove:
14
+ self.keys_to_remove.remove(__key)
15
+ else:
16
+ self.keys_to_remove.add(__key)
17
+ return super().__setitem__(__key, __value)
18
+
19
+ @property
20
+ def keys_to_remove(self) -> Set[str]:
21
+ if self.__keys_to_remove is None:
22
+ self.__keys_to_remove = set()
23
+ return self.__keys_to_remove
24
+
25
+ def pop(self, __key: Any, __default: Any = None) -> Any:
26
+ if __key in self:
27
+ self.keys_to_remove.add(__key)
28
+ return super().pop(__key, __default)
29
+
30
+ def popitem(self) -> Any:
31
+ item = super().popitem()
32
+ key = item[0]
33
+ self.keys_to_remove.add(key)
34
+ return item