def get_element(self, name: str) -> Optional[Element]: """ Gets an element that is identified by the given name, either as its name or as one of its aliases. Parameters ---------- name: str The name or alias of an element in the Biolink Model Returns ------- Element The element identified by the given name """ parsed_name = parse_name(name) logger.debug(parsed_name) element = self.generator.obj_for(parsed_name) if element is None and name in self.generator.aliases: logger.debug("in aliases") logger.debug(self.generator.aliases) element = self.get_element(self.generator.aliases[name]) if element is None and "_" in name: logger.debug("has a _") element = self.get_element(name.replace("_", " ")) return element
def get_element(self, name: str) -> Optional[Element]: """ Gets an element that is identified by the given name, either as its name or as one of its aliases. Parameters ---------- name: str The name or alias of an element in the Biolink Model Returns ------- Element The element identified by the given name """ parsed_name = parse_name(name) element = self.generator.obj_for(parsed_name) if element is None: if name in self.generator.aliases: element = self.get_element(self.generator.aliases[name]) if element is None: if '_' in name: element = self.get_element(name.replace('_', ' ')) if not element: logging.warning(f"{name} is not a valid Biolink Model element") return element
def in_subset(self, name: str, subset: str) -> bool: """ Determines whether the given name is in a given subset in the Biolink Model. Parameters ---------- name: str The name or alias of an element in the Biolink Model. subset: str The name of the subset Returns ------- bool That the named element is part of a given subset in Biolink Model """ parsed_name = parse_name(name) element = self.generator.obj_for(parsed_name) return subset in element.in_subset
def test_parse_name(query): n = parse_name(query[0]) assert n == query[1]