moleculekit.opm module#

moleculekit.opm.align_to_opm(mol, molsel='all', maxalignments=3, opmid=None, macrotype='protein')#

Align a Molecule to proteins/nucleics in the OPM database by sequence search

The matching entry is found with RCSB’s hosted sequence search, and the residue ranges it is aligned over with a local Biopython alignment. Passing opmid skips the search entirely.

Parameters:
  • mol (Molecule) – The query molecule. The alignments will be done on the first frame only.

  • molsel (str | ndarray) – The atom selection for the query molecule to use. Can be an atom selection string, a boolean mask, or an integer index array.

  • maxalignments (int) – The maximum number of aligned structures to return

  • opmid (str | None) – An OPM ID to align onto. Passing one skips the search: the database is narrowed to that entry and only the residue ranges are computed.

  • macrotype (str) – If to align on “protein” or “nucleic”

Returns:

results – Returns a number of alignments (maximum maxalignments). For each alignment it might contain a number of HSPs (high-scoring pairs) which correspond to different sequence alignments of the query on the same hit protein.

Return type:

list

moleculekit.opm.blast_search_opm(query, sequences)#

Search a query sequence against OPM protein sequences using BLAST+.

Builds a temporary BLAST protein database from the protein sequences of the OPM database and runs blastp for the query sequence. This requires the makeblastdb and blastp executables (from BLAST+) to be available on the system PATH.

Parameters:
  • query (str) – The query protein sequence to search for.

  • sequences (dict) – The OPM sequences database, as produced by generate_opm_sequences(), keyed by PDB id with a "protein" entry mapping chain ids to sequences.

Returns:

hits – The BLAST search hits, as parsed from the blastp JSON output.

Return type:

list

moleculekit.opm.generate_opm_sequences(opm_pdbs, outjson)#

Extract protein and nucleic sequences from OPM PDB files into an xz-compressed JSON file.

Each input PDB is filtered of its DUM placeholder atoms, loaded as a Molecule, and split into protein and nucleic components. The per-chain sequences (dropping chains shorter than 5 residues or consisting only of unknown X residues) are collected and written to an xz-compressed JSON file keyed by the PDB file basename. This is used to build the searchable database consumed by align_to_opm().

Parameters:
  • opm_pdbs (list) – Paths to the OPM PDB files to process.

  • outjson (str) – Path to the xz-compressed JSON file that the collected sequences are written to.

moleculekit.opm.get_opm_pdb(pdbid, keep=False, keepaltloc='A', validateElements=False)#

Download a membrane system from the OPM.

Parameters:
  • pdbid (str) – The 4-letter PDB code

  • keep (bool) – If False, removes the DUM atoms. If True, it keeps them.

  • keepaltloc (str) – Which altloc to keep if there are any

  • validateElements (bool) – Set to True to validate the elements read. Usually this will fail on OPM due to weird atom names

Returns:

Examples

>>> mol, thickness = get_opm_pdb("1z98")
>>> mol.numAtoms
7902
>>> thickness
28.2
>>> _, thickness = get_opm_pdb('4u15')
>>> thickness is None
True
moleculekit.opm.pairwise_search_opm(query, sequences, maxhits=3)#

Search a query sequence against OPM protein sequences with Biopython.

Scores the query against every chain in sequences with a local (Smith-Waterman) alignment, then returns the best maxhits in the shape align_to_opm() consumes: one entry per hit carrying a description title and its hsps records. Offsets are 1-based, start inclusive.

Parameters:
  • query (str) – The one-letter query protein sequence.

  • sequences (dict) – The OPM sequences database, keyed by PDB id with a "protein" entry mapping chain ids to sequences.

  • maxhits (int) – How many of the best-scoring chains to align and return.

Returns:

hits – Best-scoring first.

Return type:

list