biotite 0.41.2__cp310-cp310-macosx_11_0_arm64.whl → 1.0.0__cp310-cp310-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-310-darwin.so +0 -0
- biotite/sequence/align/buckets.py +12 -10
- biotite/sequence/align/cigar.py +43 -52
- biotite/sequence/align/kmeralphabet.cpython-310-darwin.so +0 -0
- biotite/sequence/align/kmeralphabet.pyx +55 -51
- biotite/sequence/align/kmersimilarity.cpython-310-darwin.so +0 -0
- biotite/sequence/align/kmertable.cpython-310-darwin.so +0 -0
- biotite/sequence/align/kmertable.pyx +3 -2
- biotite/sequence/align/localgapped.cpython-310-darwin.so +0 -0
- biotite/sequence/align/localungapped.cpython-310-darwin.so +0 -0
- biotite/sequence/align/matrix.py +81 -82
- biotite/sequence/align/multiple.cpython-310-darwin.so +0 -0
- biotite/sequence/align/multiple.pyx +1 -1
- biotite/sequence/align/pairwise.cpython-310-darwin.so +0 -0
- biotite/sequence/align/permutation.cpython-310-darwin.so +0 -0
- biotite/sequence/align/permutation.pyx +12 -4
- biotite/sequence/align/selector.cpython-310-darwin.so +0 -0
- biotite/sequence/align/selector.pyx +52 -54
- biotite/sequence/align/statistics.py +32 -33
- biotite/sequence/align/tracetable.cpython-310-darwin.so +0 -0
- biotite/sequence/alphabet.py +51 -65
- biotite/sequence/annotation.py +78 -77
- biotite/sequence/codec.cpython-310-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-310-darwin.so +0 -0
- biotite/sequence/phylo/tree.cpython-310-darwin.so +0 -0
- biotite/sequence/phylo/upgma.cpython-310-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-310-darwin.so +0 -0
- biotite/structure/bonds.pyx +29 -32
- biotite/structure/box.py +67 -71
- biotite/structure/celllist.cpython-310-darwin.so +0 -0
- biotite/structure/chains.py +55 -39
- biotite/structure/charges.cpython-310-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-310-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-310-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-310-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-310-darwin.so +0 -0
- biotite/structure/io/mmtf/convertarray.pyx +0 -341
- biotite/structure/io/mmtf/convertfile.cpython-310-darwin.so +0 -0
- biotite/structure/io/mmtf/convertfile.pyx +0 -501
- biotite/structure/io/mmtf/decode.cpython-310-darwin.so +0 -0
- biotite/structure/io/mmtf/decode.pyx +0 -152
- biotite/structure/io/mmtf/encode.cpython-310-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
biotite/structure/mechanics.py
CHANGED
|
@@ -12,17 +12,14 @@ __author__ = "Patrick Kunzmann"
|
|
|
12
12
|
__all__ = ["mass_center", "gyration_radius"]
|
|
13
13
|
|
|
14
14
|
import numpy as np
|
|
15
|
-
from .
|
|
16
|
-
from .
|
|
17
|
-
from .error import BadStructureError
|
|
18
|
-
from .geometry import distance
|
|
19
|
-
from .info.masses import mass
|
|
15
|
+
from biotite.structure.geometry import distance
|
|
16
|
+
from biotite.structure.info.masses import mass
|
|
20
17
|
|
|
21
18
|
|
|
22
19
|
def gyration_radius(array, masses=None):
|
|
23
20
|
"""
|
|
24
21
|
Compute the radius/radii of gyration of an atom array or stack.
|
|
25
|
-
|
|
22
|
+
|
|
26
23
|
Parameters
|
|
27
24
|
----------
|
|
28
25
|
array : AtomArray or AtomArrayStack
|
|
@@ -33,7 +30,7 @@ def gyration_radius(array, masses=None):
|
|
|
33
30
|
Must have the same length as `array`. By default, the standard
|
|
34
31
|
atomic mass for each element is taken.
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
|
|
37
34
|
Returns
|
|
38
35
|
-------
|
|
39
36
|
masses : float or ndarray, dtype=float
|
|
@@ -46,13 +43,14 @@ def gyration_radius(array, masses=None):
|
|
|
46
43
|
masses = np.array([mass(element) for element in array.element])
|
|
47
44
|
center = mass_center(array, masses)
|
|
48
45
|
radii = distance(array, center[..., np.newaxis, :])
|
|
49
|
-
inertia_moment = np.sum(masses * radii*radii, axis=-1)
|
|
46
|
+
inertia_moment = np.sum(masses * radii * radii, axis=-1)
|
|
50
47
|
return np.sqrt(inertia_moment / np.sum(masses))
|
|
51
48
|
|
|
49
|
+
|
|
52
50
|
def mass_center(array, masses=None):
|
|
53
51
|
"""
|
|
54
52
|
Calculate the center(s) of mass of an atom array or stack.
|
|
55
|
-
|
|
53
|
+
|
|
56
54
|
Parameters
|
|
57
55
|
----------
|
|
58
56
|
array : AtomArray or AtomArrayStack
|
|
@@ -61,7 +59,7 @@ def mass_center(array, masses=None):
|
|
|
61
59
|
The masses to use for each atom in the input `array`.
|
|
62
60
|
Must have the same length as `array`. By default, the standard
|
|
63
61
|
atomic mass for each element is taken.
|
|
64
|
-
|
|
62
|
+
|
|
65
63
|
Returns
|
|
66
64
|
-------
|
|
67
65
|
radius : ndarray, ndarray, dtype=float
|
|
@@ -72,4 +70,4 @@ def mass_center(array, masses=None):
|
|
|
72
70
|
"""
|
|
73
71
|
if masses is None:
|
|
74
72
|
masses = np.array([mass(element) for element in array.element])
|
|
75
|
-
return np.sum(masses[:,np.newaxis] * array.coord, axis=-2) / np.sum(masses)
|
|
73
|
+
return np.sum(masses[:, np.newaxis] * array.coord, axis=-2) / np.sum(masses)
|
biotite/structure/molecules.py
CHANGED
|
@@ -12,8 +12,8 @@ __author__ = "Patrick Kunzmann"
|
|
|
12
12
|
__all__ = ["get_molecule_indices", "get_molecule_masks", "molecule_iter"]
|
|
13
13
|
|
|
14
14
|
import numpy as np
|
|
15
|
-
from .atoms import AtomArray, AtomArrayStack
|
|
16
|
-
from .bonds import BondList, find_connected
|
|
15
|
+
from biotite.structure.atoms import AtomArray, AtomArrayStack
|
|
16
|
+
from biotite.structure.bonds import BondList, find_connected
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def get_molecule_indices(array):
|
|
@@ -244,8 +244,7 @@ def get_molecule_masks(array):
|
|
|
244
244
|
|
|
245
245
|
molecule_indices = get_molecule_indices(bonds)
|
|
246
246
|
molecule_masks = np.zeros(
|
|
247
|
-
(len(molecule_indices), bonds.get_atom_count()),
|
|
248
|
-
dtype=bool
|
|
247
|
+
(len(molecule_indices), bonds.get_atom_count()), dtype=bool
|
|
249
248
|
)
|
|
250
249
|
for i in range(len(molecule_indices)):
|
|
251
250
|
molecule_masks[i, molecule_indices[i]] = True
|
biotite/structure/pseudoknots.py
CHANGED
|
@@ -10,9 +10,10 @@ __name__ = "biotite.structure"
|
|
|
10
10
|
__author__ = "Tom David Müller"
|
|
11
11
|
__all__ = ["pseudoknots"]
|
|
12
12
|
|
|
13
|
-
import numpy as np
|
|
14
|
-
import networkx as nx
|
|
15
13
|
from itertools import chain, product
|
|
14
|
+
import networkx as nx
|
|
15
|
+
import numpy as np
|
|
16
|
+
|
|
16
17
|
|
|
17
18
|
def pseudoknots(base_pairs, scores=None, max_pseudoknot_order=None):
|
|
18
19
|
"""
|
|
@@ -118,7 +119,7 @@ def pseudoknots(base_pairs, scores=None, max_pseudoknot_order=None):
|
|
|
118
119
|
return np.array([[]], dtype=np.int32)
|
|
119
120
|
|
|
120
121
|
# List containing the results
|
|
121
|
-
results = [np.full(len(base_pairs), -1, dtype=
|
|
122
|
+
results = [np.full(len(base_pairs), -1, dtype="int32")]
|
|
122
123
|
|
|
123
124
|
# if no score array is given, each base pairs' score is one
|
|
124
125
|
if scores is None:
|
|
@@ -126,9 +127,7 @@ def pseudoknots(base_pairs, scores=None, max_pseudoknot_order=None):
|
|
|
126
127
|
|
|
127
128
|
# Make sure `base_pairs` has the same length as the score array
|
|
128
129
|
if len(base_pairs) != len(scores):
|
|
129
|
-
raise ValueError(
|
|
130
|
-
"'base_pair' and 'scores' must have the same shape"
|
|
131
|
-
)
|
|
130
|
+
raise ValueError("'base_pair' and 'scores' must have the same shape")
|
|
132
131
|
|
|
133
132
|
# Split the base pairs in regions
|
|
134
133
|
regions = _find_regions(base_pairs, scores)
|
|
@@ -139,7 +138,7 @@ def pseudoknots(base_pairs, scores=None, max_pseudoknot_order=None):
|
|
|
139
138
|
return np.vstack(results)
|
|
140
139
|
|
|
141
140
|
|
|
142
|
-
class _Region
|
|
141
|
+
class _Region:
|
|
143
142
|
"""
|
|
144
143
|
This class represents a paired region.
|
|
145
144
|
|
|
@@ -159,7 +158,7 @@ class _Region():
|
|
|
159
158
|
The score for each base pair.
|
|
160
159
|
"""
|
|
161
160
|
|
|
162
|
-
def __init__
|
|
161
|
+
def __init__(self, base_pairs, region_pairs, scores):
|
|
163
162
|
# The Start and Stop indices for each Region
|
|
164
163
|
self.start = np.min(base_pairs[region_pairs])
|
|
165
164
|
self.stop = np.max(base_pairs[region_pairs])
|
|
@@ -245,19 +244,18 @@ def _find_regions(base_pairs, scores):
|
|
|
245
244
|
|
|
246
245
|
# Check if the current base pair belongs to the region that is
|
|
247
246
|
# currently being defined
|
|
248
|
-
previous_upstream_rank = rank[i-1, 0]
|
|
247
|
+
previous_upstream_rank = rank[i - 1, 0]
|
|
249
248
|
this_upstream_rank = rank[i, 0]
|
|
250
|
-
previous_downstream_rank = rank[i-1, 1]
|
|
249
|
+
previous_downstream_rank = rank[i - 1, 1]
|
|
251
250
|
this_downstream_rank = rank[i, 1]
|
|
252
251
|
|
|
253
252
|
# if the current base pair belongs to a new region, save the
|
|
254
253
|
# current region and start a new region
|
|
255
|
-
if (
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
region_pairs = []
|
|
254
|
+
if (previous_downstream_rank - this_downstream_rank) != 1 or (
|
|
255
|
+
this_upstream_rank - previous_upstream_rank
|
|
256
|
+
) != 1:
|
|
257
|
+
regions.add(_Region(base_pairs, np.array(region_pairs), scores))
|
|
258
|
+
region_pairs = []
|
|
261
259
|
|
|
262
260
|
# Append the current base pair to the region
|
|
263
261
|
region_pairs.append(original_indices[i])
|
|
@@ -296,7 +294,7 @@ def _generate_graphical_representation(regions):
|
|
|
296
294
|
# Get the region array and a boolean array, where the start of each
|
|
297
295
|
# region is ``True``.
|
|
298
296
|
region_array, (start_stops,) = _get_region_array_for(
|
|
299
|
-
regions, content=[lambda a
|
|
297
|
+
regions, content=[lambda a: [True, False]], dtype=["bool"]
|
|
300
298
|
)
|
|
301
299
|
|
|
302
300
|
# Check each region for conflicts with other regions
|
|
@@ -307,15 +305,15 @@ def _generate_graphical_representation(regions):
|
|
|
307
305
|
|
|
308
306
|
# Find the index of the stopping of the region in the region
|
|
309
307
|
# array
|
|
310
|
-
stop = _get_first_occurrence_for(region_array[start+1:], region)
|
|
311
|
-
stop +=
|
|
308
|
+
stop = _get_first_occurrence_for(region_array[start + 1 :], region)
|
|
309
|
+
stop += start + 1
|
|
312
310
|
|
|
313
311
|
# Store regions the current region conflicts with
|
|
314
312
|
conflicts = set()
|
|
315
313
|
|
|
316
314
|
# Iterate over the regions between the starting and stopping
|
|
317
315
|
# point of the current region
|
|
318
|
-
for other_region in region_array[start+1:stop]:
|
|
316
|
+
for other_region in region_array[start + 1 : stop]:
|
|
319
317
|
# If the other region is not already a conflict, add it to
|
|
320
318
|
# the conflict set
|
|
321
319
|
if other_region not in conflicts:
|
|
@@ -389,17 +387,17 @@ def _get_region_array_for(regions, content=[], dtype=[]):
|
|
|
389
387
|
The custom output.
|
|
390
388
|
"""
|
|
391
389
|
# region_array and index array
|
|
392
|
-
region_array = np.empty(len(regions)*2, dtype=_Region)
|
|
393
|
-
index_array = np.empty(len(regions)*2, dtype=
|
|
390
|
+
region_array = np.empty(len(regions) * 2, dtype=_Region)
|
|
391
|
+
index_array = np.empty(len(regions) * 2, dtype="int32")
|
|
394
392
|
|
|
395
393
|
# Content array for custom return arrays
|
|
396
|
-
content_list = [None]*len(content)
|
|
394
|
+
content_list = [None] * len(content)
|
|
397
395
|
for i in range(len(content)):
|
|
398
|
-
content_list[i] = np.empty(len(regions)*2, dtype=dtype[i])
|
|
396
|
+
content_list[i] = np.empty(len(regions) * 2, dtype=dtype[i])
|
|
399
397
|
|
|
400
398
|
# Fill the arrays
|
|
401
399
|
for i, reg in enumerate(regions):
|
|
402
|
-
indices = [2*i, 2*i+1]
|
|
400
|
+
indices = [2 * i, 2 * i + 1]
|
|
403
401
|
region_array[indices] = reg
|
|
404
402
|
for c in range(len(content_list)):
|
|
405
403
|
content_list[c][indices] = content[c](reg)
|
|
@@ -443,8 +441,8 @@ def _remove_pseudoknots(regions):
|
|
|
443
441
|
represented as ``set`` of unknotted regions.
|
|
444
442
|
"""
|
|
445
443
|
# Create dynamic programming matrix
|
|
446
|
-
dp_matrix_shape = len(regions)*2, len(regions)*2
|
|
447
|
-
dp_matrix = np.empty(dp_matrix_shape, dtype=
|
|
444
|
+
dp_matrix_shape = len(regions) * 2, len(regions) * 2
|
|
445
|
+
dp_matrix = np.empty(dp_matrix_shape, dtype="object")
|
|
448
446
|
dp_matrix_solutions_starts = np.zeros_like(dp_matrix)
|
|
449
447
|
dp_matrix_solutions_stops = np.zeros_like(dp_matrix)
|
|
450
448
|
|
|
@@ -452,9 +450,7 @@ def _remove_pseudoknots(regions):
|
|
|
452
450
|
# ``region_array`` contains the region objects and ``start_stops``
|
|
453
451
|
# contains the lowest and highest positions of the regions
|
|
454
452
|
region_array, (start_stops,) = _get_region_array_for(
|
|
455
|
-
regions,
|
|
456
|
-
[lambda a : (a.start, a.stop)],
|
|
457
|
-
['int32']
|
|
453
|
+
regions, [lambda a: (a.start, a.stop)], ["int32"]
|
|
458
454
|
)
|
|
459
455
|
# Initialise the matrix diagonal with ndarrays of empty frozensets
|
|
460
456
|
for i in range(len(dp_matrix)):
|
|
@@ -462,11 +458,11 @@ def _remove_pseudoknots(regions):
|
|
|
462
458
|
|
|
463
459
|
# Iterate through the top right half of the dynamic programming
|
|
464
460
|
# matrix
|
|
465
|
-
for j in range(len(regions)*2):
|
|
466
|
-
for i in range(j-1, -1, -1):
|
|
461
|
+
for j in range(len(regions) * 2):
|
|
462
|
+
for i in range(j - 1, -1, -1):
|
|
467
463
|
solution_candidates = set()
|
|
468
|
-
left = dp_matrix[i, j-1]
|
|
469
|
-
bottom = dp_matrix[i+1, j]
|
|
464
|
+
left = dp_matrix[i, j - 1]
|
|
465
|
+
bottom = dp_matrix[i + 1, j]
|
|
470
466
|
|
|
471
467
|
# Add all solutions of the cell to the left
|
|
472
468
|
for solution in left:
|
|
@@ -474,24 +470,21 @@ def _remove_pseudoknots(regions):
|
|
|
474
470
|
|
|
475
471
|
# Add all solutions of the cell to the bottom
|
|
476
472
|
for solution in bottom:
|
|
477
|
-
|
|
473
|
+
solution_candidates.add(solution)
|
|
478
474
|
|
|
479
475
|
# Check if i and j are start/end-points of the same region
|
|
480
476
|
if region_array[i] is region_array[j]:
|
|
481
|
-
|
|
482
477
|
# Add all solutions from the cell to the bottom left
|
|
483
478
|
# plus this region
|
|
484
|
-
bottom_left = dp_matrix[i+1, j-1]
|
|
479
|
+
bottom_left = dp_matrix[i + 1, j - 1]
|
|
485
480
|
for solution in bottom_left:
|
|
486
481
|
solution_candidates.add(solution | set([region_array[i]]))
|
|
487
482
|
|
|
488
483
|
# Perform additional tests if solution in the left cell and
|
|
489
484
|
# bottom cell both differ from an empty solution
|
|
490
|
-
if
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
left_highest = dp_matrix_solutions_stops[i, j-1]
|
|
494
|
-
bottom_lowest = dp_matrix_solutions_starts[i+1, j]
|
|
485
|
+
if np.any(left != [frozenset()]) and np.any(bottom != [frozenset()]):
|
|
486
|
+
left_highest = dp_matrix_solutions_stops[i, j - 1]
|
|
487
|
+
bottom_lowest = dp_matrix_solutions_starts[i + 1, j]
|
|
495
488
|
|
|
496
489
|
# For each pair of solutions check if solutions are
|
|
497
490
|
# disjoint
|
|
@@ -504,11 +497,11 @@ def _remove_pseudoknots(regions):
|
|
|
504
497
|
# Both solutions are not disjoint
|
|
505
498
|
# Add subsolutions
|
|
506
499
|
for k in range(
|
|
507
|
-
np.where(start_stops==lowest)[0][0]-1,
|
|
508
|
-
np.where(start_stops==highest)[0][0]+1
|
|
500
|
+
np.where(start_stops == lowest)[0][0] - 1,
|
|
501
|
+
np.where(start_stops == highest)[0][0] + 1,
|
|
509
502
|
):
|
|
510
503
|
cell1 = dp_matrix[i, k]
|
|
511
|
-
cell2 = dp_matrix[k+1, j]
|
|
504
|
+
cell2 = dp_matrix[k + 1, j]
|
|
512
505
|
for subsolution1 in cell1:
|
|
513
506
|
for subsolution2 in cell2:
|
|
514
507
|
solution_candidates.add(
|
|
@@ -536,16 +529,12 @@ def _remove_pseudoknots(regions):
|
|
|
536
529
|
# Add the solutions to the dynamic programming matrix
|
|
537
530
|
dp_matrix[i, j] = solution_candidates
|
|
538
531
|
|
|
539
|
-
solution_starts = np.zeros_like(solution_candidates, dtype=
|
|
540
|
-
solution_stops = np.zeros_like(solution_candidates, dtype=
|
|
532
|
+
solution_starts = np.zeros_like(solution_candidates, dtype="int32")
|
|
533
|
+
solution_stops = np.zeros_like(solution_candidates, dtype="int32")
|
|
541
534
|
|
|
542
535
|
for s, solution in enumerate(solution_candidates):
|
|
543
|
-
solution_starts[s] = min(
|
|
544
|
-
|
|
545
|
-
)
|
|
546
|
-
solution_stops[s] = max(
|
|
547
|
-
[reg.stop for reg in solution], default=-1
|
|
548
|
-
)
|
|
536
|
+
solution_starts[s] = min([reg.start for reg in solution], default=-1)
|
|
537
|
+
solution_stops[s] = max([reg.stop for reg in solution], default=-1)
|
|
549
538
|
|
|
550
539
|
dp_matrix_solutions_starts[i, j] = solution_starts
|
|
551
540
|
dp_matrix_solutions_stops[i, j] = solution_stops
|
|
@@ -586,14 +575,11 @@ def _get_results(regions, results, max_pseudoknot_order, order=0):
|
|
|
586
575
|
|
|
587
576
|
# Non-conflicting regions are of the current order:
|
|
588
577
|
index_list_non_conflicting = list(
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
)
|
|
592
|
-
)
|
|
578
|
+
chain(*[region.get_index_array() for region in non_conflicting])
|
|
579
|
+
)
|
|
593
580
|
for result in results:
|
|
594
581
|
result[index_list_non_conflicting] = order
|
|
595
582
|
|
|
596
|
-
|
|
597
583
|
# If no conflicts remain, the results are complete
|
|
598
584
|
if len(regions) == 0:
|
|
599
585
|
return results
|
|
@@ -601,9 +587,10 @@ def _get_results(regions, results, max_pseudoknot_order, order=0):
|
|
|
601
587
|
# Get the optimal solutions for given regions. Evaluate each clique
|
|
602
588
|
# of mutually conflicting regions seperately
|
|
603
589
|
cliques = [component for component in nx.connected_components(regions)]
|
|
604
|
-
solutions = [
|
|
605
|
-
*
|
|
606
|
-
|
|
590
|
+
solutions = [
|
|
591
|
+
set(chain(*e))
|
|
592
|
+
for e in product(*[_remove_pseudoknots(clique) for clique in cliques])
|
|
593
|
+
]
|
|
607
594
|
|
|
608
595
|
# Get a copy of the current results for each optimal solution
|
|
609
596
|
results_list = [
|
|
@@ -612,16 +599,13 @@ def _get_results(regions, results, max_pseudoknot_order, order=0):
|
|
|
612
599
|
|
|
613
600
|
# Evaluate each optimal solution
|
|
614
601
|
for i, solution in enumerate(solutions):
|
|
615
|
-
|
|
616
602
|
# Get the pseudoknotted regions
|
|
617
603
|
pseudoknotted_regions = regions.copy()
|
|
618
604
|
pseudoknotted_regions.remove_nodes_from(solution)
|
|
619
605
|
|
|
620
606
|
# Get an index list of the unknotted base pairs
|
|
621
607
|
index_list_unknotted = list(
|
|
622
|
-
chain(
|
|
623
|
-
*[region.get_index_array() for region in solution]
|
|
624
|
-
)
|
|
608
|
+
chain(*[region.get_index_array() for region in solution])
|
|
625
609
|
)
|
|
626
610
|
|
|
627
611
|
# Write results for current solution
|
|
@@ -634,8 +618,10 @@ def _get_results(regions, results, max_pseudoknot_order, order=0):
|
|
|
634
618
|
|
|
635
619
|
# Evaluate the pseudoknotted region
|
|
636
620
|
results_list[i] = _get_results(
|
|
637
|
-
pseudoknotted_regions,
|
|
638
|
-
|
|
621
|
+
pseudoknotted_regions,
|
|
622
|
+
results_list[i],
|
|
623
|
+
max_pseudoknot_order,
|
|
624
|
+
order=order + 1,
|
|
639
625
|
)
|
|
640
626
|
|
|
641
627
|
# Flatten the results
|
biotite/structure/rdf.py
CHANGED
|
@@ -12,15 +12,16 @@ __all__ = ["rdf"]
|
|
|
12
12
|
|
|
13
13
|
from numbers import Integral
|
|
14
14
|
import numpy as np
|
|
15
|
-
from .atoms import
|
|
16
|
-
from .box import box_volume
|
|
17
|
-
from .
|
|
18
|
-
from .
|
|
19
|
-
from .
|
|
15
|
+
from biotite.structure.atoms import AtomArray, coord, stack
|
|
16
|
+
from biotite.structure.box import box_volume
|
|
17
|
+
from biotite.structure.celllist import CellList
|
|
18
|
+
from biotite.structure.geometry import displacement
|
|
19
|
+
from biotite.structure.util import vector_dot
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def rdf(
|
|
23
|
-
|
|
22
|
+
def rdf(
|
|
23
|
+
center, atoms, selection=None, interval=(0, 10), bins=100, box=None, periodic=False
|
|
24
|
+
):
|
|
24
25
|
r"""
|
|
25
26
|
Compute the radial distribution function *g(r)* (RDF) for one or
|
|
26
27
|
multiple given central positions based on a given system of
|
|
@@ -155,7 +156,7 @@ def rdf(center, atoms, selection=None, interval=(0, 10), bins=100, box=None,
|
|
|
155
156
|
Find the radius for the first solvation shell.
|
|
156
157
|
In this simple case, the density peak is identified by finding
|
|
157
158
|
the maximum of the function.
|
|
158
|
-
|
|
159
|
+
|
|
159
160
|
>>> peak_position = np.argmax(g_r)
|
|
160
161
|
>>> print(f"{bins[peak_position]/10:.2f} nm")
|
|
161
162
|
0.29 nm
|
|
@@ -165,9 +166,9 @@ def rdf(center, atoms, selection=None, interval=(0, 10), bins=100, box=None,
|
|
|
165
166
|
atoms = stack([atoms])
|
|
166
167
|
if selection is not None:
|
|
167
168
|
atoms = atoms[..., selection]
|
|
168
|
-
|
|
169
|
+
|
|
169
170
|
atom_coord = atoms.coord
|
|
170
|
-
|
|
171
|
+
|
|
171
172
|
if box is None:
|
|
172
173
|
if atoms.box is None:
|
|
173
174
|
raise ValueError("A box must be supplied")
|
|
@@ -175,17 +176,15 @@ def rdf(center, atoms, selection=None, interval=(0, 10), bins=100, box=None,
|
|
|
175
176
|
box = atoms.box
|
|
176
177
|
elif box.ndim == 2 and atoms.stack_depth() == 1:
|
|
177
178
|
box = box[np.newaxis, :, :]
|
|
178
|
-
|
|
179
|
+
|
|
179
180
|
center = coord(center)
|
|
180
181
|
if center.ndim == 1:
|
|
181
182
|
center = center.reshape((1, 1) + center.shape)
|
|
182
183
|
elif center.ndim == 2:
|
|
183
184
|
center = center.reshape((1,) + center.shape)
|
|
184
|
-
|
|
185
|
+
|
|
185
186
|
if box.shape[0] != center.shape[0] or box.shape[0] != atom_coord.shape[0]:
|
|
186
|
-
raise ValueError(
|
|
187
|
-
"Center, box, and atoms must have the same model count"
|
|
188
|
-
)
|
|
187
|
+
raise ValueError("Center, box, and atoms must have the same model count")
|
|
189
188
|
|
|
190
189
|
# Calculate distance histogram
|
|
191
190
|
edges = _calculate_edges(interval, bins)
|
|
@@ -209,17 +208,20 @@ def rdf(center, atoms, selection=None, interval=(0, 10), bins=100, box=None,
|
|
|
209
208
|
for j in range(center.shape[1]):
|
|
210
209
|
dist_box = box[i] if periodic else None
|
|
211
210
|
# Calculate squared distances
|
|
212
|
-
disp.append(
|
|
213
|
-
|
|
214
|
-
|
|
211
|
+
disp.append(
|
|
212
|
+
displacement(
|
|
213
|
+
center[i, j], atom_coord[i, near_atom_mask[j]], box=dist_box
|
|
214
|
+
)
|
|
215
|
+
)
|
|
215
216
|
# Make one array from multiple arrays with different length
|
|
216
217
|
disp = np.concatenate(disp)
|
|
217
218
|
sq_distances = vector_dot(disp, disp)
|
|
218
219
|
hist, _ = np.histogram(sq_distances, bins=sq_edges)
|
|
219
220
|
|
|
220
221
|
# Normalize with average particle density (N/V) in each bin
|
|
221
|
-
bin_volume =
|
|
222
|
-
|
|
222
|
+
bin_volume = (4 / 3 * np.pi * np.power(edges[1:], 3)) - (
|
|
223
|
+
4 / 3 * np.pi * np.power(edges[:-1], 3)
|
|
224
|
+
)
|
|
223
225
|
n_frames = len(atoms)
|
|
224
226
|
volume = box_volume(box).mean()
|
|
225
227
|
density = atoms.array_length() / volume
|
|
@@ -237,7 +239,7 @@ def _calculate_edges(interval, bins):
|
|
|
237
239
|
if isinstance(bins, Integral):
|
|
238
240
|
if bins < 1:
|
|
239
241
|
raise ValueError("At least one bin is required")
|
|
240
|
-
return np.linspace(*interval, bins+1)
|
|
242
|
+
return np.linspace(*interval, bins + 1)
|
|
241
243
|
else:
|
|
242
244
|
# 'bins' contains edges
|
|
243
245
|
return np.array(bins, dtype=float)
|