Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Jul 14, 2022
1 parent d65ea45 commit 52aa270
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
12 changes: 8 additions & 4 deletions apis/python/src/tiledbsc/raw_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ def __init__(
super().__init__(uri=uri, name=name, parent=parent)
self.parent_obs = obs

X_uri = self._get_child_uri("X") # See comments in that function
var_uri = self._get_child_uri("var")
varm_uri = self._get_child_uri("varm")
varp_uri = self._get_child_uri("varp")
# TODO: COMMENT
member_names = ["X", "var", "varm", "varp"]
child_uris = self._get_child_uris(member_names) # See comments in that function

X_uri = child_uris["X"] # See comments in that function
var_uri = child_uris["var"]
varm_uri = child_uris["varm"]
varp_uri = child_uris["varp"]

self.var = AnnotationDataFrame(uri=var_uri, name="var", parent=self)
self.X = AssayMatrixGroup(
Expand Down
3 changes: 3 additions & 0 deletions apis/python/src/tiledbsc/soma_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def __getitem__(self, name: str) -> Optional[SOMA]:
Returns a `SOMA` element at the given name within the group, or `None` if no such
member exists. Overloads the `[...]` operator.
"""
if name in self._somas:
return self._somas[name]

with self._open("r") as G:
try:
obj = G[name] # This returns a tiledb.object.Object.
Expand Down
4 changes: 2 additions & 2 deletions apis/python/src/tiledbsc/tiledb_group.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Dict, Optional, Sequence, List
from typing import Dict, Optional, Sequence
import time

import tiledb
Expand Down Expand Up @@ -90,7 +90,7 @@ def _open(self, mode: str = "r") -> tiledb.Group:
return tiledb.Group(self.uri, mode=mode, ctx=self._ctx)

# XXX COMMENT
def _get_child_uris(self, member_names: List[str]) -> Dict[str, str]:
def _get_child_uris(self, member_names: Sequence[str]) -> Dict[str, str]:
"""
Computes the URI for a child of the given object. For local disk, S3, and
tiledb://.../s3://... pre-creation URIs, this is simply the parent's URI, a slash, and the
Expand Down
4 changes: 3 additions & 1 deletion apis/python/src/tiledbsc/uns_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ def from_anndata_uns(self, uns: Mapping[str, Any]) -> None:
# Must be done first, to create the parent directory
self.create_unless_exists()

child_uris = self._get_child_uris(list(uns.keys())) # See comments in that function

for key in uns.keys():
component_uri = self._get_child_uri(key) # See comments in that function
component_uri = child_uris[key] # See comments in that function
value = uns[key]

if key == "rank_genes_groups":
Expand Down

0 comments on commit 52aa270

Please sign in to comment.