Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/apidoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,13 @@
"biotite.structure.alphabet" : {
"Structural alphabets": [
"I3DSequence",
"ProteinBlocksSequence"
"ProteinBlocksSequence",
"ClepapsSequence"
],
"Conversion Function": [
"to_3di",
"to_protein_blocks"
"to_protein_blocks",
"to_clepaps"
]
}
}
3 changes: 2 additions & 1 deletion doc/examples/scripts/structure/modeling/docking.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
# of the original ligand position
app = autodock.VinaApp(ligand, receptor, ref_ligand_center, [20, 20, 20])
# For reproducibility
app.set_seed(0)
# (Vina interprets seed 0 as a request for a random seed, so use a non-zero one)
app.set_seed(42)
app.set_cpu(1)
# This is the maximum number:
# Vina may find less interesting binding modes
Expand Down
15 changes: 15 additions & 0 deletions doc/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,21 @@ @article{Varadi2024
doi = {10.1093/nar/gkad1011}
}

@article{Wang2008,
title = {{{CLePAPS}}: {{FAST PAIR ALIGNMENT OF PROTEIN STRUCTURES BASED ON CONFORMATIONAL LETTERS}}},
shorttitle = {{{CLePAPS}}},
author = {Wang, Sheng and Zheng, Wei-Mou},
year = {2008},
month = apr,
journal = {Journal of Bioinformatics and Computational Biology},
volume = {06},
number = {02},
pages = {347--366},
publisher = {World Scientific Publishing Co.},
issn = {0219-7200},
doi = {10.1142/S0219720008003461}
}

