mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-09-28 04:48:12 +08:00
#81 moved gene set check into fileitem_source
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
# 0.3.11
|
||||
|
||||
* #81 added support for gene sets via GATEWAY_ENABLE_GENE_SETS
|
||||
|
||||
# 0.3.10
|
||||
|
||||
* #65 Added GATEWAY_EXPIRE_SECONDS to set how long cellxgene servers can remain idle before being terminated.
|
||||
|
||||
@@ -20,23 +20,15 @@ def render_annotations(item, item_source):
|
||||
item_source.get_annotations_subpath(item), item_source.name
|
||||
)
|
||||
new_annotation = f"<a class='new' href='{url}'>new</a>"
|
||||
non_gene_set_files = []
|
||||
if item.annotations is not None:
|
||||
# Do not also display files to store gene_sets. These should be loaded
|
||||
# by clicking on the associated annotations file (i.e. without the
|
||||
# appended "_gene_sets")
|
||||
for a in item.annotations:
|
||||
if (len(a.name) < 10) or (a.name[-10:] != "_gene_sets"):
|
||||
non_gene_set_files.append(a)
|
||||
annotations = (
|
||||
", ".join(
|
||||
[
|
||||
f"<a href='{CacheKey(item, item_source, a).view_url}/'>{a.name}</a>"
|
||||
for a in non_gene_set_files
|
||||
for a in item.annotations
|
||||
]
|
||||
)
|
||||
+ ", "
|
||||
if non_gene_set_files
|
||||
if item.annotations
|
||||
else ""
|
||||
)
|
||||
return " | annotations: " + annotations + new_annotation
|
||||
|
||||
@@ -35,6 +35,8 @@ class FileItemSource(ItemSource):
|
||||
def name(self):
|
||||
return self._name or f"Files:{self.base_path}"
|
||||
|
||||
def is_gene_set(self, path:str) -> bool:
|
||||
return ('_gene_sets' in path or '-gene-sets' in path) and path.endswith(self.annotation_file_suffix)
|
||||
def is_h5ad_file(self, path: str) -> bool:
|
||||
return path.endswith(self.h5ad_suffix) and os.path.isfile(path)
|
||||
|
||||
@@ -180,6 +182,7 @@ class FileItemSource(ItemSource):
|
||||
self.make_fileitem_from_path(annotation, annotations_subpath, True)
|
||||
for annotation in sorted(os.listdir(annotations_fullpath))
|
||||
if annotation.endswith(self.annotation_file_suffix)
|
||||
and not self.is_gene_set(annotation)
|
||||
and os.path.isfile(os.path.join(annotations_fullpath, annotation))
|
||||
]
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user