Ejemplo n.º 1
0
    def make_fileitem_from_path(
        self, filename, subpath, is_annotation=False, is_shallow=False
    ) -> FileItem:
        if is_annotation and filename.endswith(self.annotation_file_suffix):
            name = filename[: -len(self.annotation_file_suffix)]
            ext = self.annotation_file_suffix
        else:
            name = filename
            ext = ""
        item = FileItem(
            subpath=subpath,
            name=name,
            ext=ext,
            type=ItemType.annotation if is_annotation else ItemType.h5ad,
        )

        if not is_annotation and not is_shallow:
            annotations = self.make_annotations_for_fileitem(item)
            item.annotations = annotations

        return item
Ejemplo n.º 2
0
 def create_annotation(self, item: FileItem, name: str) -> FileItem:
     annotation = self.make_fileitem_from_path(
         name, self.get_annotations_subpath(item), is_annotation=True)
     item.annotations = (item.annotations or []).append(annotation)
     return annotation