remove experimental ontology support (#2300)

* remove experimental ontology support

* lint

* remove ontologies from unit tests

* additional test changes
This commit is contained in:
Bruce Martin
2021-07-14 07:23:38 -07:00
committed by GitHub
parent 45a8984223
commit e334fbe96e
35 changed files with 28 additions and 269 deletions
-1
View File
@@ -51,7 +51,6 @@ define_request_exception(
default_status_code=HTTPStatus.UNPROCESSABLE_ENTITY, default_status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
) )
define_exception("OntologyLoadFailure", "Raised when reading the ontology file fails")
define_exception("ConfigurationError", "Raised when checking configuration errors") define_exception("ConfigurationError", "Raised when checking configuration errors")
define_exception("PrepareError", "Raised when data is misprepared") define_exception("PrepareError", "Raised when data is misprepared")
define_exception("SecretKeyRetrievalError", "Raised when get_secret_key from AWS fails") define_exception("SecretKeyRetrievalError", "Raised when get_secret_key from AWS fails")
-18
View File
@@ -44,20 +44,6 @@ def annotation_args(func):
help="Directory of where to save output annotations; filename will be specified in the application. " help="Directory of where to save output annotations; filename will be specified in the application. "
"Incompatible with --annotations-file.", "Incompatible with --annotations-file.",
) )
@click.option(
"--experimental-annotations-ontology",
is_flag=True,
default=DEFAULT_CONFIG.default_dataset_config.user_annotations__ontology__enable,
show_default=True,
help="When creating annotations, optionally autocomplete names from ontology terms.",
)
@click.option(
"--experimental-annotations-ontology-obo",
default=DEFAULT_CONFIG.default_dataset_config.user_annotations__ontology__obo_location,
show_default=True,
metavar="<path or url>",
help="Location of OBO file defining cell annotation autosuggest terms.",
)
@functools.wraps(func) @functools.wraps(func)
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
return func(*args, **kwargs) return func(*args, **kwargs)
@@ -328,8 +314,6 @@ def launch(
annotations_dir, annotations_dir,
backed, backed,
disable_diffexp, disable_diffexp,
experimental_annotations_ontology,
experimental_annotations_ontology_obo,
experimental_enable_reembedding, experimental_enable_reembedding,
config_file, config_file,
dump_default_config, dump_default_config,
@@ -389,8 +373,6 @@ def launch(
user_annotations__enable=not disable_annotations, user_annotations__enable=not disable_annotations,
user_annotations__local_file_csv__file=annotations_file, user_annotations__local_file_csv__file=annotations_file,
user_annotations__local_file_csv__directory=annotations_dir, user_annotations__local_file_csv__directory=annotations_dir,
user_annotations__ontology__enable=experimental_annotations_ontology,
user_annotations__ontology__obo_location=experimental_annotations_ontology_obo,
presentation__max_categories=max_category_items, presentation__max_categories=max_category_items,
presentation__custom_colors=not disable_custom_colors, presentation__custom_colors=not disable_custom_colors,
embeddings__names=embedding, embeddings__names=embedding,
@@ -1,10 +1,8 @@
import fastobo
import fsspec
import os import os
from flask import current_app, has_request_context from flask import current_app, has_request_context
from backend.common.errors import OntologyLoadFailure, DisabledFeatureError from backend.common.errors import DisabledFeatureError
from backend.common.utils.type_conversion_utils import get_schema_type_hint_of_array from backend.common.utils.type_conversion_utils import get_schema_type_hint_of_array
from backend.common.genesets import write_gene_sets_tidycsv, read_gene_sets_tidycsv, validate_gene_sets from backend.common.genesets import write_gene_sets_tidycsv, read_gene_sets_tidycsv, validate_gene_sets
from backend.common.utils.data_locator import DataLocator from backend.common.utils.data_locator import DataLocator
@@ -12,14 +10,9 @@ from backend.common.utils.utils import path_join
class Annotations: class Annotations:
""" baseclass for annotations, including ontologies and genesets """ """baseclass for annotations and genesets"""
""" our default ontology is the PURL for the Cell Ontology.
See http://www.obofoundry.org/ontology/cl.html """
DefaultOnotology = "http://purl.obolibrary.org/obo/cl.obo"
def __init__(self, config={}): def __init__(self, config={}):
self.ontology_data = None
self.config = config self.config = config
def user_annotations_enabled(self): def user_annotations_enabled(self):
@@ -29,27 +22,6 @@ class Annotations:
if not self.user_annotations_enabled(): if not self.user_annotations_enabled():
raise DisabledFeatureError("User annotations are disabled.") raise DisabledFeatureError("User annotations are disabled.")
def load_ontology(self, path):
"""Load and parse ontologies - currently support OBO files only."""
if path is None:
path = self.DefaultOnotology
try:
with fsspec.open(path) as f:
obo = fastobo.iter(f)
terms = filter(lambda stanza: type(stanza) is fastobo.term.TermFrame, obo)
names = [tag.name for term in terms for tag in term if type(tag) is fastobo.term.NameClause]
self.ontology_data = names
except FileNotFoundError as e:
raise OntologyLoadFailure("Unable to find OBO ontology path") from e
except SyntaxError as e:
raise OntologyLoadFailure(f"{path}:{e.lineno}:{e.offset} OBO syntax error, unable to read ontology") from e
except Exception as e:
raise OntologyLoadFailure(f"{path}:Error loading OBO file") from e
def get_schema(self, data_adaptor): def get_schema(self, data_adaptor):
schema = [] schema = []
labels = self.read_labels(data_adaptor) labels = self.read_labels(data_adaptor)
@@ -126,7 +98,7 @@ class Annotations:
def dataset_uri_to_geneset_uri(data_uri_or_path): def dataset_uri_to_geneset_uri(data_uri_or_path):
""" given a dataset URI, return the associated gene set URI """ """given a dataset URI, return the associated gene set URI"""
data_basename = os.path.basename(data_uri_or_path) data_basename = os.path.basename(data_uri_or_path)
base, ext = os.path.splitext(data_basename) base, ext = os.path.splitext(data_basename)
if ext is not None: # strip extension, if any if ext is not None: # strip extension, if any
@@ -164,10 +164,4 @@ class AnnotationsHostedTileDB(Annotations):
params["annotations"] = True params["annotations"] = True
params["user_annotation_collection_name_enabled"] = False params["user_annotation_collection_name_enabled"] = False
if self.ontology_data:
params["annotations_cell_ontology_enabled"] = True
params["annotations_cell_ontology_terms"] = self.ontology_data
else:
params["annotations_cell_ontology_enabled"] = False
parameters.update(params) parameters.update(params)
@@ -115,7 +115,7 @@ class AnnotationsLocalFile(Annotations):
return os.getcwd() return os.getcwd()
def _get_filename(self, data_adaptor): def _get_filename(self, data_adaptor):
""" return the current annotation file name """ """return the current annotation file name"""
if self.output_file: if self.output_file:
return self.output_file return self.output_file
@@ -175,12 +175,6 @@ class AnnotationsLocalFile(Annotations):
params["annotations"] = True params["annotations"] = True
params["user_annotation_collection_name_enabled"] = True params["user_annotation_collection_name_enabled"] = True
if self.ontology_data:
params["annotations_cell_ontology_enabled"] = True
params["annotations_cell_ontology_terms"] = self.ontology_data
else:
params["annotations_cell_ontology_enabled"] = False
if self.output_file is not None: if self.output_file is not None:
# user has hard-wired the name of the annotation data collection # user has hard-wired the name of the annotation data collection
fname = os.path.basename(self.output_file) fname = os.path.basename(self.output_file)
@@ -47,9 +47,6 @@ def get_client_config(app_config, data_adaptor):
"annotations_genesets": True, # feature flag "annotations_genesets": True, # feature flag
"annotations_genesets_readonly": True, "annotations_genesets_readonly": True,
"annotations_genesets_summary_methods": ["mean"], "annotations_genesets_summary_methods": ["mean"],
"annotations_cell_ontology_enabled": False,
"annotations_cell_ontology_obopath": None,
"annotations_cell_ontology_terms": None,
"custom_colors": dataset_config.presentation__custom_colors, "custom_colors": dataset_config.presentation__custom_colors,
"diffexp-may-be-slow": False, "diffexp-may-be-slow": False,
"about_legal_tos": dataset_config.app__about_legal_tos, "about_legal_tos": dataset_config.app__about_legal_tos,
@@ -5,7 +5,7 @@ from backend.czi_hosted.common.annotations.annotations import Annotations
from backend.czi_hosted.common.annotations.hosted_tiledb import AnnotationsHostedTileDB from backend.czi_hosted.common.annotations.hosted_tiledb import AnnotationsHostedTileDB
from backend.czi_hosted.common.annotations.local_file_csv import AnnotationsLocalFile from backend.czi_hosted.common.annotations.local_file_csv import AnnotationsLocalFile
from backend.czi_hosted.common.config.base_config import BaseConfig from backend.czi_hosted.common.config.base_config import BaseConfig
from backend.common.errors import ConfigurationError, OntologyLoadFailure from backend.common.errors import ConfigurationError
from backend.czi_hosted.compute.scanpy import get_scanpy_module from backend.czi_hosted.compute.scanpy import get_scanpy_module
from backend.czi_hosted.data_common.matrix_loader import MatrixDataLoader, MatrixDataType from backend.czi_hosted.data_common.matrix_loader import MatrixDataLoader, MatrixDataType
from backend.czi_hosted.db.db_utils import DbUtils from backend.czi_hosted.db.db_utils import DbUtils
@@ -33,10 +33,6 @@ class DatasetConfig(BaseConfig):
"directory" "directory"
] ]
self.user_annotations__local_file_csv__file = default_config["user_annotations"]["local_file_csv"]["file"] self.user_annotations__local_file_csv__file = default_config["user_annotations"]["local_file_csv"]["file"]
self.user_annotations__ontology__enable = default_config["user_annotations"]["ontology"]["enable"]
self.user_annotations__ontology__obo_location = default_config["user_annotations"]["ontology"][
"obo_location"
]
self.user_annotations__hosted_tiledb_array__db_uri = default_config["user_annotations"][ self.user_annotations__hosted_tiledb_array__db_uri = default_config["user_annotations"][
"hosted_tiledb_array" "hosted_tiledb_array"
]["db_uri"] ]["db_uri"]
@@ -101,10 +97,6 @@ class DatasetConfig(BaseConfig):
self.validate_correct_type_of_configuration_attribute( self.validate_correct_type_of_configuration_attribute(
"user_annotations__local_file_csv__file", (type(None), str) "user_annotations__local_file_csv__file", (type(None), str)
) )
self.validate_correct_type_of_configuration_attribute("user_annotations__ontology__enable", bool)
self.validate_correct_type_of_configuration_attribute(
"user_annotations__ontology__obo_location", (type(None), str)
)
self.validate_correct_type_of_configuration_attribute( self.validate_correct_type_of_configuration_attribute(
"user_annotations__hosted_tiledb_array__db_uri", (type(None), str) "user_annotations__hosted_tiledb_array__db_uri", (type(None), str)
) )
@@ -125,11 +117,6 @@ class DatasetConfig(BaseConfig):
self.handle_hosted_tiledb_annotations() self.handle_hosted_tiledb_annotations()
else: else:
raise ConfigurationError('The only annotation type support is "local_file_csv" or "hosted_tiledb_array') raise ConfigurationError('The only annotation type support is "local_file_csv" or "hosted_tiledb_array')
if self.user_annotations__ontology__enable or self.user_annotations__ontology__obo_location:
try:
self.user_annotations.load_ontology(self.user_annotations__ontology__obo_location)
except OntologyLoadFailure as e:
raise ConfigurationError("Unable to load ontology terms\n" + str(e))
else: else:
self.check_annotation_config_vars_not_set(context) self.check_annotation_config_vars_not_set(context)
@@ -197,13 +184,6 @@ class DatasetConfig(BaseConfig):
"Warning: hosted_file_directory for hosted_tiledb_array ignored as annotations are disabled." "Warning: hosted_file_directory for hosted_tiledb_array ignored as annotations are disabled."
) )
if self.user_annotations__ontology__enable:
context["messagefn"]("Warning: --experimental-annotations-ontology ignored as annotations are disabled.")
if self.user_annotations__ontology__obo_location is not None:
context["messagefn"](
"Warning: --experimental-annotations-ontology-obo ignored as annotations are disabled."
)
def handle_embeddings(self): def handle_embeddings(self):
self.validate_correct_type_of_configuration_attribute("embeddings__names", list) self.validate_correct_type_of_configuration_attribute("embeddings__names", list)
self.validate_correct_type_of_configuration_attribute("embeddings__enable_reembedding", bool) self.validate_correct_type_of_configuration_attribute("embeddings__enable_reembedding", bool)
-3
View File
@@ -194,9 +194,6 @@ dataset:
local_file_csv: local_file_csv:
directory: null directory: null
file: null file: null
ontology:
enable: false
obo_location: null
embeddings: embeddings:
names : [] names : []
-1
View File
@@ -1,7 +1,6 @@
anndata>=0.7.0 anndata>=0.7.0
boto3>=1.12.18 boto3>=1.12.18
click>=7.1.2 click>=7.1.2
fastobo>=0.6.1
Flask>=1.0.2,<2.0.0 # Flask 2.0 is not compatible with the latest version of Flask-RESTful (0.3.8) Flask>=1.0.2,<2.0.0 # Flask 2.0 is not compatible with the latest version of Flask-RESTful (0.3.8)
Flask-Compress>=1.4.0 Flask-Compress>=1.4.0
Flask-Cors>=3.0.6 Flask-Cors>=3.0.6
-18
View File
@@ -44,20 +44,6 @@ def annotation_args(func):
help="Directory of where to save output annotations; filename will be specified in the application. " help="Directory of where to save output annotations; filename will be specified in the application. "
"Incompatible with --annotations-file and --gene-sets-file.", "Incompatible with --annotations-file and --gene-sets-file.",
) )
@click.option(
"--experimental-annotations-ontology",
is_flag=True,
default=DEFAULT_CONFIG.dataset_config.user_annotations__ontology__enable,
show_default=True,
help="When creating annotations, optionally autocomplete names from ontology terms.",
)
@click.option(
"--experimental-annotations-ontology-obo",
default=DEFAULT_CONFIG.dataset_config.user_annotations__ontology__obo_location,
show_default=True,
metavar="<path or url>",
help="Location of OBO file defining cell annotation autosuggest terms.",
)
@click.option( @click.option(
"--disable-gene-sets-save", "--disable-gene-sets-save",
is_flag=True, is_flag=True,
@@ -338,8 +324,6 @@ def launch(
disable_gene_sets_save, disable_gene_sets_save,
backed, backed,
disable_diffexp, disable_diffexp,
experimental_annotations_ontology,
experimental_annotations_ontology_obo,
experimental_enable_reembedding, experimental_enable_reembedding,
config_file, config_file,
dump_default_config, dump_default_config,
@@ -396,8 +380,6 @@ def launch(
user_annotations__local_file_csv__directory=user_generated_data_dir, user_annotations__local_file_csv__directory=user_generated_data_dir,
user_annotations__local_file_csv__gene_sets_file=gene_sets_file, user_annotations__local_file_csv__gene_sets_file=gene_sets_file,
user_annotations__gene_sets__readonly=disable_gene_sets_save, user_annotations__gene_sets__readonly=disable_gene_sets_save,
user_annotations__ontology__enable=experimental_annotations_ontology,
user_annotations__ontology__obo_location=experimental_annotations_ontology_obo,
presentation__max_categories=max_category_items, presentation__max_categories=max_category_items,
presentation__custom_colors=not disable_custom_colors, presentation__custom_colors=not disable_custom_colors,
embeddings__names=embedding, embeddings__names=embedding,
@@ -1,22 +1,14 @@
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
import fastobo from backend.common.errors import DisabledFeatureError
import fsspec
from backend.common.errors import OntologyLoadFailure, DisabledFeatureError
from backend.common.utils.type_conversion_utils import get_schema_type_hint_of_array from backend.common.utils.type_conversion_utils import get_schema_type_hint_of_array
from backend.common.genesets import write_gene_sets_tidycsv from backend.common.genesets import write_gene_sets_tidycsv
class Annotations(metaclass=ABCMeta): class Annotations(metaclass=ABCMeta):
""" baseclass for annotations, including ontologies and gene sets""" """baseclass for annotations and gene sets"""
""" our default ontology is the PURL for the Cell Ontology.
See http://www.obofoundry.org/ontology/cl.html """
DefaultOnotology = "http://purl.obolibrary.org/obo/cl.obo"
def __init__(self, config={}): def __init__(self, config={}):
self.ontology_data = None
self.config = config self.config = config
def user_annotations_enabled(self): def user_annotations_enabled(self):
@@ -33,27 +25,6 @@ class Annotations(metaclass=ABCMeta):
if not self.gene_sets_save_enabled(): if not self.gene_sets_save_enabled():
raise DisabledFeatureError("User gene sets save is disabled.") raise DisabledFeatureError("User gene sets save is disabled.")
def load_ontology(self, path):
"""Load and parse ontologies - currently support OBO files only."""
if path is None:
path = self.DefaultOnotology
try:
with fsspec.open(path) as f:
obo = fastobo.iter(f)
terms = filter(lambda stanza: type(stanza) is fastobo.term.TermFrame, obo)
names = [tag.name for term in terms for tag in term if type(tag) is fastobo.term.NameClause]
self.ontology_data = names
except FileNotFoundError as e:
raise OntologyLoadFailure("Unable to find OBO ontology path") from e
except SyntaxError as e:
raise OntologyLoadFailure("Syntax error loading OBO ontology") from e
except Exception as e:
raise OntologyLoadFailure("Error loading OBO file") from e
def get_schema(self, data_adaptor): def get_schema(self, data_adaptor):
schema = [] schema = []
labels = self.read_labels(data_adaptor) labels = self.read_labels(data_adaptor)
@@ -82,7 +53,7 @@ class Annotations(metaclass=ABCMeta):
@abstractmethod @abstractmethod
def read_gene_sets(self, data_adaptor): def read_gene_sets(self, data_adaptor):
"""Return the gene sets from persistent storage """ """Return the gene sets from persistent storage"""
pass pass
@abstractmethod @abstractmethod
@@ -193,14 +193,14 @@ class AnnotationsLocalFile(Annotations):
return os.getcwd() return os.getcwd()
def _get_celllabels_filename(self, data_adaptor): def _get_celllabels_filename(self, data_adaptor):
""" return the current annotation file name """ """return the current annotation file name"""
if self.label_output_file: if self.label_output_file:
return self.label_output_file return self.label_output_file
return self._get_filename(data_adaptor, "cell-labels") return self._get_filename(data_adaptor, "cell-labels")
def _get_genesets_filename(self, data_adaptor): def _get_genesets_filename(self, data_adaptor):
""" return the current gene sets file name """ """return the current gene sets file name"""
if self.gene_sets_output_file: if self.gene_sets_output_file:
return self.gene_sets_output_file return self.gene_sets_output_file
@@ -263,12 +263,6 @@ class AnnotationsLocalFile(Annotations):
params["annotations_genesets_name_is_read_only"] = self.gene_sets_output_file is not None params["annotations_genesets_name_is_read_only"] = self.gene_sets_output_file is not None
params["user_annotation_collection_name_enabled"] = True params["user_annotation_collection_name_enabled"] = True
if self.ontology_data:
params["annotations_cell_ontology_enabled"] = True
params["annotations_cell_ontology_terms"] = self.ontology_data
else:
params["annotations_cell_ontology_enabled"] = False
if self.label_output_file is not None: if self.label_output_file is not None:
# user has hard-wired the name of the annotation cell label data collection # user has hard-wired the name of the annotation cell label data collection
fname = os.path.basename(self.label_output_file) fname = os.path.basename(self.label_output_file)
@@ -47,9 +47,6 @@ def get_client_config(app_config, data_adaptor):
"annotations_genesets": True, # feature flag "annotations_genesets": True, # feature flag
"annotations_genesets_readonly": dataset_config.user_annotations__gene_sets__readonly, "annotations_genesets_readonly": dataset_config.user_annotations__gene_sets__readonly,
"annotations_genesets_summary_methods": ["mean"], "annotations_genesets_summary_methods": ["mean"],
"annotations_cell_ontology_enabled": False,
"annotations_cell_ontology_obopath": None,
"annotations_cell_ontology_terms": None,
"custom_colors": dataset_config.presentation__custom_colors, "custom_colors": dataset_config.presentation__custom_colors,
"diffexp-may-be-slow": False, "diffexp-may-be-slow": False,
} }
+1 -24
View File
@@ -3,7 +3,7 @@ from os.path import splitext, isdir
from backend.server.common.annotations.local_file_csv import AnnotationsLocalFile from backend.server.common.annotations.local_file_csv import AnnotationsLocalFile
from backend.server.common.config.base_config import BaseConfig from backend.server.common.config.base_config import BaseConfig
from backend.common.errors import ConfigurationError, OntologyLoadFailure, AnnotationsError from backend.common.errors import ConfigurationError, AnnotationsError
from backend.server.compute.scanpy import get_scanpy_module from backend.server.compute.scanpy import get_scanpy_module
from backend.server.data_common.matrix_loader import MatrixDataLoader from backend.server.data_common.matrix_loader import MatrixDataLoader
@@ -28,10 +28,6 @@ class DatasetConfig(BaseConfig):
"directory" "directory"
] ]
self.user_annotations__local_file_csv__file = default_config["user_annotations"]["local_file_csv"]["file"] self.user_annotations__local_file_csv__file = default_config["user_annotations"]["local_file_csv"]["file"]
self.user_annotations__ontology__enable = default_config["user_annotations"]["ontology"]["enable"]
self.user_annotations__ontology__obo_location = default_config["user_annotations"]["ontology"][
"obo_location"
]
self.user_annotations__gene_sets__readonly = default_config["user_annotations"]["gene_sets"]["readonly"] self.user_annotations__gene_sets__readonly = default_config["user_annotations"]["gene_sets"]["readonly"]
self.user_annotations__local_file_csv__gene_sets_file = default_config["user_annotations"][ self.user_annotations__local_file_csv__gene_sets_file = default_config["user_annotations"][
"local_file_csv" "local_file_csv"
@@ -101,10 +97,6 @@ class DatasetConfig(BaseConfig):
self.validate_correct_type_of_configuration_attribute( self.validate_correct_type_of_configuration_attribute(
"user_annotations__local_file_csv__gene_sets_file", (type(None), str) "user_annotations__local_file_csv__gene_sets_file", (type(None), str)
) )
self.validate_correct_type_of_configuration_attribute("user_annotations__ontology__enable", bool)
self.validate_correct_type_of_configuration_attribute(
"user_annotations__ontology__obo_location", (type(None), str)
)
self.validate_correct_type_of_configuration_attribute("user_annotations__gene_sets__readonly", bool) self.validate_correct_type_of_configuration_attribute("user_annotations__gene_sets__readonly", bool)
if self.user_annotations__enable or not self.user_annotations__gene_sets__readonly: if self.user_annotations__enable or not self.user_annotations__gene_sets__readonly:
@@ -122,13 +114,6 @@ class DatasetConfig(BaseConfig):
else: else:
raise ConfigurationError('The only annotation type support is "local_file_csv"') raise ConfigurationError('The only annotation type support is "local_file_csv"')
if self.user_annotations__enable:
if self.user_annotations__ontology__enable or self.user_annotations__ontology__obo_location:
try:
self.user_annotations.load_ontology(self.user_annotations__ontology__obo_location)
except OntologyLoadFailure as e:
raise ConfigurationError("Unable to load ontology terms\n" + str(e))
self.check_annotation_config_vars_not_set(context) self.check_annotation_config_vars_not_set(context)
def handle_local_file_csv_annotations(self, context): def handle_local_file_csv_annotations(self, context):
@@ -183,14 +168,6 @@ class DatasetConfig(BaseConfig):
if not self.user_annotations__enable: if not self.user_annotations__enable:
if filename is not None: if filename is not None:
context["messagefn"]("Warning: --annotations-file ignored as annotations are disabled.") context["messagefn"]("Warning: --annotations-file ignored as annotations are disabled.")
if self.user_annotations__ontology__enable:
context["messagefn"](
"Warning: --experimental-annotations-ontology ignored as annotations are disabled."
)
if self.user_annotations__ontology__obo_location is not None:
context["messagefn"](
"Warning: --experimental-annotations-ontology-obo ignored as annotations are disabled."
)
if dirname is not None: if dirname is not None:
context["messagefn"]("Warning: --user-generated-data-dir ignored as annotations are disabled.") context["messagefn"]("Warning: --user-generated-data-dir ignored as annotations are disabled.")
-3
View File
@@ -66,9 +66,6 @@ dataset:
directory: null directory: null
file: null # annotations file name file: null # annotations file name
gene_sets_file: null # gene sets file name gene_sets_file: null # gene sets file name
ontology:
enable: false
obo_location: null
gene_sets: gene_sets:
readonly: false # gene sets CRUD enabled/disabled readonly: false # gene sets CRUD enabled/disabled
-1
View File
@@ -1,7 +1,6 @@
anndata>=0.7.0 anndata>=0.7.0
boto3>=1.12.18 boto3>=1.12.18
click>=7.1.2 click>=7.1.2
fastobo>=0.6.1
Flask>=1.0.2,<2.0.0 # Flask 2.0 is not compatible with the latest version of Flask-RESTful (0.3.8) Flask>=1.0.2,<2.0.0 # Flask 2.0 is not compatible with the latest version of Flask-RESTful (0.3.8)
Flask-Compress>=1.4.0 Flask-Compress>=1.4.0
Flask-Cors>=3.0.9 # CVE-2020-25032 Flask-Cors>=3.0.9 # CVE-2020-25032
@@ -22,9 +22,6 @@ dataset:
local_file_csv: local_file_csv:
directory: {local_file_csv_directory} directory: {local_file_csv_directory}
file: {local_file_csv_file} file: {local_file_csv_file}
ontology:
enable: {ontology_enabled}
obo_location: {obo_location}
embeddings: embeddings:
names: {embedding_names} names: {embedding_names}
-3
View File
@@ -17,9 +17,6 @@ dataset:
directory: {local_file_csv_directory} directory: {local_file_csv_directory}
file: {local_file_csv_file} file: {local_file_csv_file}
gene_sets_file: {local_file_csv_gene_sets_file} gene_sets_file: {local_file_csv_gene_sets_file}
ontology:
enable: {ontology_enabled}
obo_location: {obo_location}
gene_sets: gene_sets:
readonly: {gene_sets_readonly} readonly: {gene_sets_readonly}
@@ -124,8 +124,6 @@ class ConfigTests(BaseTest):
hosted_file_directory="null", hosted_file_directory="null",
local_file_csv_directory="null", local_file_csv_directory="null",
local_file_csv_file="null", local_file_csv_file="null",
ontology_enabled="false",
obo_location="null",
embedding_names=[], embedding_names=[],
enable_reembedding="false", enable_reembedding="false",
enable_difexp="true", enable_difexp="true",
@@ -193,8 +191,6 @@ class ConfigTests(BaseTest):
hosted_file_directory=hosted_file_directory, hosted_file_directory=hosted_file_directory,
local_file_csv_directory=local_file_csv_directory, local_file_csv_directory=local_file_csv_directory,
local_file_csv_file=local_file_csv_file, local_file_csv_file=local_file_csv_file,
ontology_enabled=ontology_enabled,
obo_location=obo_location,
embedding_names=embedding_names, embedding_names=embedding_names,
enable_reembedding=enable_reembedding, enable_reembedding=enable_reembedding,
enable_difexp=enable_difexp, enable_difexp=enable_difexp,
@@ -231,8 +227,6 @@ class ConfigTests(BaseTest):
hosted_file_directory="null", hosted_file_directory="null",
local_file_csv_directory="null", local_file_csv_directory="null",
local_file_csv_file="null", local_file_csv_file="null",
ontology_enabled="false",
obo_location="null",
embedding_names=[], embedding_names=[],
enable_reembedding="false", enable_reembedding="false",
enable_difexp="true", enable_difexp="true",
@@ -36,7 +36,6 @@ class BaseConfigTest(ConfigTests):
mapping = config.default_dataset_config.create_mapping(config.default_config) mapping = config.default_dataset_config.create_mapping(config.default_config)
self.assertIsNotNone(mapping["server__app__verbose"]) self.assertIsNotNone(mapping["server__app__verbose"])
self.assertIsNotNone(mapping["dataset__presentation__max_categories"]) self.assertIsNotNone(mapping["dataset__presentation__max_categories"])
self.assertIsNotNone(mapping["dataset__user_annotations__ontology__obo_location"])
self.assertIsNotNone(mapping["server__multi_dataset__allowed_matrix_types"]) self.assertIsNotNone(mapping["server__multi_dataset__allowed_matrix_types"])
def test_changes_from_default_returns_list_of_nondefault_config_values(self): def test_changes_from_default_returns_list_of_nondefault_config_values(self):
@@ -44,13 +44,12 @@ class TestDatasetConfig(ConfigTests):
self.assertEqual(config.default_dataset_config.presentation__max_categories, 1000) self.assertEqual(config.default_dataset_config.presentation__max_categories, 1000)
self.assertEqual(config.default_dataset_config.user_annotations__type, "local_file_csv") self.assertEqual(config.default_dataset_config.user_annotations__type, "local_file_csv")
self.assertEqual(config.default_dataset_config.diffexp__lfc_cutoff, 0.01) self.assertEqual(config.default_dataset_config.diffexp__lfc_cutoff, 0.01)
self.assertIsNone(config.default_dataset_config.user_annotations__ontology__obo_location)
@patch("backend.czi_hosted.common.config.dataset_config.BaseConfig.validate_correct_type_of_configuration_attribute") @patch("backend.czi_hosted.common.config.dataset_config.BaseConfig.validate_correct_type_of_configuration_attribute")
def test_complete_config_checks_all_attr(self, mock_check_attrs): def test_complete_config_checks_all_attr(self, mock_check_attrs):
mock_check_attrs.side_effect = BaseConfig.validate_correct_type_of_configuration_attribute() mock_check_attrs.side_effect = BaseConfig.validate_correct_type_of_configuration_attribute()
self.dataset_config.complete_config(self.context) self.dataset_config.complete_config(self.context)
self.assertEqual(mock_check_attrs.call_count, 21) self.assertEqual(mock_check_attrs.call_count, 19)
def test_app_sets_script_vars(self): def test_app_sets_script_vars(self):
config = self.get_config(scripts=["path/to/script"]) config = self.get_config(scripts=["path/to/script"])
@@ -95,8 +95,6 @@ class ConfigTests(unittest.TestCase):
local_file_csv_directory="null", local_file_csv_directory="null",
local_file_csv_file="null", local_file_csv_file="null",
local_file_csv_gene_sets_file="null", local_file_csv_gene_sets_file="null",
ontology_enabled="false",
obo_location="null",
gene_sets_readonly="false", gene_sets_readonly="false",
embedding_names=[], embedding_names=[],
enable_reembedding="false", enable_reembedding="false",
@@ -148,8 +146,6 @@ class ConfigTests(unittest.TestCase):
local_file_csv_directory=local_file_csv_directory, local_file_csv_directory=local_file_csv_directory,
local_file_csv_file=local_file_csv_file, local_file_csv_file=local_file_csv_file,
local_file_csv_gene_sets_file=local_file_csv_gene_sets_file, local_file_csv_gene_sets_file=local_file_csv_gene_sets_file,
ontology_enabled=ontology_enabled,
obo_location=obo_location,
gene_sets_readonly=gene_sets_readonly, gene_sets_readonly=gene_sets_readonly,
embedding_names=embedding_names, embedding_names=embedding_names,
enable_reembedding=enable_reembedding, enable_reembedding=enable_reembedding,
@@ -186,8 +182,6 @@ class ConfigTests(unittest.TestCase):
local_file_csv_directory="null", local_file_csv_directory="null",
local_file_csv_file="null", local_file_csv_file="null",
local_file_csv_gene_sets_file="null", local_file_csv_gene_sets_file="null",
ontology_enabled="false",
obo_location="null",
gene_sets_readonly="false", gene_sets_readonly="false",
embedding_names=[], embedding_names=[],
enable_reembedding="false", enable_reembedding="false",
@@ -131,9 +131,8 @@ class AppConfigTest(ConfigTests):
# test simple value in default dataset # test simple value in default dataset
config.update_single_config_from_path_and_value( config.update_single_config_from_path_and_value(
["dataset", "user_annotations", "ontology", "obo_location"], "dummy_location", ["dataset", "user_annotations"], "dummy_location",
) )
self.assertEqual(config.dataset_config.user_annotations__ontology__obo_location, "dummy_location")
# error checking # error checking
bad_paths = [ bad_paths = [
@@ -36,7 +36,6 @@ class BaseConfigTest(ConfigTests):
mapping = config.dataset_config.create_mapping(config.default_config) mapping = config.dataset_config.create_mapping(config.default_config)
self.assertIsNotNone(mapping["server__app__verbose"]) self.assertIsNotNone(mapping["server__app__verbose"])
self.assertIsNotNone(mapping["dataset__presentation__max_categories"]) self.assertIsNotNone(mapping["dataset__presentation__max_categories"])
self.assertIsNotNone(mapping["dataset__user_annotations__ontology__obo_location"])
def test_changes_from_default_returns_list_of_nondefault_config_values(self): def test_changes_from_default_returns_list_of_nondefault_config_values(self):
config = self.get_config(verbose="true", lfc_cutoff=0.05) config = self.get_config(verbose="true", lfc_cutoff=0.05)
@@ -40,14 +40,13 @@ class TestDatasetConfig(ConfigTests):
self.assertEqual(config.dataset_config.presentation__max_categories, 1000) self.assertEqual(config.dataset_config.presentation__max_categories, 1000)
self.assertEqual(config.dataset_config.user_annotations__type, "local_file_csv") self.assertEqual(config.dataset_config.user_annotations__type, "local_file_csv")
self.assertEqual(config.dataset_config.diffexp__lfc_cutoff, 0.01) self.assertEqual(config.dataset_config.diffexp__lfc_cutoff, 0.01)
self.assertIsNone(config.dataset_config.user_annotations__ontology__obo_location)
@patch("backend.server.common.config.dataset_config.BaseConfig.validate_correct_type_of_configuration_attribute") @patch("backend.server.common.config.dataset_config.BaseConfig.validate_correct_type_of_configuration_attribute")
def test_complete_config_checks_all_attr(self, mock_check_attrs): def test_complete_config_checks_all_attr(self, mock_check_attrs):
mock_check_attrs.side_effect = BaseConfig.validate_correct_type_of_configuration_attribute() mock_check_attrs.side_effect = BaseConfig.validate_correct_type_of_configuration_attribute()
self.dataset_config.complete_config(self.context) self.dataset_config.complete_config(self.context)
self.assertIsNotNone(self.config.server_config.data_adaptor) self.assertIsNotNone(self.config.server_config.data_adaptor)
self.assertEqual(mock_check_attrs.call_count, 19) self.assertEqual(mock_check_attrs.call_count, 17)
def test_app_sets_script_vars(self): def test_app_sets_script_vars(self):
config = self.get_config(scripts=["path/to/script"]) config = self.get_config(scripts=["path/to/script"])
-3
View File
@@ -22,9 +22,6 @@ dataset:
local_file_csv: local_file_csv:
directory: null directory: null
file: null file: null
ontology:
enable: false
obo_location: null
embeddings: embeddings:
names: [] names: []
@@ -8,7 +8,6 @@ import actions from "../../../actions";
@connect((state) => ({ @connect((state) => ({
annotations: state.annotations, annotations: state.annotations,
schema: state.annoMatrix?.schema, schema: state.annoMatrix?.schema,
ontology: state.ontology,
obsCrossfilter: state.obsCrossfilter, obsCrossfilter: state.obsCrossfilter,
})) }))
class Category extends React.PureComponent { class Category extends React.PureComponent {
@@ -57,8 +56,8 @@ class Category extends React.PureComponent {
}; };
labelNameError = (name) => { labelNameError = (name) => {
const { metadataField, ontology, schema } = this.props; const { metadataField, schema } = this.props;
return isLabelErroneous(name, metadataField, ontology, schema); return isLabelErroneous(name, metadataField, schema);
}; };
instruction = (label) => { instruction = (label) => {
@@ -71,8 +70,7 @@ class Category extends React.PureComponent {
render() { render() {
const { newLabelText } = this.state; const { newLabelText } = this.state;
const { metadataField, annotations, ontology, obsCrossfilter } = this.props; const { metadataField, annotations, obsCrossfilter } = this.props;
const ontologyEnabled = ontology?.enabled ?? false;
return ( return (
<> <>
@@ -97,7 +95,7 @@ class Category extends React.PureComponent {
handleCancel={this.disableAddNewLabelMode} handleCancel={this.disableAddNewLabelMode}
annoInput={ annoInput={
<LabelInput <LabelInput
labelSuggestions={ontologyEnabled ? ontology.terms : null} labelSuggestions={null}
onChange={this.handleChangeOrSelect} onChange={this.handleChangeOrSelect}
onSelect={this.handleChangeOrSelect} onSelect={this.handleChangeOrSelect}
inputProps={{ inputProps={{
@@ -10,7 +10,6 @@ import actions from "../../../actions";
@connect((state) => ({ @connect((state) => ({
annotations: state.annotations, annotations: state.annotations,
schema: state.annoMatrix?.schema, schema: state.annoMatrix?.schema,
ontology: state.ontology,
})) }))
class AnnoDialogEditCategoryName extends React.PureComponent { class AnnoDialogEditCategoryName extends React.PureComponent {
constructor(props) { constructor(props) {
@@ -105,8 +104,7 @@ class AnnoDialogEditCategoryName extends React.PureComponent {
render() { render() {
const { newCategoryText } = this.state; const { newCategoryText } = this.state;
const { metadataField, annotations, ontology } = this.props; const { metadataField, annotations } = this.props;
const ontologyEnabled = ontology?.enabled ?? false;
return ( return (
<> <>
@@ -132,7 +130,7 @@ class AnnoDialogEditCategoryName extends React.PureComponent {
annoInput={ annoInput={
<LabelInput <LabelInput
label={newCategoryText} label={newCategoryText}
labelSuggestions={ontologyEnabled ? ontology.terms : null} labelSuggestions={null}
onChange={this.handleChangeOrSelect} onChange={this.handleChangeOrSelect}
onSelect={this.handleChangeOrSelect} onSelect={this.handleChangeOrSelect}
inputProps={{ inputProps={{
+1 -4
View File
@@ -13,7 +13,6 @@ import actions from "../../actions";
@connect((state) => ({ @connect((state) => ({
writableCategoriesEnabled: state.config?.parameters?.annotations ?? false, writableCategoriesEnabled: state.config?.parameters?.annotations ?? false,
schema: state.annoMatrix?.schema, schema: state.annoMatrix?.schema,
ontology: state.ontology,
userInfo: state.userInfo, userInfo: state.userInfo,
})) }))
class Categories extends React.Component { class Categories extends React.Component {
@@ -130,10 +129,8 @@ class Categories extends React.Component {
const { const {
writableCategoriesEnabled, writableCategoriesEnabled,
schema, schema,
ontology,
userInfo, userInfo,
} = this.props; } = this.props;
const ontologyEnabled = ontology?.enabled ?? false;
/* all names, sorted in display order. Will be rendered in this order */ /* all names, sorted in display order. Will be rendered in this order */
const allCategoryNames = ControlsHelpers.selectableCategoryNames( const allCategoryNames = ControlsHelpers.selectableCategoryNames(
schema schema
@@ -158,7 +155,7 @@ class Categories extends React.Component {
handleCancel={this.handleDisableAnnoMode} handleCancel={this.handleDisableAnnoMode}
annoInput={ annoInput={
<LabelInput <LabelInput
labelSuggestions={ontologyEnabled ? ontology.terms : null} labelSuggestions={null}
onChange={this.handleChange} onChange={this.handleChange}
onSelect={this.handleSelect} onSelect={this.handleSelect}
inputProps={{ inputProps={{
@@ -3,7 +3,7 @@ import { Colors } from "@blueprintjs/core";
import { AnnotationsHelpers } from "../../util/stateManager"; import { AnnotationsHelpers } from "../../util/stateManager";
export function isLabelErroneous(label, metadataField, ontology, schema) { export function isLabelErroneous(label, metadataField, schema) {
/* /*
return false if this is a LEGAL/acceptable category name or NULL/empty string, return false if this is a LEGAL/acceptable category name or NULL/empty string,
or return an error type. or return an error type.
@@ -12,10 +12,9 @@ export function isLabelErroneous(label, metadataField, ontology, schema) {
/* allow empty string */ /* allow empty string */
if (label === "") return false; if (label === "") return false;
/* check for label syntax errors, but allow terms in ontology */ /* check for label syntax errors */
const termInOntology = ontology?.termSet.has(label) ?? false;
const error = AnnotationsHelpers.annotationNameIsErroneous(label); const error = AnnotationsHelpers.annotationNameIsErroneous(label);
if (error && !termInOntology) return error; if (error) return error;
/* disallow duplicates */ /* disallow duplicates */
const { obsByName } = schema.annotations; const { obsByName } = schema.annotations;
@@ -50,7 +50,6 @@ function _currentLabelAsString(ownProps) {
return { return {
annotations: state.annotations, annotations: state.annotations,
schema: state.annoMatrix?.schema, schema: state.annoMatrix?.schema,
ontology: state.ontology,
isDilated, isDilated,
isSelected, isSelected,
label, label,
@@ -118,9 +117,9 @@ class CategoryValue extends React.Component {
}; };
labelNameError = (name) => { labelNameError = (name) => {
const { metadataField, ontology, schema } = this.props; const { metadataField, schema } = this.props;
if (name === this.currentLabelAsString()) return false; if (name === this.currentLabelAsString()) return false;
return isLabelErroneous(name, metadataField, ontology, schema); return isLabelErroneous(name, metadataField, schema);
}; };
instruction = (label) => { instruction = (label) => {
@@ -490,14 +489,12 @@ class CategoryValue extends React.Component {
colorTable, colorTable,
isUserAnno, isUserAnno,
annotations, annotations,
ontology,
isDilated, isDilated,
isSelected, isSelected,
categorySummary, categorySummary,
label, label,
} = this.props; } = this.props;
const colorScale = colorTable?.scale; const colorScale = colorTable?.scale;
const ontologyEnabled = ontology?.enabled ?? false;
const { editedLabelText } = this.state; const { editedLabelText } = this.state;
@@ -634,7 +631,7 @@ class CategoryValue extends React.Component {
annoInput={ annoInput={
<LabelInput <LabelInput
label={editedLabelText} label={editedLabelText}
labelSuggestions={ontologyEnabled ? ontology.terms : null} labelSuggestions={null}
onChange={this.handleTextChange} onChange={this.handleTextChange}
onSelect={this.handleTextChange} onSelect={this.handleTextChange}
inputProps={{ inputProps={{
@@ -10,7 +10,6 @@ import actions from "../../../actions";
@connect((state) => ({ @connect((state) => ({
annotations: state.annotations, annotations: state.annotations,
schema: state.annoMatrix?.schema, schema: state.annoMatrix?.schema,
ontology: state.ontology,
obsCrossfilter: state.obsCrossfilter, obsCrossfilter: state.obsCrossfilter,
genesets: state.genesets.genesets, genesets: state.genesets.genesets,
genesetsUI: state.genesetsUI, genesetsUI: state.genesetsUI,
@@ -6,7 +6,6 @@ import LabelInput from "../../labelInput";
@connect((state) => ({ @connect((state) => ({
annotations: state.annotations, annotations: state.annotations,
schema: state.annoMatrix?.schema, schema: state.annoMatrix?.schema,
ontology: state.ontology,
obsCrossfilter: state.obsCrossfilter, obsCrossfilter: state.obsCrossfilter,
genesetsUI: state.genesetsUI, genesetsUI: state.genesetsUI,
genesets: state.genesets.genesets, genesets: state.genesets.genesets,
-2
View File
@@ -18,7 +18,6 @@ import annotations from "./annotations";
import genesets from "./genesets"; import genesets from "./genesets";
import genesetsUI from "./genesetsUI"; import genesetsUI from "./genesetsUI";
import autosave from "./autosave"; import autosave from "./autosave";
import ontology from "./ontology";
import centroidLabels from "./centroidLabels"; import centroidLabels from "./centroidLabels";
import pointDialation from "./pointDilation"; import pointDialation from "./pointDilation";
import { reembedController } from "./reembed"; import { reembedController } from "./reembed";
@@ -31,7 +30,6 @@ const Reducer = undoable(
["config", config], ["config", config],
["annoMatrix", annoMatrix], ["annoMatrix", annoMatrix],
["obsCrossfilter", obsCrossfilter], ["obsCrossfilter", obsCrossfilter],
["ontology", ontology],
["annotations", annotations], ["annotations", annotations],
["genesets", genesets], ["genesets", genesets],
["genesetsUI", genesetsUI], ["genesetsUI", genesetsUI],
-31
View File
@@ -1,31 +0,0 @@
const Ontology = (
state = {
enabled: false, // are ontology terms enabled?
terms: null, // an array of term names, eg, ['cell', 'lung cell', ...]
termSet: null, // a Set object containing all terms, for fast lookup
loading: true,
},
action
) => {
switch (action.type) {
case "configuration load complete": {
const enabled =
action.config?.parameters?.annotations_cell_ontology_enabled ?? false;
const terms = action.config?.parameters?.annotations_cell_ontology_terms;
const termSet = new Set(terms);
return {
...state,
loading: false,
enabled,
terms,
termSet,
};
}
default: {
return state;
}
}
};
export default Ontology;