biotite 1.0.1__cp312-cp312-win_amd64.whl → 1.2.0__cp312-cp312-win_amd64.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/application/application.py +3 -3
- biotite/application/autodock/app.py +1 -1
- biotite/application/blast/webapp.py +1 -1
- biotite/application/clustalo/app.py +1 -1
- biotite/application/dssp/app.py +13 -3
- biotite/application/localapp.py +36 -2
- biotite/application/msaapp.py +10 -10
- biotite/application/muscle/app3.py +5 -18
- biotite/application/muscle/app5.py +5 -5
- biotite/application/sra/app.py +0 -5
- biotite/application/util.py +22 -2
- biotite/application/viennarna/rnaalifold.py +8 -8
- biotite/application/viennarna/rnaplot.py +9 -3
- biotite/application/viennarna/util.py +1 -1
- biotite/application/webapp.py +1 -1
- biotite/database/afdb/__init__.py +12 -0
- biotite/database/afdb/download.py +191 -0
- biotite/database/entrez/dbnames.py +10 -0
- biotite/database/entrez/download.py +9 -10
- biotite/database/entrez/key.py +1 -1
- biotite/database/entrez/query.py +5 -4
- biotite/database/pubchem/download.py +6 -6
- biotite/database/pubchem/error.py +10 -0
- biotite/database/pubchem/query.py +12 -23
- biotite/database/rcsb/download.py +3 -2
- biotite/database/rcsb/query.py +8 -9
- biotite/database/uniprot/check.py +22 -17
- biotite/database/uniprot/download.py +3 -6
- biotite/database/uniprot/query.py +4 -5
- biotite/file.py +14 -2
- biotite/interface/__init__.py +19 -0
- biotite/interface/openmm/__init__.py +16 -0
- biotite/interface/openmm/state.py +93 -0
- biotite/interface/openmm/system.py +227 -0
- biotite/interface/pymol/__init__.py +198 -0
- biotite/interface/pymol/cgo.py +346 -0
- biotite/interface/pymol/convert.py +185 -0
- biotite/interface/pymol/display.py +267 -0
- biotite/interface/pymol/object.py +1226 -0
- biotite/interface/pymol/shapes.py +178 -0
- biotite/interface/pymol/startup.py +169 -0
- biotite/interface/rdkit/__init__.py +15 -0
- biotite/interface/rdkit/mol.py +490 -0
- biotite/interface/version.py +71 -0
- biotite/interface/warning.py +19 -0
- biotite/sequence/align/__init__.py +0 -4
- biotite/sequence/align/alignment.py +49 -14
- biotite/sequence/align/banded.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/banded.pyx +26 -26
- biotite/sequence/align/cigar.py +2 -2
- biotite/sequence/align/kmeralphabet.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/kmeralphabet.pyx +19 -2
- biotite/sequence/align/kmersimilarity.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/kmertable.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/kmertable.pyx +58 -48
- biotite/sequence/align/localgapped.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/localgapped.pyx +47 -47
- biotite/sequence/align/localungapped.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/localungapped.pyx +10 -10
- biotite/sequence/align/matrix.py +284 -57
- biotite/sequence/align/matrix_data/3Di.mat +24 -0
- biotite/sequence/align/matrix_data/PB.license +21 -0
- biotite/sequence/align/matrix_data/PB.mat +18 -0
- biotite/sequence/align/multiple.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/pairwise.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/pairwise.pyx +35 -35
- biotite/sequence/align/permutation.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/selector.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/selector.pyx +2 -2
- biotite/sequence/align/statistics.py +1 -1
- biotite/sequence/align/tracetable.cp312-win_amd64.pyd +0 -0
- biotite/sequence/alphabet.py +5 -2
- biotite/sequence/annotation.py +19 -13
- biotite/sequence/codec.cp312-win_amd64.pyd +0 -0
- biotite/sequence/codon.py +1 -2
- biotite/sequence/graphics/alignment.py +25 -39
- biotite/sequence/graphics/color_schemes/3di_flower.json +48 -0
- biotite/sequence/graphics/color_schemes/pb_flower.json +2 -1
- biotite/sequence/graphics/colorschemes.py +44 -11
- biotite/sequence/graphics/dendrogram.py +4 -2
- biotite/sequence/graphics/features.py +2 -2
- biotite/sequence/graphics/logo.py +10 -12
- biotite/sequence/io/fasta/convert.py +1 -2
- biotite/sequence/io/fasta/file.py +1 -1
- biotite/sequence/io/fastq/file.py +3 -3
- biotite/sequence/io/genbank/file.py +3 -3
- biotite/sequence/io/genbank/sequence.py +2 -0
- biotite/sequence/io/gff/convert.py +1 -1
- biotite/sequence/io/gff/file.py +1 -2
- biotite/sequence/phylo/nj.cp312-win_amd64.pyd +0 -0
- biotite/sequence/phylo/tree.cp312-win_amd64.pyd +0 -0
- biotite/sequence/phylo/upgma.cp312-win_amd64.pyd +0 -0
- biotite/sequence/profile.py +105 -29
- biotite/sequence/search.py +0 -1
- biotite/sequence/seqtypes.py +136 -8
- biotite/sequence/sequence.py +1 -2
- biotite/setup_ccd.py +197 -0
- biotite/structure/__init__.py +6 -3
- biotite/structure/alphabet/__init__.py +25 -0
- biotite/structure/alphabet/encoder.py +332 -0
- biotite/structure/alphabet/encoder_weights_3di.kerasify +0 -0
- biotite/structure/alphabet/i3d.py +109 -0
- biotite/structure/alphabet/layers.py +86 -0
- biotite/structure/alphabet/pb.license +21 -0
- biotite/structure/alphabet/pb.py +170 -0
- biotite/structure/alphabet/unkerasify.py +128 -0
- biotite/structure/atoms.py +163 -66
- biotite/structure/basepairs.py +26 -26
- biotite/structure/bonds.cp312-win_amd64.pyd +0 -0
- biotite/structure/bonds.pyx +79 -25
- biotite/structure/box.py +19 -21
- biotite/structure/celllist.cp312-win_amd64.pyd +0 -0
- biotite/structure/celllist.pyx +83 -67
- biotite/structure/chains.py +5 -37
- biotite/structure/charges.cp312-win_amd64.pyd +0 -0
- biotite/structure/compare.py +420 -13
- biotite/structure/density.py +1 -1
- biotite/structure/dotbracket.py +27 -28
- biotite/structure/filter.py +8 -8
- biotite/structure/geometry.py +74 -127
- biotite/structure/hbond.py +17 -19
- biotite/structure/info/__init__.py +1 -0
- biotite/structure/info/atoms.py +24 -15
- biotite/structure/info/bonds.py +12 -6
- biotite/structure/info/ccd.py +125 -34
- biotite/structure/info/{ccd/components.bcif → components.bcif} +0 -0
- biotite/structure/info/groups.py +62 -19
- biotite/structure/info/masses.py +9 -6
- biotite/structure/info/misc.py +15 -22
- biotite/structure/info/radii.py +92 -22
- biotite/structure/info/standardize.py +4 -4
- biotite/structure/integrity.py +4 -6
- biotite/structure/io/general.py +2 -2
- biotite/structure/io/gro/file.py +8 -9
- biotite/structure/io/mol/convert.py +1 -1
- biotite/structure/io/mol/ctab.py +33 -28
- biotite/structure/io/mol/mol.py +1 -1
- biotite/structure/io/mol/sdf.py +80 -53
- biotite/structure/io/pdb/convert.py +4 -3
- biotite/structure/io/pdb/file.py +85 -25
- biotite/structure/io/pdb/hybrid36.cp312-win_amd64.pyd +0 -0
- biotite/structure/io/pdbqt/file.py +36 -36
- biotite/structure/io/pdbx/__init__.py +1 -0
- biotite/structure/io/pdbx/bcif.py +54 -15
- biotite/structure/io/pdbx/cif.py +92 -66
- biotite/structure/io/pdbx/component.py +15 -4
- biotite/structure/io/pdbx/compress.py +321 -0
- biotite/structure/io/pdbx/convert.py +410 -75
- biotite/structure/io/pdbx/encoding.cp312-win_amd64.pyd +0 -0
- biotite/structure/io/pdbx/encoding.pyx +98 -17
- biotite/structure/io/trajfile.py +9 -6
- biotite/structure/io/util.py +38 -0
- biotite/structure/mechanics.py +0 -1
- biotite/structure/molecules.py +141 -156
- biotite/structure/pseudoknots.py +7 -13
- biotite/structure/repair.py +2 -4
- biotite/structure/residues.py +13 -24
- biotite/structure/rings.py +335 -0
- biotite/structure/sasa.cp312-win_amd64.pyd +0 -0
- biotite/structure/sasa.pyx +2 -1
- biotite/structure/segments.py +69 -11
- biotite/structure/sequence.py +0 -1
- biotite/structure/sse.py +0 -2
- biotite/structure/superimpose.py +74 -62
- biotite/structure/tm.py +581 -0
- biotite/structure/transform.py +12 -25
- biotite/structure/util.py +76 -4
- biotite/version.py +9 -4
- biotite/visualize.py +111 -1
- {biotite-1.0.1.dist-info → biotite-1.2.0.dist-info}/METADATA +6 -2
- {biotite-1.0.1.dist-info → biotite-1.2.0.dist-info}/RECORD +173 -143
- biotite/structure/info/ccd/README.rst +0 -8
- biotite/structure/info/ccd/amino_acids.txt +0 -1663
- biotite/structure/info/ccd/carbohydrates.txt +0 -1135
- biotite/structure/info/ccd/nucleotides.txt +0 -798
- {biotite-1.0.1.dist-info → biotite-1.2.0.dist-info}/WHEEL +0 -0
- {biotite-1.0.1.dist-info → biotite-1.2.0.dist-info}/licenses/LICENSE.rst +0 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
__name__ = "biotite.interface.pymol"
|
|
2
|
+
__author__ = "Patrick Kunzmann"
|
|
3
|
+
__all__ = ["TimeoutError", "RenderError", "show", "play"]
|
|
4
|
+
|
|
5
|
+
import datetime
|
|
6
|
+
import shutil
|
|
7
|
+
import subprocess
|
|
8
|
+
import tempfile
|
|
9
|
+
import time
|
|
10
|
+
from os import remove
|
|
11
|
+
from os.path import getsize, join
|
|
12
|
+
from biotite.interface.pymol.startup import get_and_set_pymol_instance
|
|
13
|
+
|
|
14
|
+
_INTERVAL = 0.1
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TimeoutError(Exception):
|
|
18
|
+
"""
|
|
19
|
+
Exception that is raised after time limit expiry in :func:`show()`.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RenderError(Exception):
|
|
26
|
+
"""
|
|
27
|
+
Exception that is raised when ``imagemagick`` or ``ffmpeg`` fails.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def show(size=None, use_ray=False, timeout=60.0, pymol_instance=None):
|
|
34
|
+
"""
|
|
35
|
+
Render an image of the *PyMOL* session and display it in the current
|
|
36
|
+
*Jupyter* notebook.
|
|
37
|
+
|
|
38
|
+
Note that this function works only in a *Jupyter* notebook.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
size : tuple of (int, int), optional
|
|
43
|
+
The width and height of the rendered image in pixels.
|
|
44
|
+
By default, the size of the current *PyMOL* viewport is used.
|
|
45
|
+
use_ray : bool, optional
|
|
46
|
+
If set to true, the a ray-traced image is created.
|
|
47
|
+
This will also increase the rendering time.
|
|
48
|
+
timeout : float
|
|
49
|
+
The number of seconds to wait for image output from *PyMOL*.
|
|
50
|
+
pymol_instance : module or SingletonPyMOL or PyMOL, optional
|
|
51
|
+
If *PyMOL* is used in library mode, the :class:`PyMOL`
|
|
52
|
+
or :class:`SingletonPyMOL` object is given here.
|
|
53
|
+
If otherwise *PyMOL* is used in GUI mode, the :mod:`pymol`
|
|
54
|
+
module is given.
|
|
55
|
+
By default the currently active *PyMOL* instance is used.
|
|
56
|
+
If no *PyMOL* instance is currently running,
|
|
57
|
+
*PyMOL* is started in library mode.
|
|
58
|
+
|
|
59
|
+
Raises
|
|
60
|
+
------
|
|
61
|
+
TimeoutError
|
|
62
|
+
If no image was created after expiry of the `timeout` limit.
|
|
63
|
+
|
|
64
|
+
Notes
|
|
65
|
+
-----
|
|
66
|
+
Internally uses the *PyMOL* ``png`` command.
|
|
67
|
+
"""
|
|
68
|
+
try:
|
|
69
|
+
from IPython.display import Image
|
|
70
|
+
except ImportError:
|
|
71
|
+
raise ImportError("IPython is not installed")
|
|
72
|
+
|
|
73
|
+
pymol_instance = get_and_set_pymol_instance(pymol_instance)
|
|
74
|
+
cmd = pymol_instance.cmd
|
|
75
|
+
|
|
76
|
+
if size is None:
|
|
77
|
+
width = 0
|
|
78
|
+
height = 0
|
|
79
|
+
else:
|
|
80
|
+
width, height = size
|
|
81
|
+
|
|
82
|
+
image_file = tempfile.NamedTemporaryFile(
|
|
83
|
+
delete=False, prefix="biotite_", suffix=".png"
|
|
84
|
+
)
|
|
85
|
+
# Close directly and cleanup later
|
|
86
|
+
# This is necessary, as Windows does not allow writing opened files
|
|
87
|
+
image_file.close()
|
|
88
|
+
|
|
89
|
+
start_time = datetime.datetime.now()
|
|
90
|
+
cmd.png(image_file.name, width, height, ray=int(use_ray))
|
|
91
|
+
while True:
|
|
92
|
+
# After 'timeout' seconds the loop exits with an error
|
|
93
|
+
if (datetime.datetime.now() - start_time).total_seconds() > timeout:
|
|
94
|
+
raise TimeoutError("No PNG image was output within the expected time limit")
|
|
95
|
+
# Check if PyMOL has already written image data to file
|
|
96
|
+
if getsize(image_file.name) > 0:
|
|
97
|
+
break
|
|
98
|
+
time.sleep(_INTERVAL)
|
|
99
|
+
|
|
100
|
+
with open(image_file.name, "rb") as f:
|
|
101
|
+
image_data = f.read()
|
|
102
|
+
remove(image_file.name)
|
|
103
|
+
return Image(image_data, embed=True, metadata={"source": "PyMOL"})
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def play(
|
|
107
|
+
size=None, fps=30, format="gif", html_attributes="controls", pymol_instance=None
|
|
108
|
+
):
|
|
109
|
+
"""
|
|
110
|
+
Render an video of the *PyMOL* video frames and display it in the current
|
|
111
|
+
*Jupyter* notebook.
|
|
112
|
+
|
|
113
|
+
Note that this function works only in a *Jupyter* notebook.
|
|
114
|
+
|
|
115
|
+
Parameters
|
|
116
|
+
----------
|
|
117
|
+
size : tuple of (int, int), optional
|
|
118
|
+
The width and height of the rendered video in pixels.
|
|
119
|
+
By default, the size of the current *PyMOL* viewport is used.
|
|
120
|
+
fps : int
|
|
121
|
+
The number of frames per second.
|
|
122
|
+
format : {"gif", "mp4"}, optional
|
|
123
|
+
The format of the rendered video.
|
|
124
|
+
By default, a GIF is created.
|
|
125
|
+
html_attributes : str, optional
|
|
126
|
+
The HTML attributes that are passed to the ``<video>`` tag.
|
|
127
|
+
Only used, if ``format="mp4"``.
|
|
128
|
+
pymol_instance : module or SingletonPyMOL or PyMOL, optional
|
|
129
|
+
If *PyMOL* is used in library mode, the :class:`PyMOL`
|
|
130
|
+
or :class:`SingletonPyMOL` object is given here.
|
|
131
|
+
If otherwise *PyMOL* is used in GUI mode, the :mod:`pymol`
|
|
132
|
+
module is given.
|
|
133
|
+
By default the currently active *PyMOL* instance is used.
|
|
134
|
+
If no *PyMOL* instance is currently running,
|
|
135
|
+
*PyMOL* is started in library mode.
|
|
136
|
+
|
|
137
|
+
Notes
|
|
138
|
+
-----
|
|
139
|
+
Internally uses the *PyMOL* ``mpng`` command.
|
|
140
|
+
This function requires either the ``ffmpeg`` (``gif`` or ``mp4``)
|
|
141
|
+
or ``imagemagick`` (``gif``) command line tool to be installed.
|
|
142
|
+
"""
|
|
143
|
+
try:
|
|
144
|
+
from IPython.display import Image, Video
|
|
145
|
+
except ImportError:
|
|
146
|
+
raise ImportError("IPython is not installed")
|
|
147
|
+
|
|
148
|
+
pymol_instance = get_and_set_pymol_instance(pymol_instance)
|
|
149
|
+
cmd = pymol_instance.cmd
|
|
150
|
+
|
|
151
|
+
if size is None:
|
|
152
|
+
width = 0
|
|
153
|
+
height = 0
|
|
154
|
+
else:
|
|
155
|
+
width, height = size
|
|
156
|
+
|
|
157
|
+
with tempfile.TemporaryDirectory(prefix="biotite_") as frame_dir:
|
|
158
|
+
# Must use ray tracing, as no window is created
|
|
159
|
+
# Otherwise PyMOL raises 'MoviePNG-Error: Missing rendered image.'
|
|
160
|
+
cmd.mpng(join(frame_dir, "img_"), mode=2, width=width, height=height)
|
|
161
|
+
video_data = _create_video(frame_dir, fps, format)
|
|
162
|
+
|
|
163
|
+
if format == "mp4":
|
|
164
|
+
return Video(
|
|
165
|
+
video_data,
|
|
166
|
+
embed=True,
|
|
167
|
+
mimetype="video/mp4",
|
|
168
|
+
html_attributes=html_attributes,
|
|
169
|
+
)
|
|
170
|
+
else:
|
|
171
|
+
return Image(video_data, embed=True, metadata={"source": "PyMOL"})
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def _create_video(input_dir, fps, format):
|
|
175
|
+
"""
|
|
176
|
+
Create a video from the images in the given directory using ``ffmpeg```
|
|
177
|
+
or ``imagemagick``.
|
|
178
|
+
|
|
179
|
+
Parameters
|
|
180
|
+
----------
|
|
181
|
+
input_dir : str
|
|
182
|
+
The directory containing the frames to be concatenated into a video.
|
|
183
|
+
The images are consumed in lexographical order.
|
|
184
|
+
fps : int
|
|
185
|
+
The number of frames per second.
|
|
186
|
+
format : {"gif", "mp4"}
|
|
187
|
+
The format of the video.
|
|
188
|
+
|
|
189
|
+
Returns
|
|
190
|
+
-------
|
|
191
|
+
video : bytes
|
|
192
|
+
The video data.
|
|
193
|
+
"""
|
|
194
|
+
if format == "gif":
|
|
195
|
+
# GIFs created with 'imagemagick' have less artifacts
|
|
196
|
+
if _is_installed("magick"):
|
|
197
|
+
return _create_gif_with_imagemagick(input_dir, fps)
|
|
198
|
+
elif _is_installed("ffmpeg"):
|
|
199
|
+
return _create_video_with_ffmpeg(input_dir, fps, format)
|
|
200
|
+
else:
|
|
201
|
+
raise RenderError("Neither 'imagemagick' nor 'ffmpeg' is installed")
|
|
202
|
+
elif format == "mp4":
|
|
203
|
+
if _is_installed("ffmpeg"):
|
|
204
|
+
return _create_video_with_ffmpeg(input_dir, fps, format)
|
|
205
|
+
else:
|
|
206
|
+
raise RenderError("'ffmpeg' is not installed")
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def _create_gif_with_imagemagick(input_dir, fps):
|
|
210
|
+
# See https://usage.imagemagick.org/anim_basics/ for reference
|
|
211
|
+
completed_process = subprocess.run(
|
|
212
|
+
[
|
|
213
|
+
"magick",
|
|
214
|
+
# GIFs require a multiple of a hundredth of a second to work properly
|
|
215
|
+
"-delay", str(int(100 / fps)),
|
|
216
|
+
# Make animation loop infinitely
|
|
217
|
+
"-loop", "0",
|
|
218
|
+
# Do not overlay images
|
|
219
|
+
"-dispose", "Previous",
|
|
220
|
+
join(input_dir, "*.png"),
|
|
221
|
+
# Decrease GIF size
|
|
222
|
+
"-layers", "Optimize",
|
|
223
|
+
"GIF:-",
|
|
224
|
+
],
|
|
225
|
+
capture_output=True,
|
|
226
|
+
) # fmt: skip
|
|
227
|
+
if completed_process.returncode != 0:
|
|
228
|
+
raise RenderError(completed_process.stderr.decode())
|
|
229
|
+
return completed_process.stdout
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _create_video_with_ffmpeg(input_dir, fps, format):
|
|
233
|
+
# 'input_dir' is a temporary directory anyway
|
|
234
|
+
video_path = join(input_dir, f"video.{format}")
|
|
235
|
+
completed_process = subprocess.run(
|
|
236
|
+
[
|
|
237
|
+
"ffmpeg",
|
|
238
|
+
"-i", join(input_dir, "img_%04d.png"),
|
|
239
|
+
"-r", str(fps),
|
|
240
|
+
# Must be set to obtain a non-corrupted video
|
|
241
|
+
"-pix_fmt", "yuv420p",
|
|
242
|
+
video_path,
|
|
243
|
+
],
|
|
244
|
+
capture_output=True,
|
|
245
|
+
) # fmt: skip
|
|
246
|
+
if completed_process.returncode != 0:
|
|
247
|
+
raise RenderError(completed_process.stderr.decode())
|
|
248
|
+
with open(video_path, "rb") as f:
|
|
249
|
+
video_data = f.read()
|
|
250
|
+
return video_data
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def _is_installed(program):
|
|
254
|
+
"""
|
|
255
|
+
Check whether the given program is installed.
|
|
256
|
+
|
|
257
|
+
Parameters
|
|
258
|
+
----------
|
|
259
|
+
program : str
|
|
260
|
+
The name of the program to check.
|
|
261
|
+
|
|
262
|
+
Returns
|
|
263
|
+
-------
|
|
264
|
+
installed : bool
|
|
265
|
+
True, if the program is installed, false otherwise.
|
|
266
|
+
"""
|
|
267
|
+
return shutil.which(program) is not None
|