import enum
from schrodinger.infra.util import enum_speedup
from schrodinger.models.jsonable import JsonableEnum
MAX_CHIMERIC_TEMPLATES = 9 # Because they are represented by digits 1-9
WEAK_CUTOFF = 12
LOW_CUTOFF = 30
HomologyStatus = enum_speedup(
enum.Enum('HomologyStatus', ['Target', 'Template']))
[docs]class OrderedEnum(enum.Enum):
def __ge__(self, other):
if self.__class__ is other.__class__:
return self.value >= other.value
return NotImplemented
def __gt__(self, other):
if self.__class__ is other.__class__:
return self.value > other.value
return NotImplemented
def __le__(self, other):
if self.__class__ is other.__class__:
return self.value <= other.value
return NotImplemented
def __lt__(self, other):
if self.__class__ is other.__class__:
return self.value < other.value
return NotImplemented
[docs]@enum.unique
class AlignmentQuality(OrderedEnum):
WEAK = enum.auto()
LOW = enum.auto()
ACCEPTABLE = enum.auto()
_REALIGN_TEXT_FORMAT = """
The template sequence does not appear to have been aligned with the target
({reason}). The sequences must be aligned before the model is built.<br/><br/>
Choose Align to run the alignment automatically, or Cancel if you wish to
cancel the model generation and correct the alignment yourself.
"""
WEAK_REALIGN_TEXT = _REALIGN_TEXT_FORMAT.format(
reason=f"ID less than {WEAK_CUTOFF}%")
LOW_REALIGN_TEXT = _REALIGN_TEXT_FORMAT.format(
reason=f"no gaps, ID < {LOW_CUTOFF}%")
LOW_PROCEED_TEXT = f"""
The template sequence does not appear to be a good match for the target (ID less
than {LOW_CUTOFF}%). The resulting model is likely to be poor quality.<br/><br/>
Continue anyway?
"""
_ONE_ONE_TEXT = "1 target, 1 template"
_CHIMERA_TEXT = "Multiple templates (chimera)"
_ONE_ONE_TOOLTIP = """
Basic single-chain model. Used when a single template structure is a close
match to the target sequence (high-identity).
"""
_CHIMERA_TOOLTIP = """
Chimeric or composite single-chain model. Used when no single template
structure has a high identity, but multiple templates correspond well to
different regions of the target.
"""
Mode = JsonableEnum("Mode", [
"ONE_ONE", "CHIMERA", "HOMOMULTIMER", "CONSENSUS", "HETEROMULTIMER",
"MANY_ONE"
],
start=0)
MODE_TEXTS = {
Mode.ONE_ONE: _ONE_ONE_TEXT,
Mode.MANY_ONE: "Batch single template modeling",
Mode.CHIMERA: _CHIMERA_TEXT,
Mode.HOMOMULTIMER: "Multiple templates (homomultimer)",
Mode.CONSENSUS: "Multiple templates (consensus)",
Mode.HETEROMULTIMER: "Multiple View tabs (heteromultimer)",
}
MODE_TOOLTIPS = [
(Mode.ONE_ONE, _ONE_ONE_TOOLTIP),
(Mode.MANY_ONE, """
Basic single-chain model repeated for multiple target sequences. Used when
a single template structure is a close match to several target sequences
(high-identity).
"""),
(Mode.CHIMERA, _CHIMERA_TOOLTIP),
(Mode.HOMOMULTIMER, """
Homomultimer model. Used to build a multi-chain structure from a set of
highly similar, correctly positioned templates.
"""),
(Mode.CONSENSUS, """
Consensus single-chain model. Used when no single template or set of
templates has a high identity with the target sequence. The model is based
on agreement between lower-identity templates.
"""),
(Mode.HETEROMULTIMER, """
Heteromultimer model. Used to build a multi-chain structure (or several
single-chain structures) from a set of individually modeled structures.
Each chain must have its own sequence and one or more matching templates.
"""),
]
HeteromultimerMode = JsonableEnum("HeteromultimerMode", ["ONE_ONE", "CHIMERA"],
start=0)
HETEROMULTIMER_MODE_TEXTS = [
(HeteromultimerMode.ONE_ONE, _ONE_ONE_TEXT),
(HeteromultimerMode.CHIMERA, _CHIMERA_TEXT),
]
HETEROMULTIMER_MODE_TOOLTIPS = [
(HeteromultimerMode.ONE_ONE, _ONE_ONE_TOOLTIP),
(HeteromultimerMode.CHIMERA, _CHIMERA_TOOLTIP),
]
StepState = enum.Enum("Step state", [
"ACCEPTABLE",
"QUESTIONABLE",
"FIXABLE",
"UNACCEPTABLE",
])
COMPLETED_TOOLTIP = """
<p>This step has been marked as complete.</p>
<p>To clear this state and enable the action link, click the green
checkmark to the left of the step name.</p>
"""
TARGET_SEQ_STEP_TT = """
<p>If the target is not already in the tab, use this link to load
a FASTA file. The imported sequence will be set as the
Reference.</p>
<p>If multiple sequences are imported, the first will be used. To
change the target, right-click the intended sequence and choose
<i>Set as Reference</i> from the menu.</p>
<p>The target will always be marked in the list with a green square.</p>
"""
BATCH_TARGET_SEQ_STEP_TT = """
<p>If the targets are not already in the tab, use this link to load a FASTA
file. The imported sequence will be set as the Reference and used to locate
the template in the next step.</p>
<p>If multiple sequences are imported, they will all be selected and marked as
targets with a green square. The first will be set as the Reference. To use
a different sequence in the search, right-click the sequence and choose
<i>Set as Reference</i> from the menu.</p>
"""
OTHER_TARGET_STEP_TT = """
<p>If you did not previously load all the targets into the tab, use this
link to import the rest now. (You may select more than one file from
within the Import dialog.)</p>
<p>The new sequences will be added below the Reference. To model only some
of the structureless sequences in the tab, select them in the sequence
list. The targets to be modeled will be marked with a green square.</p>
"""
TEMP_ST_STEP_TT = """
<p>If the template is not already in the tab, you may use one of these
links to add it. Choose <i>Import</i> to load it from a file, <i>Find</i>
to locate one via a BLAST search. When the search results are shown,
select one structure to import.</p>
<p>The newly imported sequence will be marked in the list as the template,
with a magenta color behind the structure icon. (If multiple structures
have been imported, select the sequence you want to use.)</p>
<p>If you need to return to the search results, just click <i>Find</i>
again.
"""
BATCH_TEMP_ST_STEP_TT = """
<p>If the template is not already in the tab, use one of these links to add
it. Choose <i>Import</i> to load it from a file, <i>Find</i> to run a BLAST
search. When the search results are shown, select one structure to import.</p>
<p>The new sequence will be selected and marked as the template, with a
magenta color behind the structure icon. (If multiple structures have been
imported, select the sequence you want to use.)</p>
<p>Then click the <i>Set as Reference</i> link. The template will move to
the top and become the Reference, and all structureless sequences in the
tab will be marked as targets, with a green square.</p>
"""
MULTI_TEMP_ST_STEP_TT = """
<p>If the templates are not already in the tab, you may use either of these
links to add them. Choose <i>Import</i> to load structures from a file,
<i>Find</i> to locate them via a BLAST search. When the search results are
shown, select the structures to import.</p>
<p>The newly imported structures will be marked in the list as templates,
with a magenta color behind their structure icons. (If extra structures
have been imported, select the sequences you want to use.)</p>
<p>If you need to return to the search results, just click <i>Find</i>
again.</p>
"""
BASE_ALIGN_SEQ_STEP_TT = """
<p>If the template sequence was not previously aligned to the target, use this
link to align them. The target must be set as the Reference (first sequence).
A Multiple Alignment will be run, using the settings from the Alignment
Pane.</p>
<p>The reported ID % indicates how well-aligned the sequences are (overall).
If the value is too low after alignment, the template may not be a good match
with the target. Click <i>Find Homologs</i> to choose another template from
the previous search results.</p>
<p>You can also try to improve the alignment at a critical region of the
template by selecting the relevant residues and running the alignment again,
or by manually editing the alignment.</p>
"""
BATCH_ALIGN_SEQ_STEP_TT = """
<p>Use this link to align all the target sequences to the template sequence.
The template <i>must</i> be set as the Reference (first sequence).</p>
<p>If there are any additional sequences in the tab, select the targets before
aligning.</p>
<p>A Multiple Alignment will be run, using the settings from the Alignment
Pane.</p>
"""
ALIGN_ST_SEQ_STE_TT = """
<p>Click the <i>Align Structures</i> link to align the template structures.
The first of the specified templates will be used as the reference.</p>
<p>To align on a different structure, reorder the template sequences in the
list, being careful to restore the previous selection or clear all selection
before aligning. Only the sequences with magenta behind their structure
icons will be structurally aligned.</p>
<p>After the structures are aligned, click the <i>Align Sequences</i> link
to align all the template sequences to the target sequence. The target must
be set as the Reference (first sequence). A Multiple Alignment will be run,
using the settings from the Alignment Pane.</p>
"""
HOMOMULTIMER_ALIGN_SEQ_STEP_TT = """
<p>If the template sequences were not previously aligned to the target, use
this link to align them. The target must be the Reference (first sequence).
If there are any extraneous sequences in the tab, select the templates
before aligning.</p>
<p>A Multiple Alignment will be run, using the settings from the Alignment
Pane.</p>
"""
REGION_STEP_TT = """
<p>Click the <i>Pick</i> button to define the regions of each template to be
used in the model. By default, only the first template will be used. It
will be highlighted in orange across the full width of the target (except
for structureless residues, which will show a cross-hatch texture).</p>
<p>To use a different template for a particular region of the model, press and
drag the mouse along that portion of the intended sequence. The highlight
will move there, and the panel will report that alternate regions have been
defined.</p>
<p>To change templates for a specific region, just press and drag along a
different template. To start over with the default template, click the
<i>Reset</i> link on the banner at the top of the tab.</p>
<p>When you are done picking alternate regions, close the banner or click the
<i>Pick</i> button again to turn off the special picking state. The orange
highlights will remain. To modify the regions, click <i>Pick</i> again.</p>
"""
LIGANDS_STEP_TT = """
<p>By default, this option keeps all recognized ligands from the template in
the model. The number of ligands to be preserved (if greater than zero) is
displayed above the <i>Choose...</i> link.</p>
<p>To <i>discard</i> all ligands, cofactors, and waters, click the blue
checkmark to turn the option off. The icon will turn gray, and the link
will disable. None of the extra molecules will be preserved.</p>
<p>To choose specific ligands to preserve, or to keep cofactors or waters,
click the link and follow the instructions on the popup. Proximity
constraints may also be set for each preserved ligand.</p>
"""
MULTI_TEMP_LIGS_STEP_TT = """
<p>By default, this option keeps all recognized ligands near the highlighted
regions of the templates in the model. The number of ligands to be
preserved (if greater than zero) is displayed above the <i>Choose...</i>
link.</p>
<p>To discard all ligands, cofactors, and waters, click the blue checkmark to
turn the option off. The icon will turn gray, and the link will disable.
None of the extra molecules will be preserved.</p>
<p>To choose specific ligands to preserve, or to keep specific cofactors or all
waters near the highlighted regions, click the link and follow the
instructions on the popup. Proximity constraints may also be set for each
preserved ligand.</p>
"""
SETTNGS_STEP_TT = """
<p>Click the link or the gear icon to change the modeling method, number of
models, or other modeling and output options. The text under this step
reflects the current settings.</p>
<p>The Knowledge-based method is the default. It constructs insertions and
closes gaps using segments from known structures. This option supports
multiple models of the structure.</p>
<p>The Energy-based method uses energy calculations to construct and refine
missing residues. It is much slower and will only generate a single model,
but it is also the only method that can be used with binding site proximity
constraints.</p>
"""
HETERO_MULTIMER_WIDGET_TT = """
<p>Select a target or a target and its template and click <i>Copy Selected</i>
to create a new tab containing those sequences. Repeat this action once per
available target to create the tabs needed for the modeling.</p>
<p>If you already have a template for each target sequence, you may instead
reorder your sequences so that each target is directly above its template.
Select all of the targets and templates and click <i>Copy Selected</i> once.
New tabs will be created for each target-template pair.</p>
<p>In both cases, the newly created tabs will be selected automatically in the
list below.</p>
"""
ALIGN_SEQ_STEPS_TT = """
<p>To optimize the binding site region after running the full alignment,
click the Optimization icon. (The icon will not be visible if the
overall alignment is very low.)</p>
"""
[docs]@enum.unique
class StepAction(enum.Enum):
IMPORT_SEQUENCE = "Import Sequence..."
IMPORT_SEQUENCES = "Import Sequences..."
FIND_HOMOLOGS = "Find..."
IMPORT_HOMOLOGS = "Import..."
SET_AS_REFERENCE = "Set as Reference"
RUN_ALIGNMENT = "Run Alignment"
ALIGN_STRUCTURES = "Align Structures"
ALIGN_SEQUENCES = "Align Sequences"
PICK = "Pick"
CHOOSE_LIGANDS = "Choose..."
VIEW_SETTINGS = "View Settings..."
[docs]@enum.unique
class PrimeMethod(JsonableEnum):
KNOWLEDGE = "Knowledge-based"
ENERGY = "Energy-based"