"""
Constants that are shared between the view and viewmodel modules.
"""
from enum import Enum
from schrodinger.infra.util import enum_speedup
from schrodinger.models import jsonable
from schrodinger.ui.qt import table_helper
from schrodinger.ui.qt import table_speed_up
################################################################################
# Constants
################################################################################
DEFAULT_GAP = u'\u00B7' # · middle dot
TERMINAL_GAP = '\uFE32' # ︲ vertical en dash
MATCHING_RESIDUES_ONLY = "Residues matching reference"
DIFFERENT_RESIDUES_ONLY = "Residues differing from reference"
MIN_TEXT_SIZE = 4
MAX_TEXT_SIZE = 30
PROF_ALIGN_DISABLED_TT = """
Profile alignment is only available when aligning 2 alignment sets
or 1 alignment set and 1 loose sequence. The Reference
sequence must be part of the (first) alignment set.
"""
MULTI_ALIGN_ENABLED_TT = ("Run multiple sequence alignment algorithm on "
"selected sequences or on selected columns.")
MULTI_ALIGN_DISABLED_TT = """
This method can be used to align sequences within a single alignment set, or
sequences outside of any set, but not both. When aligning a set, the Reference
must be included in the set."""
ALIGN_SELECTED_ONLY_CB_TT = '''When toggled on, only the selected sequences will be
aligned to the Reference. The Reference sequence is
always used, regardless of selection.'''
# The QModelIndex internal id used to indicate a top-level row in the nested
# viewmodel proxies. (Internal ID is an unsigned 32-bit integer according to
# Qt's QModelIndex documentation.)
TOP_LEVEL = 2**32 - 1
################################################################################
# Roles
################################################################################
CustomRole = enum_speedup(
table_speed_up.MultipleRolesUserRolesEnum("CustomRole", [
"RowType",
"DataRange",
"Residue",
"ReferenceResidue",
"Consensus",
"Seq",
"ColorToolTip",
"HasDragHandle",
"AlignmentIdentity",
"AlignmentSimilarity",
"AlignmentConservation",
"AlignmentScore",
"ReferenceSequence",
"Included",
"EntryID",
"HasStructure",
"SeqExpanded",
"ConsensusSeq",
"SeqRowEntryID",
"RowTitle",
"ChainCol",
"RowHeightScale",
"LigandNames",
"DomainNames",
"PfamName",
"ResSelected",
"ColSelected",
"ResOrColSelected",
"SeqresOnly",
"ResidueIndex",
"MaxLength",
"SeqSelected",
"IncludeInDragImage",
"CanDropAbove",
"CanDropBelow",
"ResAnchored",
"IsAnchoredColumnRangeEnd",
"InsertionEdit",
"ReplacementEdit",
"ResSelectionBlockStart",
"MetricsType",
"InfoColumnType",
"ChainDivider",
"HomologyStatus",
"PartialPairwiseConstraint",
"ResOutline",
"MouseOver",
"PreviousRowHidden",
"NextRowHidden",
"AnnotationSelected",
"HMCompositeRegion",
"BindingSiteConstraint",
"NonstandardRes",
"SeqMatchesRefType",
"MultiRowAnnIndex",
]))
SeqInfo = enum_speedup(
table_helper.UserRolesEnum(
"SeqInfo",
["Name", "Title", "EntryName", "Chain", "GaplessLength", "GapCount"],
offset=100))
RoleBase = enum_speedup(
table_helper.UserRolesEnum("RoleBase", [
"SeqAnnotation",
"GlobalAnnotation",
"SeqAnnotationRange",
"GlobalAnnotationRange",
"SeqBackground",
"GlobalBackground",
"SeqForeground",
"GlobalForeground",
"SeqToolTip",
"GlobalToolTip",
"SeqRowHeightScale",
"SequenceProperty",
"SeqAnnotationIndexes",
"BindingSiteBackground",
"BindingSiteName",
"BindingSiteToolTip",
"KinaseConservationBackground",
"KinaseConservationToolTip",
"DomainBackground",
"DomainName",
"DomainToolTip",
],
offset=10000,
step_size=1000))
################################################################################
# Enums
################################################################################
RowType = enum_speedup(Enum("RowType", ["Sequence", "Spacer"]))
AnnotationType = enum_speedup(Enum("AnnotationType", ["Sequence", "Global"]))
GroupBy = enum_speedup(jsonable.JsonableEnum("GroupBy", ["Sequence", "Type"]))
ResidueFormat = enum_speedup(
jsonable.JsonableEnum('Format',
['OneLetter', 'ThreeLetter', 'HideLetters']))
ColumnMode = enum_speedup(
jsonable.JsonableEnum('ColumnMode', ['AllColumns', 'SelectedColumns']))
IdentityDisplayMode = enum_speedup(
jsonable.JsonableEnum('IdentityDisplayMode', ['Residue', 'MidDot']))
ColorByAln = enum_speedup(
jsonable.JsonableEnum('ColorByAln', [
'All', 'Matching', 'Different', 'MatchingCons', 'DifferentCons', 'Unset'
]))
AlignType = enum_speedup(
jsonable.JsonableEnum('AlignType', 'Sequence Structure', start=0))
SeqAlnMode = enum_speedup(
jsonable.JsonableEnum('SeqAlnMode', [
'Multiple', 'Pairwise', 'PairwiseSS', 'Structure', 'Residue', 'Profile'
]))
StructAlnMode = enum_speedup(
jsonable.JsonableEnum('StructAlnMode',
['Superimpose', 'Structure', 'BindingSite']))
MultAlnAlgorithm = enum_speedup(
jsonable.JsonableEnum('MultAlnAlgorithm', ['Clustal', 'Muscle']))
StructAlnSequenceRepresents = enum_speedup(
jsonable.JsonableEnum('StructAlnSequenceRepresents',
['SingleChain', 'EntireEntry'],
start=0))
StructAlnTransform = enum_speedup(
jsonable.JsonableEnum('StructAlnTransform', ['Existing', 'Individual'],
start=0))
StructAlnRefASLMode = enum_speedup(
jsonable.JsonableEnum('StructAlnRefASLMode', ['All', 'Selected', 'ASL'],
start=0))
Direction = enum_speedup(Enum("Direction", ["Top", "Up", "Down", "Bottom"]))
SortTypes = enum_speedup(
Enum("SortTypes", [
'Name', 'ChainID', 'NumGaps', 'Length', 'Identity', 'Similarity',
'Conservation', 'Score'
]))
# Adjacent isn't used during painting, so there's no need to speed it up
Adjacent = Enum("Adjacent", ["Up", "Down", "Left", "Right"])
ResSelectionBlockStart = enum_speedup(
Enum("ResSelectionBlockStart", ("Before", "After")))
# Whether a sequence is currently included in the workspace and whether it's
# visible. Only applies to sequences with associated structures.
Inclusion = enum_speedup(
Enum("Inclusion",
("Excluded", "NotVisible", "PartiallyVisible", "FullyVisible")))
included_map = {
Inclusion.Excluded: False,
Inclusion.NotVisible: True,
Inclusion.PartiallyVisible: True,
Inclusion.FullyVisible: True
}
Autosave = jsonable.JsonableEnum("Autosave",
["Regularly", "OnlyAfterEdit", "Never"])