moleculekit.tools.survey module#
Survey an input structure before building an MD system, and verify the build result afterwards.
surveyStructure() runs, in one call, every detection a structure needs
before anything is submitted to a builder: what the structure is (a candidate
RCSB entry recovered by sequence search when the input is a file of unknown
origin), whether it is a membrane protein (entry keywords, when the entry is
known), the full reference sequence of every chain (RCSB entity sequences, a
sequence search, a UniProt accession, or a caller-supplied sequence), the
unresolved stretches (gaps) and sequence mismatches (mutations) against that
reference, and every residue whose bonds and formal charges are unknown. It also
classifies each protein chain terminus as a real biological end or a cut, which
is what decides whether that terminus is capped or left charged. The results are
returned as a printable SurveyReport and persisted under
outdir (input.cif, sequences.json, survey.json) so later
sessions can act on them. Rerunning is how findings are refined: the resolved
sequences are reused (sequences.json is the source of truth once written),
and each parameter (pdbid=, sequences=, keep_mutations=) folds one
decision into the stored state.
verifyBuildResult() is the closing bracket: it compares a produced
structure against the pre-build input and reports backbone breaks, leftover
ACE/NME-style caps, and per-chain protein residue counts - the checks a job
status cannot make.
- class moleculekit.tools.survey.SurveyReport(structure, outdir, pdbid, membrane, candidate_pdbid, chains, unresolved, gaps, mismatches, skipped_ncaa_chains, nonstandard, termini)#
Bases:
objectWhat
surveyStructure()found, printable as a per-topic summary.Every field is JSON-serializable; the same content is written to
survey.jsonunder the survey’soutdir.terminiholds two entries per protein chain (seedetectTermini()): each end classified asnatural(a real biological terminus - leave it charged),truncated(a construct boundary or an unfilled break - cap it) orunknown, with theselandproposed_capa build request needs. It is the last field so positional construction of the earlier ones keeps working.
- class moleculekit.tools.survey.VerifyReport(reference, result, breaks, caps, caps_missing, caps_extra, residues_in, residues_out)#
Bases:
objectWhat
verifyBuildResult()found, printable as a per-check summary.cleanis True when the produced structure has no backbone breaks, no protein residues were lost relative to the input, and the caps are the ones asked for. A cap patching a backbone break still shows as the distance between the residues the cap sits between and is caught by thebreakscheck.
- moleculekit.tools.survey.surveyStructure(structure, outdir, pdbid=None, sequences=None, keep_mutations=False, trim=True)#
Survey a structure: everything a builder needs decided, in one call.
Loads the structure, writes it as
{outdir}/input.cif, resolves each protein chain’s full reference sequence, detects gaps, mismatches and non-standard residues, classifies every protein chain terminus as a real biological end or a cut (which is what decides its cap), and (when the entry is known) checks the RCSB membrane keywords. The resolved sequences are written to{outdir}/sequences.json(plain{chain: sequence}) and the full report to{outdir}/survey.json.Rerunning refines the stored state instead of redoing it: chains already in
sequences.jsonare not re-resolved (delete the file to start over), except that passing a newpdbidre-resolves every chain whose sequence did not come from the user, upgrading search hits to exact entity sequences.- Parameters:
structure (
str) – A structure file path, or a 4-letter RCSB PDB id.outdir (
str) – Directory forinput.cif,sequences.jsonandsurvey.json. Created if missing.pdbid (
str|None) – The structure’s RCSB entry when known. Inferred automatically whenstructureis itself a PDB id. For a file input, pass the id the user confirmed (e.g. the report’scandidate_pdbid) to unlock the membrane keyword check and exact entity sequences.sequences (
dict|None) –{chain: reference}supplied by the user, where each value is either a UniProt accession (fetched, and trimmed from the full-length precursor to the span the structure covers unlesstrim=False) or a raw one-letter sequence (used verbatim). These chains are never overwritten by later reruns.keep_mutations (
bool) – When True, patch the reference sequences to the residues actually observed at mismatch positions before detecting gaps - modelling the construct as crystallised rather than reverting it to the reference.trim (
bool) – Trim user-supplied precursor sequences to the span the structure covers (seesequences). Disable only to deliberately extend a terminus.
- Returns:
report – The printable survey findings; the same content is in
{outdir}/survey.json.- Return type:
- moleculekit.tools.survey.verifyBuildResult(reference, result, expected_caps=None)#
Verify a built or prepared structure against the pre-build input.
Three checks a job status cannot make: backbone continuity of the produced structure (an unclosed break is an unmodelled gap or one the builder capped), leftover ACE/NME-style caps (legitimate only at a real chain terminus), and per-chain protein residue counts against the input (a drop means residues were silently discarded).
- Parameters:
reference (
str) – Path of the pre-build input structure (what the build was asked to build).result (
str) – Path of the produced structure (a build output or a prepared file).expected_caps (
dictorNone) – The dict of caps passed to the builder:{selection: capname}. When given, the function compares only cap names and counts (never resids or chains), measured as result-minus-reference, because the builder renumbers every resid after capping and re-letters chains, so the input selections cannot be resolved in the output. A"none"entry means that terminus was to stay charged and is not a cap to find. An unrequested cap — including one patching a break — surfaces ascaps_extra. When None (the default), no cap comparison is done.
- Returns:
report – The findings;
report.cleansays whether every check passed, and printing the report gives the per-check summary.- Return type: