Handling Gaps¶
This chapter describes the gap classes and functionality attached to them. These classes / functions are used within the modelling pipeline.
Gap classes¶
- class promod3.modelling.StructuralGap(before, after, seq)¶
Describes a structural gap, i.e. a loop to be modeled. The gap may either be terminal or between two defined regions. The gap stores information of the last residue before and the first residue after the gap as well as the sequence of gap. Gaps at the N- and C-terminals can be defined by passing invalid residue handles to before or after.
- Parameters:
before (
ost.mol.ResidueHandle
) – Fillsbefore
after (
ost.mol.ResidueHandle
) – Fillsafter
- Raises:
A
RuntimeError
if both residues are invalid or when both are valid and:residues are from different chains (if both valid)
before is located after after
seq has a length which is inconsistent with the gap
- GetChain()¶
- Returns:
Chain, the gap is belonging to
- Return type:
- IsNTerminal()¶
- IsCTerminal()¶
- ShiftCTerminal()¶
Try to shift gap by one position towards C-terminal. Only possible if new gap is not terminal and it doesn’t try to shift the gap past another gap.
- Returns:
True, iff shift succeeded (gap is only updated in that case)
- Return type:
- ExtendAtNTerm()¶
Try to extend gap at N-terminal end of gap. Only possible if the gap is not at N-terminal and it doesn’t try to extend the gap past another gap.
- Returns:
True, iff extend succeeded (gap is only updated in that case)
- Return type:
- ExtendAtCTerm()¶
Try to extend gap at C-terminal end of gap. Only possible if the gap is not at C-terminal and it doesn’t try to extend the gap past another gap.
- Returns:
True, iff extend succeeded (gap is only updated in that case)
- Return type:
- Copy()¶
- Returns:
Copy of the gap.
- Return type:
- length¶
Alias for
GetLength()
(read-only,int
)
- before¶
Residue before the gap (read-only,
ost.mol.ResidueHandle
)
- after¶
Residue after the gap (read-only,
ost.mol.ResidueHandle
)
- full_seq¶
Full sequence, including stem residues (read-only)
- class promod3.modelling.StructuralGapList¶
Represents a
list
ofStructuralGap
.
Gap Extender classes¶
The extender classes work on a given StructuralGap
and provide an
Extend() function to propose new gaps for loop modelling. The function returns
False if no new extension possible.
- class promod3.modelling.GapExtender(gap, seqres)¶
The extender cycles through the following steps:
- -- -- --- --- --- ---- ---- ---- ----
- Parameters:
gap (
StructuralGap
) – The gap which will be extended byExtend()
.seqres (
str
/ost.seq.SequenceHandle
) – The full sequence of the chain, the gap is associated with.
- Raises:
An exception if a terminal gap is used to construct this.
- Extend()¶
Tries to extend gap.
- Returns:
False, if the gap cannot be extended any further. This happens if it reaches a terminal or another insertion gap. Otherwise, the gap passed to the constructor is changed. The gaps are extended with ascending length and will always have valid termini.
- Return type:
- class promod3.modelling.FullGapExtender(gap, seqres, max_length=-1)¶
Cycles as GapExtender, but continues even if another gap was encountered.
- Parameters:
gap (
StructuralGap
) – The gap which will be extended byExtend()
.seqres (
str
/ost.seq.SequenceHandle
) – The full sequence of the chain, the gap is associated with.max_length (
int
) –If -1, all possible non-terminal gaps are returned.
If >= 0, this restricts the max. gap-length (w/o termini) producable by
Extend()
.
- Raises:
An exception if a terminal gap is used to construct this.
- class promod3.modelling.ScoringGapExtender(gap, extension_penalty, penalties, seqres, max_length=-2)¶
The extender scores possible gap extensions and returns them in order of their score when
Extend()
is called. The score is penalized according to length and according to certain (well conserved) regions in the structure as defined by penalties. score = num_gap_extensions * extension_penalty + sum( penalties [i] ) (i = resnum - 1 of residues in extension)- Parameters:
gap (
StructuralGap
) – The gap which will be extended byExtend()
.extension_penalty (
float
) – Penalty for length of gap.penalties (
list
offloat
) – Penalty for each residue added to gap.seqres (
str
/ost.seq.SequenceHandle
) – The full sequence of the chain, the gap is associated with.max_length (
int
) –If -2,
GapExtender
is used instead ofFullGapExtender
(i.e. it stops at gaps and termini).If -1, all possible non-terminal gaps are returned.
If >= 0, this restricts the max. gap-length (w/o termini) producable by
Extend()
.
- Raises:
An exception if a terminal gap is used to construct this.
- class promod3.modelling.ShiftExtension(n_num, c_num)¶
Implements the underlying extension scheme of the
GapExtender
. It is not associated to any structural data, it just spits out the residue numbers according to the extension scheme described above.- Parameters:
Gap Handling Functions¶
- promod3.modelling.CountEnclosedGaps(mhandle, gap)¶
- promod3.modelling.CountEnclosedInsertions(mhandle, gap)¶
Counts all gaps from mhandle which are fully enclosed by given gap. This is either all gaps or only insertions.
- Parameters:
mhandle (
ModellingHandle
) – Modelling handle on which to apply change.gap (
StructuralGap
) – Gap defining range in which gaps are to be removed.
- Returns:
Number of gaps.
- Return type:
- promod3.modelling.ClearGaps(mhandle, gap)¶
Removes all gaps from mhandle which are fully enclosed by given gap.
- Parameters:
mhandle (
ModellingHandle
) – Modelling handle on which to apply change.gap (
StructuralGap
) – Gap defining range in which gaps are to be removed.
- Returns:
Index of next gap in mhandle.gaps after removal. Returns -1 if last gap was removed or no gaps in mhandle.
- Return type:
- Raises:
A
RuntimeError
if any gap in mhandle.gaps is only partially enclosed by given gap.
- promod3.modelling.InsertLoopClearGaps(mhandle, bb_list, gap)¶
Insert loop into model, update scoring environments and remove all gaps from mhandle which are fully enclosed by given gap (see
InsertLoop()
andClearGaps()
).- Parameters:
mhandle (
ModellingHandle
) – Modelling handle on which to apply change.bb_list (
BackboneList
) – Loop to insert (backbone only).gap (
StructuralGap
) – Gap defining range of loop to insert (must be consistent!).
- Returns:
Index of next gap in mhandle.gaps after removal. Returns -1 if last gap was removed or no gaps in mhandle.
- Return type:
- Raises:
A
RuntimeError
if bb_list and gap are inconsistent or if any gap in mhandle.gaps is only partially enclosed by gap.
- promod3.modelling.MergeGaps(mhandle, index)¶
Merges two gaps mhandle.gaps[index] and mhandle.gaps[index+1]. The residues in between the gaps are removed from mhandle.model and added to the new mhandle.gaps[index].
- Parameters:
mhandle (
ModellingHandle
) – Modelling handle on which to apply change.index (
int
) – Index of gap to merge with next one.
- Raises:
A
RuntimeError
if indices out of range or if trying to merge gaps of different chains or an N-terminal gap with a C-terminal gap.