def test_get(self): """Test getting content from the bioregistry.""" ncbitaxon_entry = bioregistry.get('ncbitaxon') self.assertIn('synonyms', ncbitaxon_entry) self.assertIn('NCBI_Taxon_ID', ncbitaxon_entry['synonyms']) self.assertIn('miriam', ncbitaxon_entry) self.assertIn('obofoundry', ncbitaxon_entry) self.assertIn('ols', ncbitaxon_entry) self.assertIn('wikidata', ncbitaxon_entry)
def _get_version_type(bioregistry_id) -> Optional[VersionType]: ols_entry = bioregistry.get(bioregistry_id) ols_version_type = ols_entry.get('ols_version_type') ols_version_date_format = ols_entry.get('ols_version_date_format') if ols_version_date_format: return VersionType.date elif ols_version_type: return getattr(VersionType, ols_version_type) else: logger.warning('[%s] missing version type', bioregistry_id)
def resource(prefix: str): """Get an entry. --- parameters: - name: prefix in: path description: The prefix for the entry required: true type: string example: doid """ # noqa:DAR101,DAR201 prefix = _normalize_prefix_or_404(prefix) return jsonify(prefix=prefix, **bioregistry.get(prefix)) # type:ignore
def test_name_expansions(self): """Test that default names are not capital acronyms.""" for prefix in bioregistry.read_registry(): if bioregistry.is_deprecated(prefix): continue entry = bioregistry.get(prefix) if 'name' in entry: continue name = bioregistry.get_name(prefix) if prefix == name.lower() and name.upper() == name: with self.subTest(prefix=prefix): self.fail(msg=f'{prefix} acronym ({name}) is not expanded') if '.' in prefix and prefix.split('.')[0] == name.lower(): with self.subTest(prefix=prefix): self.fail(msg=f'{prefix} acronym ({name}) is not expanded')
def test_no_redundant_acronym(self): """Test that there is no redundant acronym in the name. For example, "Amazon Standard Identification Number (ASIN)" is a problematic name for prefix "asin". """ for prefix in bioregistry.read_registry(): if bioregistry.is_deprecated(prefix): continue entry = bioregistry.get(prefix) if 'name' in entry: continue name = bioregistry.get_name(prefix) try: _, rest = name.rstrip(')').rsplit('(', 1) except ValueError: continue if rest.lower() == prefix.lower(): with self.subTest(prefix=prefix): self.fail(msg=f'{prefix} has redundany acronym in name "{name}"')