#81 moved gene set check into fileitem_source

This commit is contained in:
Alok Saldanha
2023-07-06 08:18:50 -06:00
parent 81c8ce4219
commit 5a650334df
3 changed files with 9 additions and 10 deletions
+4
View File
@@ -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.
+2 -10
View File
@@ -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: