biotite 0.41.2__cp311-cp311-macosx_11_0_arm64.whl → 1.0.0__cp311-cp311-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of biotite might be problematic. Click here for more details.
- biotite/__init__.py +2 -3
- biotite/application/__init__.py +1 -1
- biotite/application/application.py +20 -10
- biotite/application/autodock/__init__.py +1 -1
- biotite/application/autodock/app.py +74 -79
- biotite/application/blast/__init__.py +1 -1
- biotite/application/blast/alignment.py +19 -10
- biotite/application/blast/webapp.py +92 -85
- biotite/application/clustalo/__init__.py +1 -1
- biotite/application/clustalo/app.py +46 -61
- biotite/application/dssp/__init__.py +1 -1
- biotite/application/dssp/app.py +8 -11
- biotite/application/localapp.py +62 -60
- biotite/application/mafft/__init__.py +1 -1
- biotite/application/mafft/app.py +16 -22
- biotite/application/msaapp.py +78 -89
- biotite/application/muscle/__init__.py +1 -1
- biotite/application/muscle/app3.py +50 -64
- biotite/application/muscle/app5.py +23 -31
- biotite/application/sra/__init__.py +1 -1
- biotite/application/sra/app.py +64 -68
- biotite/application/tantan/__init__.py +1 -1
- biotite/application/tantan/app.py +22 -45
- biotite/application/util.py +7 -9
- biotite/application/viennarna/rnaalifold.py +34 -28
- biotite/application/viennarna/rnafold.py +24 -39
- biotite/application/viennarna/rnaplot.py +36 -21
- biotite/application/viennarna/util.py +17 -12
- biotite/application/webapp.py +13 -14
- biotite/copyable.py +13 -13
- biotite/database/__init__.py +1 -1
- biotite/database/entrez/__init__.py +1 -1
- biotite/database/entrez/check.py +2 -3
- biotite/database/entrez/dbnames.py +7 -5
- biotite/database/entrez/download.py +55 -49
- biotite/database/entrez/key.py +1 -1
- biotite/database/entrez/query.py +62 -23
- biotite/database/error.py +2 -1
- biotite/database/pubchem/__init__.py +1 -1
- biotite/database/pubchem/download.py +43 -45
- biotite/database/pubchem/error.py +2 -2
- biotite/database/pubchem/query.py +34 -31
- biotite/database/pubchem/throttle.py +3 -4
- biotite/database/rcsb/__init__.py +1 -1
- biotite/database/rcsb/download.py +44 -52
- biotite/database/rcsb/query.py +85 -80
- biotite/database/uniprot/check.py +6 -3
- biotite/database/uniprot/download.py +6 -11
- biotite/database/uniprot/query.py +115 -31
- biotite/file.py +12 -31
- biotite/sequence/__init__.py +3 -3
- biotite/sequence/align/__init__.py +2 -2
- biotite/sequence/align/alignment.py +99 -90
- biotite/sequence/align/banded.cpython-311-darwin.so +0 -0
- biotite/sequence/align/buckets.py +12 -10
- biotite/sequence/align/cigar.py +43 -52
- biotite/sequence/align/kmeralphabet.cpython-311-darwin.so +0 -0
- biotite/sequence/align/kmeralphabet.pyx +55 -51
- biotite/sequence/align/kmersimilarity.cpython-311-darwin.so +0 -0
- biotite/sequence/align/kmertable.cpython-311-darwin.so +0 -0
- biotite/sequence/align/kmertable.pyx +3 -2
- biotite/sequence/align/localgapped.cpython-311-darwin.so +0 -0
- biotite/sequence/align/localungapped.cpython-311-darwin.so +0 -0
- biotite/sequence/align/matrix.py +81 -82
- biotite/sequence/align/multiple.cpython-311-darwin.so +0 -0
- biotite/sequence/align/multiple.pyx +1 -1
- biotite/sequence/align/pairwise.cpython-311-darwin.so +0 -0
- biotite/sequence/align/permutation.cpython-311-darwin.so +0 -0
- biotite/sequence/align/permutation.pyx +12 -4
- biotite/sequence/align/selector.cpython-311-darwin.so +0 -0
- biotite/sequence/align/selector.pyx +52 -54
- biotite/sequence/align/statistics.py +32 -33
- biotite/sequence/align/tracetable.cpython-311-darwin.so +0 -0
- biotite/sequence/alphabet.py +51 -65
- biotite/sequence/annotation.py +78 -77
- biotite/sequence/codec.cpython-311-darwin.so +0 -0
- biotite/sequence/codon.py +90 -79
- biotite/sequence/graphics/__init__.py +1 -1
- biotite/sequence/graphics/alignment.py +184 -103
- biotite/sequence/graphics/colorschemes.py +10 -12
- biotite/sequence/graphics/dendrogram.py +79 -34
- biotite/sequence/graphics/features.py +133 -99
- biotite/sequence/graphics/logo.py +22 -28
- biotite/sequence/graphics/plasmid.py +229 -178
- biotite/sequence/io/fasta/__init__.py +1 -1
- biotite/sequence/io/fasta/convert.py +44 -33
- biotite/sequence/io/fasta/file.py +42 -55
- biotite/sequence/io/fastq/__init__.py +1 -1
- biotite/sequence/io/fastq/convert.py +11 -14
- biotite/sequence/io/fastq/file.py +68 -112
- biotite/sequence/io/genbank/__init__.py +2 -2
- biotite/sequence/io/genbank/annotation.py +12 -20
- biotite/sequence/io/genbank/file.py +74 -76
- biotite/sequence/io/genbank/metadata.py +74 -62
- biotite/sequence/io/genbank/sequence.py +13 -14
- biotite/sequence/io/general.py +39 -30
- biotite/sequence/io/gff/__init__.py +2 -2
- biotite/sequence/io/gff/convert.py +10 -15
- biotite/sequence/io/gff/file.py +81 -65
- biotite/sequence/phylo/__init__.py +1 -1
- biotite/sequence/phylo/nj.cpython-311-darwin.so +0 -0
- biotite/sequence/phylo/tree.cpython-311-darwin.so +0 -0
- biotite/sequence/phylo/upgma.cpython-311-darwin.so +0 -0
- biotite/sequence/profile.py +57 -28
- biotite/sequence/search.py +17 -15
- biotite/sequence/seqtypes.py +200 -164
- biotite/sequence/sequence.py +15 -17
- biotite/structure/__init__.py +3 -3
- biotite/structure/atoms.py +221 -235
- biotite/structure/basepairs.py +260 -271
- biotite/structure/bonds.cpython-311-darwin.so +0 -0
- biotite/structure/bonds.pyx +29 -32
- biotite/structure/box.py +67 -71
- biotite/structure/celllist.cpython-311-darwin.so +0 -0
- biotite/structure/chains.py +55 -39
- biotite/structure/charges.cpython-311-darwin.so +0 -0
- biotite/structure/compare.py +32 -32
- biotite/structure/density.py +13 -18
- biotite/structure/dotbracket.py +20 -22
- biotite/structure/error.py +10 -2
- biotite/structure/filter.py +82 -77
- biotite/structure/geometry.py +130 -119
- biotite/structure/graphics/atoms.py +60 -43
- biotite/structure/graphics/rna.py +81 -68
- biotite/structure/hbond.py +112 -93
- biotite/structure/info/__init__.py +0 -2
- biotite/structure/info/atoms.py +10 -11
- biotite/structure/info/bonds.py +41 -43
- biotite/structure/info/ccd.py +4 -5
- biotite/structure/info/groups.py +1 -3
- biotite/structure/info/masses.py +5 -10
- biotite/structure/info/misc.py +1 -1
- biotite/structure/info/radii.py +20 -20
- biotite/structure/info/standardize.py +15 -26
- biotite/structure/integrity.py +18 -71
- biotite/structure/io/__init__.py +3 -4
- biotite/structure/io/dcd/__init__.py +1 -1
- biotite/structure/io/dcd/file.py +22 -20
- biotite/structure/io/general.py +47 -61
- biotite/structure/io/gro/__init__.py +1 -1
- biotite/structure/io/gro/file.py +73 -72
- biotite/structure/io/mol/__init__.py +1 -1
- biotite/structure/io/mol/convert.py +8 -11
- biotite/structure/io/mol/ctab.py +37 -36
- biotite/structure/io/mol/header.py +14 -10
- biotite/structure/io/mol/mol.py +9 -53
- biotite/structure/io/mol/sdf.py +47 -50
- biotite/structure/io/netcdf/__init__.py +1 -1
- biotite/structure/io/netcdf/file.py +24 -23
- biotite/structure/io/pdb/__init__.py +1 -1
- biotite/structure/io/pdb/convert.py +32 -20
- biotite/structure/io/pdb/file.py +151 -172
- biotite/structure/io/pdb/hybrid36.cpython-311-darwin.so +0 -0
- biotite/structure/io/pdbqt/__init__.py +1 -1
- biotite/structure/io/pdbqt/convert.py +17 -11
- biotite/structure/io/pdbqt/file.py +128 -80
- biotite/structure/io/pdbx/__init__.py +1 -2
- biotite/structure/io/pdbx/bcif.py +36 -44
- biotite/structure/io/pdbx/cif.py +64 -62
- biotite/structure/io/pdbx/component.py +10 -16
- biotite/structure/io/pdbx/convert.py +235 -246
- biotite/structure/io/pdbx/encoding.cpython-311-darwin.so +0 -0
- biotite/structure/io/trajfile.py +76 -93
- biotite/structure/io/trr/__init__.py +1 -1
- biotite/structure/io/trr/file.py +12 -15
- biotite/structure/io/xtc/__init__.py +1 -1
- biotite/structure/io/xtc/file.py +11 -14
- biotite/structure/mechanics.py +9 -11
- biotite/structure/molecules.py +3 -4
- biotite/structure/pseudoknots.py +53 -67
- biotite/structure/rdf.py +23 -21
- biotite/structure/repair.py +137 -86
- biotite/structure/residues.py +26 -16
- biotite/structure/sasa.cpython-311-darwin.so +0 -0
- biotite/structure/{resutil.py → segments.py} +24 -23
- biotite/structure/sequence.py +10 -11
- biotite/structure/sse.py +100 -119
- biotite/structure/superimpose.py +39 -77
- biotite/structure/transform.py +97 -71
- biotite/structure/util.py +11 -13
- biotite/version.py +2 -2
- biotite/visualize.py +69 -55
- {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/METADATA +5 -5
- biotite-1.0.0.dist-info/RECORD +322 -0
- biotite/structure/io/ctab.py +0 -72
- biotite/structure/io/mmtf/__init__.py +0 -21
- biotite/structure/io/mmtf/assembly.py +0 -214
- biotite/structure/io/mmtf/convertarray.cpython-311-darwin.so +0 -0
- biotite/structure/io/mmtf/convertarray.pyx +0 -341
- biotite/structure/io/mmtf/convertfile.cpython-311-darwin.so +0 -0
- biotite/structure/io/mmtf/convertfile.pyx +0 -501
- biotite/structure/io/mmtf/decode.cpython-311-darwin.so +0 -0
- biotite/structure/io/mmtf/decode.pyx +0 -152
- biotite/structure/io/mmtf/encode.cpython-311-darwin.so +0 -0
- biotite/structure/io/mmtf/encode.pyx +0 -183
- biotite/structure/io/mmtf/file.py +0 -233
- biotite/structure/io/npz/__init__.py +0 -20
- biotite/structure/io/npz/file.py +0 -152
- biotite/structure/io/pdbx/legacy.py +0 -267
- biotite/structure/io/tng/__init__.py +0 -13
- biotite/structure/io/tng/file.py +0 -46
- biotite/temp.py +0 -86
- biotite-0.41.2.dist-info/RECORD +0 -340
- {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/WHEEL +0 -0
- {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/licenses/LICENSE.rst +0 -0
|
@@ -4,15 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
__name__ = "biotite.sequence.graphics"
|
|
6
6
|
__author__ = "Patrick Kunzmann"
|
|
7
|
-
__all__ = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
__all__ = [
|
|
8
|
+
"SymbolPlotter",
|
|
9
|
+
"LetterPlotter",
|
|
10
|
+
"LetterSimilarityPlotter",
|
|
11
|
+
"LetterTypePlotter",
|
|
12
|
+
"ArrayPlotter",
|
|
13
|
+
"plot_alignment",
|
|
14
|
+
"plot_alignment_similarity_based",
|
|
15
|
+
"plot_alignment_type_based",
|
|
16
|
+
"plot_alignment_array",
|
|
17
|
+
]
|
|
11
18
|
|
|
12
19
|
import abc
|
|
13
20
|
import numpy as np
|
|
14
|
-
from
|
|
15
|
-
from .
|
|
21
|
+
from biotite.sequence.graphics.colorschemes import get_color_scheme
|
|
22
|
+
from biotite.visualize import colors
|
|
16
23
|
|
|
17
24
|
|
|
18
25
|
class SymbolPlotter(metaclass=abc.ABCMeta):
|
|
@@ -81,8 +88,7 @@ class LetterPlotter(SymbolPlotter, metaclass=abc.ABCMeta):
|
|
|
81
88
|
:class:`matplotlib.Text` instance of each symbol.
|
|
82
89
|
"""
|
|
83
90
|
|
|
84
|
-
def __init__(self, axes, color_symbols=False,
|
|
85
|
-
font_size=None, font_param=None):
|
|
91
|
+
def __init__(self, axes, color_symbols=False, font_size=None, font_param=None):
|
|
86
92
|
super().__init__(axes)
|
|
87
93
|
self._color_symbols = color_symbols
|
|
88
94
|
self._font_size = font_size
|
|
@@ -101,9 +107,15 @@ class LetterPlotter(SymbolPlotter, metaclass=abc.ABCMeta):
|
|
|
101
107
|
box = Rectangle(bbox.p0, bbox.width, bbox.height)
|
|
102
108
|
self.axes.add_patch(box)
|
|
103
109
|
text = self.axes.text(
|
|
104
|
-
bbox.x0 + bbox.width/
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
bbox.x0 + bbox.width / 2,
|
|
111
|
+
bbox.y0 + bbox.height / 2,
|
|
112
|
+
symbol,
|
|
113
|
+
color="black",
|
|
114
|
+
ha="center",
|
|
115
|
+
va="center",
|
|
116
|
+
size=self._font_size,
|
|
117
|
+
**self._font_param,
|
|
118
|
+
)
|
|
107
119
|
text.set_clip_on(True)
|
|
108
120
|
|
|
109
121
|
if self._color_symbols:
|
|
@@ -196,17 +208,16 @@ class LetterSimilarityPlotter(LetterPlotter):
|
|
|
196
208
|
because *a* does also occur in *b*\ :sub:`i`.
|
|
197
209
|
"""
|
|
198
210
|
|
|
199
|
-
def __init__(
|
|
200
|
-
|
|
201
|
-
|
|
211
|
+
def __init__(
|
|
212
|
+
self, axes, matrix=None, color_symbols=False, font_size=None, font_param=None
|
|
213
|
+
):
|
|
202
214
|
super().__init__(axes, color_symbols, font_size, font_param)
|
|
203
215
|
if matrix is not None:
|
|
204
216
|
self._matrix = matrix.score_matrix()
|
|
205
217
|
else:
|
|
206
218
|
self._matrix = None
|
|
207
219
|
# Default colormap
|
|
208
|
-
self._cmap = self._generate_colormap(colors["dimgreen"],
|
|
209
|
-
self._color_symbols)
|
|
220
|
+
self._cmap = self._generate_colormap(colors["dimgreen"], self._color_symbols)
|
|
210
221
|
|
|
211
222
|
def set_color(self, color=None, cmap=None):
|
|
212
223
|
"""
|
|
@@ -257,8 +268,7 @@ class LetterSimilarityPlotter(LetterPlotter):
|
|
|
257
268
|
similarities[i] = 0
|
|
258
269
|
else:
|
|
259
270
|
code2 = alignment.sequences[i].code[index2]
|
|
260
|
-
similarities[i] = self._get_similarity(self._matrix,
|
|
261
|
-
code1, code2)
|
|
271
|
+
similarities[i] = self._get_similarity(self._matrix, code1, code2)
|
|
262
272
|
# Delete self-similarity
|
|
263
273
|
similarities = np.delete(similarities, seq_i)
|
|
264
274
|
similarity = np.average(similarities)
|
|
@@ -283,14 +293,18 @@ class LetterSimilarityPlotter(LetterPlotter):
|
|
|
283
293
|
if to_black:
|
|
284
294
|
# From color to black
|
|
285
295
|
cmap_val = np.stack(
|
|
286
|
-
[
|
|
287
|
-
|
|
296
|
+
[
|
|
297
|
+
np.interp(np.linspace(0, 1, 100), [0, 1], [color[i], 0])
|
|
298
|
+
for i in range(len(color))
|
|
299
|
+
]
|
|
288
300
|
).transpose()
|
|
289
301
|
else:
|
|
290
302
|
# From white to color
|
|
291
303
|
cmap_val = np.stack(
|
|
292
|
-
[
|
|
293
|
-
|
|
304
|
+
[
|
|
305
|
+
np.interp(np.linspace(0, 1, 100), [0, 1], [1, color[i]])
|
|
306
|
+
for i in range(len(color))
|
|
307
|
+
]
|
|
294
308
|
).transpose()
|
|
295
309
|
return ListedColormap(cmap_val)
|
|
296
310
|
|
|
@@ -310,7 +324,7 @@ class LetterTypePlotter(LetterPlotter):
|
|
|
310
324
|
The alphabet of the alignment(s) to be plotted
|
|
311
325
|
color_scheme : str or list of (tuple or str), optional
|
|
312
326
|
Either a valid color scheme name
|
|
313
|
-
(e.g. ``"
|
|
327
|
+
(e.g. ``"flower"``, ``"clustalx"``, ``blossom``, etc.)
|
|
314
328
|
or a list of *Matplotlib* compatible colors.
|
|
315
329
|
The list length must be at least as long as the
|
|
316
330
|
length of the alphabet used by the sequences.
|
|
@@ -325,12 +339,19 @@ class LetterTypePlotter(LetterPlotter):
|
|
|
325
339
|
:class:`matplotlib.Text` instance of each symbol.
|
|
326
340
|
"""
|
|
327
341
|
|
|
328
|
-
def __init__(
|
|
329
|
-
|
|
342
|
+
def __init__(
|
|
343
|
+
self,
|
|
344
|
+
axes,
|
|
345
|
+
alphabet,
|
|
346
|
+
color_scheme=None,
|
|
347
|
+
color_symbols=False,
|
|
348
|
+
font_size=None,
|
|
349
|
+
font_param=None,
|
|
350
|
+
):
|
|
330
351
|
super().__init__(axes, color_symbols, font_size, font_param)
|
|
331
352
|
|
|
332
353
|
if color_scheme is None:
|
|
333
|
-
self._colors = get_color_scheme("
|
|
354
|
+
self._colors = get_color_scheme("flower", alphabet)
|
|
334
355
|
elif isinstance(color_scheme, str):
|
|
335
356
|
self._colors = get_color_scheme(color_scheme, alphabet)
|
|
336
357
|
else:
|
|
@@ -346,7 +367,7 @@ class LetterTypePlotter(LetterPlotter):
|
|
|
346
367
|
|
|
347
368
|
|
|
348
369
|
class ArrayPlotter(LetterPlotter):
|
|
349
|
-
|
|
370
|
+
"""
|
|
350
371
|
This :class:`SymbolPlotter` quantitatively decorates sequences alignments, with molecular
|
|
351
372
|
recognition data obtained from e.g. microarrays. Symbols are visualized as characters
|
|
352
373
|
on a colored background box. The color of a given box represents the recognition
|
|
@@ -371,15 +392,14 @@ class ArrayPlotter(LetterPlotter):
|
|
|
371
392
|
Additional parameters that is given to the
|
|
372
393
|
:class:`matplotlib.Text` instance of each symbol.
|
|
373
394
|
|
|
374
|
-
|
|
375
|
-
def __init__(self, axes, fl_score, color_symbols=False,
|
|
376
|
-
font_size=None, font_param=None):
|
|
395
|
+
"""
|
|
377
396
|
|
|
397
|
+
def __init__(
|
|
398
|
+
self, axes, fl_score, color_symbols=False, font_size=None, font_param=None
|
|
399
|
+
):
|
|
378
400
|
super().__init__(axes, color_symbols, font_size, font_param)
|
|
379
401
|
self.fl_score = fl_score
|
|
380
|
-
self._cmap = self._generate_colormap(colors["dimorange"],
|
|
381
|
-
self._color_symbols)
|
|
382
|
-
|
|
402
|
+
self._cmap = self._generate_colormap(colors["dimorange"], self._color_symbols)
|
|
383
403
|
|
|
384
404
|
def get_color(self, alignment, column_i, seq_i):
|
|
385
405
|
index1 = alignment.trace[column_i, seq_i]
|
|
@@ -389,7 +409,6 @@ class ArrayPlotter(LetterPlotter):
|
|
|
389
409
|
spot_signal = self._get_signal(self.fl_score, column_i, seq_i)
|
|
390
410
|
return self._cmap(spot_signal)
|
|
391
411
|
|
|
392
|
-
|
|
393
412
|
def _get_signal(self, fl_score, column_i, seq_i):
|
|
394
413
|
if fl_score is None:
|
|
395
414
|
signal = 0.0
|
|
@@ -400,7 +419,6 @@ class ArrayPlotter(LetterPlotter):
|
|
|
400
419
|
def get_cmap(self):
|
|
401
420
|
return self._cmap
|
|
402
421
|
|
|
403
|
-
|
|
404
422
|
def plot_symbol(self, bbox, alignment, column_i, seq_i):
|
|
405
423
|
from matplotlib.patches import Rectangle
|
|
406
424
|
|
|
@@ -422,9 +440,15 @@ class ArrayPlotter(LetterPlotter):
|
|
|
422
440
|
box = Rectangle(bbox.p0, bbox.width, bbox.height)
|
|
423
441
|
self.axes.add_patch(box)
|
|
424
442
|
text = self.axes.text(
|
|
425
|
-
bbox.x0 + bbox.width/
|
|
426
|
-
|
|
427
|
-
|
|
443
|
+
bbox.x0 + bbox.width / 2,
|
|
444
|
+
bbox.y0 + bbox.height / 2,
|
|
445
|
+
symbol,
|
|
446
|
+
color="black",
|
|
447
|
+
ha="center",
|
|
448
|
+
va="center",
|
|
449
|
+
size=self._font_size,
|
|
450
|
+
**self._font_param,
|
|
451
|
+
)
|
|
428
452
|
text.set_clip_on(True)
|
|
429
453
|
|
|
430
454
|
if self._color_symbols:
|
|
@@ -455,11 +479,20 @@ class ArrayPlotter(LetterPlotter):
|
|
|
455
479
|
return ListedColormap(cmap_val)
|
|
456
480
|
|
|
457
481
|
|
|
458
|
-
def plot_alignment(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
482
|
+
def plot_alignment(
|
|
483
|
+
axes,
|
|
484
|
+
alignment,
|
|
485
|
+
symbol_plotter,
|
|
486
|
+
symbols_per_line=50,
|
|
487
|
+
show_numbers=False,
|
|
488
|
+
number_size=None,
|
|
489
|
+
number_functions=None,
|
|
490
|
+
labels=None,
|
|
491
|
+
label_size=None,
|
|
492
|
+
show_line_position=False,
|
|
493
|
+
spacing=1,
|
|
494
|
+
symbol_spacing=None,
|
|
495
|
+
):
|
|
463
496
|
"""
|
|
464
497
|
Plot a pairwise or multiple sequence alignment.
|
|
465
498
|
|
|
@@ -545,7 +578,7 @@ def plot_alignment(axes, alignment, symbol_plotter, symbols_per_line=50,
|
|
|
545
578
|
)
|
|
546
579
|
for i, func in enumerate(number_functions):
|
|
547
580
|
if func is None:
|
|
548
|
-
number_functions[i] =
|
|
581
|
+
number_functions[i] = lambda x: x + 1
|
|
549
582
|
|
|
550
583
|
seq_num = alignment.trace.shape[1]
|
|
551
584
|
seq_len = alignment.trace.shape[0]
|
|
@@ -573,7 +606,7 @@ def plot_alignment(axes, alignment, symbol_plotter, symbols_per_line=50,
|
|
|
573
606
|
for i in range(seq_len):
|
|
574
607
|
y = y_start
|
|
575
608
|
for j in range(seq_num):
|
|
576
|
-
bbox = Bbox([[x, y], [x+1, y+1]])
|
|
609
|
+
bbox = Bbox([[x, y], [x + 1, y + 1]])
|
|
577
610
|
symbol_plotter.plot_symbol(bbox, alignment, i, j)
|
|
578
611
|
y += 1
|
|
579
612
|
line_pos += 1
|
|
@@ -583,8 +616,7 @@ def plot_alignment(axes, alignment, symbol_plotter, symbols_per_line=50,
|
|
|
583
616
|
y_start += seq_num + spacing
|
|
584
617
|
else:
|
|
585
618
|
x += 1
|
|
586
|
-
if (symbol_spacing
|
|
587
|
-
and (i + 1) % symbol_spacing == 0):
|
|
619
|
+
if symbol_spacing and (i + 1) % symbol_spacing == 0:
|
|
588
620
|
line_pos += 1
|
|
589
621
|
x += 1
|
|
590
622
|
|
|
@@ -613,14 +645,12 @@ def plot_alignment(axes, alignment, symbol_plotter, symbols_per_line=50,
|
|
|
613
645
|
y = 0.5
|
|
614
646
|
for i in range(line_count):
|
|
615
647
|
for j in range(seq_num):
|
|
616
|
-
if i == line_count-1:
|
|
648
|
+
if i == line_count - 1:
|
|
617
649
|
# Last line -> get number of last column in trace
|
|
618
650
|
trace_pos = len(alignment.trace) - 1
|
|
619
651
|
else:
|
|
620
|
-
trace_pos = (i+1) * symbols_per_line - 1
|
|
621
|
-
seq_index = _get_last_valid_index(
|
|
622
|
-
alignment, trace_pos, j
|
|
623
|
-
)
|
|
652
|
+
trace_pos = (i + 1) * symbols_per_line - 1
|
|
653
|
+
seq_index = _get_last_valid_index(alignment, trace_pos, j)
|
|
624
654
|
# if -1 -> terminal gap
|
|
625
655
|
# -> skip number for this sequence in this line
|
|
626
656
|
if seq_index != -1:
|
|
@@ -636,18 +666,14 @@ def plot_alignment(axes, alignment, symbol_plotter, symbols_per_line=50,
|
|
|
636
666
|
|
|
637
667
|
axes.set_xlim(0, symbols_to_print)
|
|
638
668
|
# Y-axis starts from top
|
|
639
|
-
lim = seq_num*line_count + spacing*(line_count-1)
|
|
669
|
+
lim = seq_num * line_count + spacing * (line_count - 1)
|
|
640
670
|
axes.set_ylim(lim, 0)
|
|
641
671
|
number_axes.set_ylim(lim, 0)
|
|
642
672
|
axes.set_frame_on(False)
|
|
643
673
|
number_axes.set_frame_on(False)
|
|
644
674
|
# Remove ticks and set label and number size
|
|
645
|
-
axes.yaxis.set_tick_params(
|
|
646
|
-
|
|
647
|
-
)
|
|
648
|
-
number_axes.yaxis.set_tick_params(
|
|
649
|
-
left=False, right=False, labelsize=number_size
|
|
650
|
-
)
|
|
675
|
+
axes.yaxis.set_tick_params(left=False, right=False, labelsize=label_size)
|
|
676
|
+
number_axes.yaxis.set_tick_params(left=False, right=False, labelsize=number_size)
|
|
651
677
|
|
|
652
678
|
if show_line_position:
|
|
653
679
|
axes.xaxis.set_tick_params(
|
|
@@ -659,15 +685,25 @@ def plot_alignment(axes, alignment, symbol_plotter, symbols_per_line=50,
|
|
|
659
685
|
)
|
|
660
686
|
|
|
661
687
|
|
|
662
|
-
def plot_alignment_similarity_based(
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
688
|
+
def plot_alignment_similarity_based(
|
|
689
|
+
axes,
|
|
690
|
+
alignment,
|
|
691
|
+
symbols_per_line=50,
|
|
692
|
+
show_numbers=False,
|
|
693
|
+
number_size=None,
|
|
694
|
+
number_functions=None,
|
|
695
|
+
labels=None,
|
|
696
|
+
label_size=None,
|
|
697
|
+
show_line_position=False,
|
|
698
|
+
spacing=1,
|
|
699
|
+
color=None,
|
|
700
|
+
cmap=None,
|
|
701
|
+
matrix=None,
|
|
702
|
+
color_symbols=False,
|
|
703
|
+
symbol_spacing=None,
|
|
704
|
+
symbol_size=None,
|
|
705
|
+
symbol_param=None,
|
|
706
|
+
):
|
|
671
707
|
r"""
|
|
672
708
|
Plot a pairwise or multiple sequence alignment highlighting
|
|
673
709
|
the similarity per alignment column.
|
|
@@ -788,31 +824,47 @@ def plot_alignment_similarity_based(axes, alignment, symbols_per_line=50,
|
|
|
788
824
|
because *a* does also occur in *b*\ :sub:`i`.
|
|
789
825
|
"""
|
|
790
826
|
symbol_plotter = LetterSimilarityPlotter(
|
|
791
|
-
axes,
|
|
792
|
-
|
|
827
|
+
axes,
|
|
828
|
+
matrix=matrix,
|
|
829
|
+
font_size=symbol_size,
|
|
830
|
+
font_param=symbol_param,
|
|
831
|
+
color_symbols=color_symbols,
|
|
793
832
|
)
|
|
794
833
|
if color is not None or cmap is not None:
|
|
795
834
|
symbol_plotter.set_color(color=color, cmap=cmap)
|
|
796
835
|
plot_alignment(
|
|
797
|
-
axes=axes,
|
|
836
|
+
axes=axes,
|
|
837
|
+
alignment=alignment,
|
|
838
|
+
symbol_plotter=symbol_plotter,
|
|
798
839
|
symbols_per_line=symbols_per_line,
|
|
799
|
-
show_numbers=show_numbers,
|
|
840
|
+
show_numbers=show_numbers,
|
|
841
|
+
number_size=number_size,
|
|
800
842
|
number_functions=number_functions,
|
|
801
|
-
labels=labels,
|
|
843
|
+
labels=labels,
|
|
844
|
+
label_size=label_size,
|
|
802
845
|
show_line_position=show_line_position,
|
|
803
|
-
spacing=spacing,
|
|
846
|
+
spacing=spacing,
|
|
847
|
+
symbol_spacing=symbol_spacing,
|
|
804
848
|
)
|
|
805
849
|
|
|
806
850
|
|
|
807
|
-
def plot_alignment_type_based(
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
851
|
+
def plot_alignment_type_based(
|
|
852
|
+
axes,
|
|
853
|
+
alignment,
|
|
854
|
+
symbols_per_line=50,
|
|
855
|
+
show_numbers=False,
|
|
856
|
+
number_size=None,
|
|
857
|
+
number_functions=None,
|
|
858
|
+
labels=None,
|
|
859
|
+
label_size=None,
|
|
860
|
+
show_line_position=False,
|
|
861
|
+
spacing=1,
|
|
862
|
+
color_scheme=None,
|
|
863
|
+
color_symbols=False,
|
|
864
|
+
symbol_size=None,
|
|
865
|
+
symbol_param=None,
|
|
866
|
+
symbol_spacing=None,
|
|
867
|
+
):
|
|
816
868
|
"""
|
|
817
869
|
Plot a pairwise or multiple sequence alignment coloring each symbol
|
|
818
870
|
based on the symbol type.
|
|
@@ -873,7 +925,7 @@ def plot_alignment_type_based(axes, alignment, symbols_per_line=50,
|
|
|
873
925
|
is equal to the size of a symbol box.
|
|
874
926
|
color_scheme : str or list of (tuple or str), optional
|
|
875
927
|
Either a valid color scheme name
|
|
876
|
-
(e.g. ``"
|
|
928
|
+
(e.g. ``"flower"``, ``"clustalx"``, ``blossom``, etc.)
|
|
877
929
|
or a list of *Matplotlib* compatible colors.
|
|
878
930
|
The list length must be at least as long as the
|
|
879
931
|
length of the alphabet used by the sequences.
|
|
@@ -897,27 +949,48 @@ def plot_alignment_type_based(axes, alignment, symbols_per_line=50,
|
|
|
897
949
|
"""
|
|
898
950
|
alphabet = alignment.sequences[0].get_alphabet()
|
|
899
951
|
symbol_plotter = LetterTypePlotter(
|
|
900
|
-
axes,
|
|
901
|
-
|
|
952
|
+
axes,
|
|
953
|
+
alphabet,
|
|
954
|
+
font_size=symbol_size,
|
|
955
|
+
font_param=symbol_param,
|
|
956
|
+
color_symbols=color_symbols,
|
|
957
|
+
color_scheme=color_scheme,
|
|
902
958
|
)
|
|
903
959
|
plot_alignment(
|
|
904
|
-
axes=axes,
|
|
960
|
+
axes=axes,
|
|
961
|
+
alignment=alignment,
|
|
962
|
+
symbol_plotter=symbol_plotter,
|
|
905
963
|
symbols_per_line=symbols_per_line,
|
|
906
|
-
show_numbers=show_numbers,
|
|
964
|
+
show_numbers=show_numbers,
|
|
965
|
+
number_size=number_size,
|
|
907
966
|
number_functions=number_functions,
|
|
908
|
-
labels=labels,
|
|
967
|
+
labels=labels,
|
|
968
|
+
label_size=label_size,
|
|
909
969
|
show_line_position=show_line_position,
|
|
910
|
-
spacing=spacing,
|
|
970
|
+
spacing=spacing,
|
|
971
|
+
symbol_spacing=symbol_spacing,
|
|
911
972
|
)
|
|
912
973
|
|
|
913
|
-
def plot_alignment_array(axes, alignment, fl_score, symbols_per_line=50,
|
|
914
|
-
show_numbers=False, number_size=None,
|
|
915
|
-
number_functions=None, labels=None, label_size=None,
|
|
916
|
-
show_line_position=False, spacing=1, color=None,
|
|
917
|
-
cmap=None, symbol_spacing=None,
|
|
918
|
-
symbol_size=None, symbol_param=None):
|
|
919
974
|
|
|
920
|
-
|
|
975
|
+
def plot_alignment_array(
|
|
976
|
+
axes,
|
|
977
|
+
alignment,
|
|
978
|
+
fl_score,
|
|
979
|
+
symbols_per_line=50,
|
|
980
|
+
show_numbers=False,
|
|
981
|
+
number_size=None,
|
|
982
|
+
number_functions=None,
|
|
983
|
+
labels=None,
|
|
984
|
+
label_size=None,
|
|
985
|
+
show_line_position=False,
|
|
986
|
+
spacing=1,
|
|
987
|
+
color=None,
|
|
988
|
+
cmap=None,
|
|
989
|
+
symbol_spacing=None,
|
|
990
|
+
symbol_size=None,
|
|
991
|
+
symbol_param=None,
|
|
992
|
+
):
|
|
993
|
+
"""
|
|
921
994
|
Plot a pairwise sequence alignment using an :class:`ArrayPlotter`
|
|
922
995
|
instance.
|
|
923
996
|
|
|
@@ -995,19 +1068,27 @@ def plot_alignment_array(axes, alignment, fl_score, symbols_per_line=50,
|
|
|
995
1068
|
A '*' represents a sequence match on the alignment
|
|
996
1069
|
A '-' represents a sequence gap on the alignment
|
|
997
1070
|
|
|
998
|
-
|
|
1071
|
+
"""
|
|
999
1072
|
symbol_plotter = ArrayPlotter(
|
|
1000
|
-
axes,
|
|
1073
|
+
axes,
|
|
1074
|
+
fl_score=fl_score,
|
|
1075
|
+
font_size=symbol_size,
|
|
1076
|
+
font_param=symbol_param,
|
|
1001
1077
|
)
|
|
1002
1078
|
|
|
1003
1079
|
plot_alignment(
|
|
1004
|
-
axes=axes,
|
|
1080
|
+
axes=axes,
|
|
1081
|
+
alignment=alignment,
|
|
1082
|
+
symbol_plotter=symbol_plotter,
|
|
1005
1083
|
symbols_per_line=symbols_per_line,
|
|
1006
|
-
show_numbers=show_numbers,
|
|
1084
|
+
show_numbers=show_numbers,
|
|
1085
|
+
number_size=number_size,
|
|
1007
1086
|
number_functions=number_functions,
|
|
1008
|
-
labels=labels,
|
|
1087
|
+
labels=labels,
|
|
1088
|
+
label_size=label_size,
|
|
1009
1089
|
show_line_position=show_line_position,
|
|
1010
|
-
spacing=spacing,
|
|
1090
|
+
spacing=spacing,
|
|
1091
|
+
symbol_spacing=symbol_spacing,
|
|
1011
1092
|
)
|
|
1012
1093
|
|
|
1013
1094
|
|
|
@@ -6,12 +6,11 @@ __name__ = "biotite.sequence.graphics"
|
|
|
6
6
|
__author__ = "Patrick Kunzmann"
|
|
7
7
|
__all__ = ["get_color_scheme", "list_color_scheme_names", "load_color_scheme"]
|
|
8
8
|
|
|
9
|
-
import numpy as np
|
|
10
|
-
import json
|
|
11
|
-
from os.path import join, dirname, realpath
|
|
12
9
|
import glob
|
|
10
|
+
import json
|
|
13
11
|
import os
|
|
14
|
-
from
|
|
12
|
+
from os.path import dirname, join, realpath
|
|
13
|
+
from biotite.sequence.alphabet import Alphabet
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
def load_color_scheme(file_name):
|
|
@@ -26,13 +25,13 @@ def load_color_scheme(file_name):
|
|
|
26
25
|
----------
|
|
27
26
|
file_name : str
|
|
28
27
|
The file name of the JSON file containing the scheme.
|
|
29
|
-
|
|
28
|
+
|
|
30
29
|
Returns
|
|
31
30
|
-------
|
|
32
31
|
scheme : dict
|
|
33
32
|
A dictionary representing the color scheme, It contains the
|
|
34
33
|
following keys, if the input file is proper:
|
|
35
|
-
|
|
34
|
+
|
|
36
35
|
- **name** - Name of the scheme.
|
|
37
36
|
- **alphabet** - :class:`Alphabet` instance describing the
|
|
38
37
|
type of sequence the scheme can be used for.
|
|
@@ -71,7 +70,7 @@ def get_color_scheme(name, alphabet, default="#FFFFFF"):
|
|
|
71
70
|
default : str or tuple, optional
|
|
72
71
|
A *Matplotlib* compatible color that is used for symbols that
|
|
73
72
|
have no defined color in the scheme.
|
|
74
|
-
|
|
73
|
+
|
|
75
74
|
Returns
|
|
76
75
|
-------
|
|
77
76
|
colors : list
|
|
@@ -99,11 +98,10 @@ def get_color_scheme(name, alphabet, default="#FFFFFF"):
|
|
|
99
98
|
if scheme["name"] == name and scheme["alphabet"].extends(alphabet):
|
|
100
99
|
colors = scheme["colors"]
|
|
101
100
|
# Replace None values with default color
|
|
102
|
-
colors = [color if color is not None else default
|
|
103
|
-
for color in colors]
|
|
101
|
+
colors = [color if color is not None else default for color in colors]
|
|
104
102
|
# Only return colors that are in scope of this alphabet
|
|
105
103
|
# and not the extended alphabet
|
|
106
|
-
return colors[:len(alphabet)]
|
|
104
|
+
return colors[: len(alphabet)]
|
|
107
105
|
raise ValueError(f"Unkown scheme '{name}' for given alphabet")
|
|
108
106
|
|
|
109
107
|
|
|
@@ -117,7 +115,7 @@ def list_color_scheme_names(alphabet):
|
|
|
117
115
|
The alphbet to get the color scheme names for.
|
|
118
116
|
The alphabet of the scheme must equal or extend this parameter,
|
|
119
117
|
to be included in the list.
|
|
120
|
-
|
|
118
|
+
|
|
121
119
|
Returns
|
|
122
120
|
-------
|
|
123
121
|
schemes : list of str
|
|
@@ -136,4 +134,4 @@ _color_schemes = []
|
|
|
136
134
|
|
|
137
135
|
for file_name in glob.glob(_scheme_dir + os.sep + "*.json"):
|
|
138
136
|
scheme = load_color_scheme(file_name)
|
|
139
|
-
_color_schemes.append(scheme)
|
|
137
|
+
_color_schemes.append(scheme)
|