Skip to content

uniprot_injection

UniProt injection and provenance helpers for structures.

add_uniprot_accessions2structure(structure_file, pdb2uniprot=None, *, structure=None, chain_system='auth')

Add UniProt accessions to a structure if they are missing, based on the provided pdb2uniprot mapping.

If structure has UniProt accession that is not in pdb2uniprot, it will be left unchanged. If structure has chain extraction provenance, the chain names from pdb2uniprot will be renamed to match the output chain name in the provenance.

Parameters:

Name Type Description Default
structure_file Path

Source mmCIF path to preserve raw SIFTS segment data when checking which UniProt mappings are already present.

required
pdb2uniprot Pdb2UniprotChainsMapping | None

Dictionary mapping PDB ID to structured UniProt chain mappings. If provided, will be used to inject UniProt accessions into the structure if they are missing. If None, the structure is returned unchanged.

None
structure Structure | None

The gemmi Structure object to add UniProt accessions to. Can be passed if caller already read structure. If not passed will use protein_quest.structure.formats.read_structure to read structure_file.

None
chain_system ChainIdSystem

System of chain ids in pdb2uniprot mapping.

'auth'

Returns:

Type Description
Structure

A tuple of (structure, injected, uniprot_mappings) where:

bool
  • structure: gemmi Structure object with UniProt accessions added if they were missing
UniprotChainMappings
  • injected: bool indicating whether UniProt accessions were injected
tuple[Structure, bool, UniprotChainMappings]
  • uniprot_chain_mappings: set of UniprotChainMapping that were considered for injection (from pdb2uniprot), empty set if none

apply_chain_provenance_to_uniprot_mappings(mappings, chain_provenance)

Apply chain extraction provenance to a set of UniprotChainMapping.

Parameters:

Name Type Description Default
mappings UniprotChainMappings

Set of UniprotChainMapping to apply provenance to.

required
chain_provenance ChainExtractionProvenance

ChainExtractionProvenance to apply to mappings.

required

Returns:

Type Description
UniprotChainMappings

Set of UniprotChainMapping with chain ids updated based on provenance.