mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-27 02:18:11 +08:00
remove experimental ontology support (#2300)
* remove experimental ontology support * lint * remove ontologies from unit tests * additional test changes
This commit is contained in:
@@ -1,22 +1,14 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
import fastobo
|
||||
import fsspec
|
||||
|
||||
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.genesets import write_gene_sets_tidycsv
|
||||
|
||||
|
||||
class Annotations(metaclass=ABCMeta):
|
||||
""" baseclass for annotations, including ontologies 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"
|
||||
"""baseclass for annotations and gene sets"""
|
||||
|
||||
def __init__(self, config={}):
|
||||
self.ontology_data = None
|
||||
self.config = config
|
||||
|
||||
def user_annotations_enabled(self):
|
||||
@@ -33,27 +25,6 @@ class Annotations(metaclass=ABCMeta):
|
||||
if not self.gene_sets_save_enabled():
|
||||
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):
|
||||
schema = []
|
||||
labels = self.read_labels(data_adaptor)
|
||||
@@ -82,7 +53,7 @@ class Annotations(metaclass=ABCMeta):
|
||||
|
||||
@abstractmethod
|
||||
def read_gene_sets(self, data_adaptor):
|
||||
"""Return the gene sets from persistent storage """
|
||||
"""Return the gene sets from persistent storage"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
||||
Reference in New Issue
Block a user