Skip to content

metadata

Metadata extraction and ranking helpers for structures.

StructureMetadata dataclass

Metadata extracted from a structure file for ranking and grouping.

Attributes:

Name Type Description
id str

The structure ID.

uniprot_accession str | None

The UniProt accession if available and only one, otherwise None.

resolution float

The resolution of the structure in Angstroms.

total_residue_count int

The total number of residues in the structure.

is_alphafold bool

True if the structure was predicted by AlphaFold, otherwise False.

uniprot_start int

The start position of the UniProt sequence in the structure.

uniprot_end int

The end position of the UniProt sequence in the structure.

sequence_identity float

The sequence identity between the structure and the UniProt sequence.

chain_length int

The length of the chain in the structure.

auth_chain str

The chain in 'auth' id system.

label_chain str

The chain in 'label' id system.

method StructureMethod

The experimental method used to determine the structure.

structure_metadata(structure, *, path=None)

Extract metadata from a Gemmi structure.

If no UniProt accession is found, returns metadata with uniprot_accession=None and first chain in alphabetical order.

If multiple accessions are found within one chain, chooses the accession with the highest aligned residue count from _struct_ref_seq. Ties are resolved alphabetically by accession for deterministic behavior.

If accessions map to multiple chains, logs a warning and returns metadata with uniprot_accession=None and first chain in alphabetical order.

Parameters:

Name Type Description Default
structure Structure

A Gemmi structure.

required
path Path | None

Optional source path used only for error context.

None

Returns:

Type Description
StructureMetadata

A StructureMetadata instance.

Raises:

Type Description
ValueError

If no UniProt mapping is found in the structure.

ChainNotFoundError

If the chain specified in the UniProt mapping is not found in the structure.