@article{Westbrook2015,
title = {The Chemical Component Dictionary: Complete Descriptions of Constituent Molecules in Experimentally Determined {{3D}} Macromolecules in the {{Protein Data Bank}}},
shorttitle = {The Chemical Component Dictionary},
Expand Down
23 changes: 9 additions & 14 deletions src/biotite/application/sra/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from os.path import join
from subprocess import PIPE, Popen, SubprocessError, TimeoutExpired
from tempfile import TemporaryDirectory
from typing import Literal, TypeAlias
import numpy as np
from biotite.application.application import (
Application,
Expand All @@ -28,10 +27,6 @@
from biotite.sequence.io.fastq.file import FastqFile
from biotite.sequence.seqtypes import NucleotideSequence

_OffsetFormat: TypeAlias = Literal[
"Sanger", "Solexa", "Illumina-1.3", "Illumina-1.5", "Illumina-1.8"
]


# Do not use LocalApp, as two programs are executed
class _DumpApp(Application, metaclass=abc.ABCMeta):
Expand Down Expand Up @@ -237,11 +232,11 @@ class FastqDumpApp(_DumpApp):
prefetch_path, fasterq_dump_path : str, optional
Path to the ``prefetch_path`` and ``fasterq-dump`` binary,
respectively.
offset : int or {'Sanger', 'Solexa', 'Illumina-1.3', 'Illumina-1.5', 'Illumina-1.8'}, optional
offset : int or FastqFile.Offset, optional
This value is subtracted from the FASTQ ASCII code to obtain the
quality score.
Can either be directly the value, or a string that indicates
the score format.
Can be provided directly as integer or as a member of
:class:`FastqFile.Offset`.
"""

def __init__(
Expand All @@ -250,10 +245,10 @@ def __init__(
output_path_prefix: PathLike[str] | str | None = None,
prefetch_path: PathLike[str] | str = "prefetch",
fasterq_dump_path: PathLike[str] | str = "fasterq-dump",
offset: int | _OffsetFormat = "Sanger",
offset: int | FastqFile.Offset = FastqFile.Offset.SANGER,
) -> None:
super().__init__(uid, output_path_prefix, prefetch_path, fasterq_dump_path)
self._offset: int | _OffsetFormat = offset
self._offset: int | FastqFile.Offset = offset
self._fastq_files: list[FastqFile] | None = None

@requires_state(AppState.JOINED)
Expand Down Expand Up @@ -312,7 +307,7 @@ def fetch(
output_path_prefix: PathLike[str] | str | None = None,
prefetch_path: PathLike[str] | str = "prefetch",
fasterq_dump_path: PathLike[str] | str = "fasterq-dump",
offset: int | _OffsetFormat = "Sanger",
offset: int | FastqFile.Offset = FastqFile.Offset.SANGER,
) -> list[dict[str, NucleotideSequence]]:
"""
Get the sequences belonging to the UID from the
Expand All @@ -333,11 +328,11 @@ def fetch(
prefetch_path, fasterq_dump_path : str, optional
Path to the ``prefetch_path`` and ``fasterq-dump`` binary,
respectively.
offset : int or {'Sanger', 'Solexa', 'Illumina-1.3', 'Illumina-1.5', 'Illumina-1.8'}, optional
offset : int or FastqFile.Offset, optional
This value is subtracted from the FASTQ ASCII code to obtain the
quality score.
Can either be directly the value, or a string that indicates
the score format.
Can be provided directly as integer or as a member of
:class:`FastqFile.Offset`.

Returns
-------
Expand Down
8 changes: 5 additions & 3 deletions src/biotite/database/entrez/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
# information.

from __future__ import annotations

__name__ = "biotite.database.entrez"
__author__ = "Patrick Kunzmann"
__all__ = ["Query", "SimpleQuery", "CompositeQuery", "search"]
Expand Down Expand Up @@ -31,17 +33,17 @@ def __init__(self) -> None:
def __str__(self) -> str:
pass

def __or__(self, operand: "Query | str") -> "CompositeQuery":
def __or__(self, operand: Query | str) -> CompositeQuery:
if not isinstance(operand, Query):
operand = SimpleQuery(operand)
return CompositeQuery("OR", self, operand)

def __and__(self, operand: "Query | str") -> "CompositeQuery":
def __and__(self, operand: Query | str) -> CompositeQuery:
if not isinstance(operand, Query):
operand = SimpleQuery(operand)
return CompositeQuery("AND", self, operand)

def __xor__(self, operand: "Query | str") -> "CompositeQuery":
def __xor__(self, operand: Query | str) -> CompositeQuery:
if not isinstance(operand, Query):
operand = SimpleQuery(operand)
return CompositeQuery("NOT", self, operand)
Expand Down
6 changes: 4 additions & 2 deletions src/biotite/database/pubchem/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
# information.

from __future__ import annotations

__name__ = "biotite.database.pubchem"
__author__ = "Patrick Kunzmann"
__all__ = [
Expand Down Expand Up @@ -236,7 +238,7 @@ def from_atoms(
atoms: AtomArray[N],
allow_other_elements: bool = False,
number: int | None = None,
) -> "FormulaQuery":
) -> FormulaQuery:
"""
Create the query from an the given structure by using its
molecular formula.
Expand Down Expand Up @@ -385,7 +387,7 @@ def from_atoms(
atoms: AtomArray[N],
*args: Any,
**kwargs: Any,
) -> "StructureQuery":
) -> StructureQuery:
"""
Create a query using the given query structure.

Expand Down
4 changes: 3 additions & 1 deletion src/biotite/database/pubchem/throttle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
# information.

from __future__ import annotations

__name__ = "biotite.database.pubchem"
__author__ = "Patrick Kunzmann"
__all__ = ["ThrottleStatus"]
Expand Down Expand Up @@ -52,7 +54,7 @@ class ThrottleStatus:
service: float

@staticmethod
def from_response(response: requests.Response) -> "ThrottleStatus":
def from_response(response: requests.Response) -> ThrottleStatus:
"""
Extract the throttle status from a *Pubchem* server response.

Expand Down
10 changes: 6 additions & 4 deletions src/biotite/database/rcsb/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
# information.

from __future__ import annotations

__name__ = "biotite.database.rcsb"
__author__ = "Patrick Kunzmann, Maximilian Dombrowsky"
__all__ = [
Expand Down Expand Up @@ -71,10 +73,10 @@ def get_content(self) -> dict[str, Any]:
"""
pass

def __and__(self, query: "Query") -> "CompositeQuery":
def __and__(self, query: Query) -> CompositeQuery:
return CompositeQuery([self, query], "and")

def __or__(self, query: "Query") -> "CompositeQuery":
def __or__(self, query: Query) -> CompositeQuery:
return CompositeQuery([self, query], "or")


Expand Down Expand Up @@ -433,7 +435,7 @@ def get_content(self) -> dict[str, Any]:
content["parameters"]["value"] = self._value
return content

def __invert__(self) -> "FieldQuery":
def __invert__(self) -> FieldQuery:
clone = copy.deepcopy(self)
clone._negation = not clone._negation
return clone
Expand Down Expand Up @@ -831,7 +833,7 @@ def is_compatible_return_type(self, return_type: str) -> bool:
def count(
query: Query,
return_type: _ReturnType = "entry",
group_by: "Grouping | None" = None,
group_by: Grouping | None = None,
content_types: Iterable[_ContentType] = ("experimental",),
) -> int:
"""
Expand Down
8 changes: 5 additions & 3 deletions src/biotite/database/uniprot/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
# information.

from __future__ import annotations

__name__ = "biotite.database.uniprot"
__author__ = "Maximilian Greil"
__all__ = ["Query", "SimpleQuery", "CompositeQuery", "search"]
Expand All @@ -27,13 +29,13 @@ def __init__(self) -> None:
def __str__(self) -> str:
pass

def __or__(self, operand: "Query") -> "CompositeQuery":
def __or__(self, operand: Query) -> CompositeQuery:
return CompositeQuery("OR", self, operand)

def __and__(self, operand: "Query") -> "CompositeQuery":
def __and__(self, operand: Query) -> CompositeQuery:
return CompositeQuery("AND", self, operand)

def __xor__(self, operand: "Query") -> "CompositeQuery":
def __xor__(self, operand: Query) -> CompositeQuery:
return CompositeQuery("NOT", self, operand)


Expand Down
45 changes: 45 additions & 0 deletions src/biotite/sequence/align/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class SubstitutionMatrix(Generic[S1, S2]):

- **3Di** - For 3Di alphabet from ``foldseek`` :footcite:`VanKempen2024`
- **PB** - For Protein Blocks alphabet from *PBexplore* :footcite:`Barnoud2017`
- **CLESUM** - For CLePAPS alphabet :footcite:`Wang2008`

A list of all available matrix names is returned by
:meth:`list_db()`.
Expand Down Expand Up @@ -630,6 +631,50 @@ def std_protein_blocks_matrix(
matrix_dict,
)

@staticmethod
@functools.cache
def std_clepaps_matrix(
unknown_match: int = 200, unknown_mismatch: int = -200
) -> SubstitutionMatrix[str, str]:
"""
Get the *CLESUM* substitution matrix for *CLePAPS* sequence.
:footcite:`Wang2008`

Parameters
----------
unknown_match, unknown_mismatch : int, optional
The match and mismatch score for the unknown symbol.
The default values were chosen arbitrarily, but are in the order of
magnitude of the other score values.

Returns
-------
matrix : SubstitutionMatrix
Default matrix.

References
----------

.. footbibliography::
"""
from biotite.structure.alphabet.clepaps import ClepapsSequence

alphabet = ClepapsSequence.alphabet
unknown_symbol = ClepapsSequence.unknown_symbol
matrix_dict = SubstitutionMatrix.dict_from_db("CLESUM")
# Add match/mismatch scores for the unknown symbol
for symbol in alphabet:
if symbol == unknown_symbol:
continue
matrix_dict[symbol, unknown_symbol] = unknown_mismatch
matrix_dict[unknown_symbol, symbol] = unknown_mismatch
matrix_dict[unknown_symbol, unknown_symbol] = unknown_match
return SubstitutionMatrix(
alphabet,
alphabet,
matrix_dict,
)

def _fill_with_matrix_dict(self, matrix_dict: dict[tuple[Any, Any], int]) -> None:
self._matrix = np.zeros((len(self._alph1), len(self._alph2)), dtype=np.int32)
for i in range(len(self._alph1)):
Expand Down
19 changes: 19 additions & 0 deletions src/biotite/sequence/align/matrix_data/CLESUM.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# CLESUM: The conformation letter substitution matrix from the CLePAPS paper
A B C D E F G H I J K L M N O P Q
A 73 20 13 -17 -25 -20 -6 -45 -31 -23 -19 -11 -2 10 25 35 16
B 20 51 7 13 15 7 13 -96 -74 -57 -50 -12 -13 -11 -12 42 12
C 13 7 53 21 3 20 -4 -77 -56 -43 -33 0 -12 -5 3 4 29
D -17 13 21 52 22 21 -31 -124 -105 -88 -81 -22 -49 -44 -42 -10 14
E -25 15 3 22 36 26 -22 -127 -108 -93 -84 -21 -47 -43 -48 -5 -6
F -20 7 20 21 26 50 -5 -107 -88 -73 -69 -16 -33 -32 -30 0 3
G -6 13 -4 -31 -22 -5 69 -51 -34 -21 -13 29 21 -8 -1 5 8
H -45 -96 -77 -124 -127 -107 -51 23 18 13 5 -62 -4 -34 -55 -60 -87
I -31 -74 -56 -105 -108 -88 -34 18 23 16 21 -41 1 -11 -34 -49 -62
J -23 -57 -43 -88 -93 -73 -21 13 16 37 13 -32 16 -2 -24 -34 -44
K -19 -50 -33 -81 -84 -69 -13 5 21 13 49 -1 12 28 5 -36 -24
L -11 -12 0 -22 -21 -16 29 -62 -41 -32 -1 74 5 8 -4 -12 26
M -2 -13 -12 -49 -47 -33 21 -4 1 16 12 5 61 7 5 8 -7
N 10 -11 -5 -44 -43 -32 -8 -34 -11 -2 28 8 7 90 15 -3 32
O 25 -12 3 -42 -48 -30 -1 -55 -34 -24 5 -4 5 15 104 4 -13
P 35 42 4 -10 -5 0 5 -60 -49 -34 -36 -12 8 -3 4 66 7
Q 16 12 29 14 -6 3 8 -87 -62 -44 -24 26 -7 32 -13 7 90
4 changes: 2 additions & 2 deletions src/biotite/sequence/align/multiple.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ def _get_distance_matrix(CodeType[:] _T, sequences, matrix,
for code1 in range(alphabet_size):
for code2 in range(alphabet_size):
score_rand += score_matrix[code1,code2] \
* code_count[i,code1] \
* code_count[j,code2]
* code_count_v[i,code1] \
* code_count_v[j,code2]
score_rand /= alignments[i,j].trace.shape[0]
gap_open_count, gap_ext_count = _count_gaps(
alignments[i,j].trace.astype(np.int64, copy=False),
Expand Down
2 changes: 1 addition & 1 deletion src/biotite/sequence/graphics/plasmid.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def __init__(
else:
self._arrow_head = None

self._label: "CurvedText | None"
self._label: CurvedText | None
if label is not None:
label_properties["color"] = label_color
self._label = CurvedText(
Expand Down
Loading
Loading