Skip to main content
Glama
test_parsers.py2.1 kB
from __future__ import annotations import pytest from uniprot_mcp.adapters import parsers from uniprot_mcp.models.domain import Entry, MappingResult, SearchHit, Sequence @pytest.mark.parametrize("fixture_name", ["entry_reviewed.json", "entry_minimal.json"]) def test_parse_entry(load_fixture, fixture_name: str): entry_payload = load_fixture(fixture_name) entry = parsers.parse_entry(entry_payload) assert isinstance(entry, Entry) assert entry.accession == entry_payload["primaryAccession"] if fixture_name == "entry_reviewed.json": assert entry.reviewed is True assert entry.sequence and entry.sequence.mol_weight == 11023 assert entry.sequence.crc64 == "1234567890ABCDEF" assert entry.go and entry.go[0].id == "GO:0003677" assert entry.go[0].aspect == "MF" assert entry.xrefs and entry.xrefs[0].db == "Ensembl" assert entry.xrefs[0].url == "https://ensembl.org/ENSP00000269305" assert any(xref.db == "PDB" and xref.url for xref in entry.xrefs) else: assert entry.reviewed is False def test_parse_sequence_from_entry(load_fixture): payload = load_fixture("entry_reviewed.json") sequence = parsers.parse_sequence_from_entry(payload) assert isinstance(sequence, Sequence) assert sequence.length == 10 assert sequence.crc64 == "1234567890ABCDEF" assert sequence.mol_weight == 11023 def test_parse_search_hits(load_fixture): payload = load_fixture("search_results.json") hits = parsers.parse_search_hits(payload) assert isinstance(hits, list) assert len(hits) == 2 assert all(isinstance(hit, SearchHit) for hit in hits) assert hits[0].reviewed is True assert hits[1].reviewed is False def test_parse_mapping_result(load_fixture): payload = load_fixture("mapping_result.json") result = parsers.parse_mapping_result(payload, from_db="UniProtKB_AC-ID", to_db="Ensembl") assert isinstance(result, MappingResult) assert result.results["P12345"] == ["ENSP00000269305", "ENSP00000456789"] assert result.results["NO_MATCH"] == []

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/josefdc/Uniprot-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server