biotite 1.5.0__cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.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 +18 -0
- biotite/application/__init__.py +69 -0
- biotite/application/application.py +276 -0
- biotite/application/autodock/__init__.py +12 -0
- biotite/application/autodock/app.py +500 -0
- biotite/application/blast/__init__.py +14 -0
- biotite/application/blast/alignment.py +92 -0
- biotite/application/blast/webapp.py +428 -0
- biotite/application/clustalo/__init__.py +12 -0
- biotite/application/clustalo/app.py +223 -0
- biotite/application/dssp/__init__.py +12 -0
- biotite/application/dssp/app.py +216 -0
- biotite/application/localapp.py +342 -0
- biotite/application/mafft/__init__.py +12 -0
- biotite/application/mafft/app.py +116 -0
- biotite/application/msaapp.py +363 -0
- biotite/application/muscle/__init__.py +13 -0
- biotite/application/muscle/app3.py +227 -0
- biotite/application/muscle/app5.py +163 -0
- biotite/application/sra/__init__.py +18 -0
- biotite/application/sra/app.py +447 -0
- biotite/application/tantan/__init__.py +12 -0
- biotite/application/tantan/app.py +199 -0
- biotite/application/util.py +77 -0
- biotite/application/viennarna/__init__.py +18 -0
- biotite/application/viennarna/rnaalifold.py +310 -0
- biotite/application/viennarna/rnafold.py +254 -0
- biotite/application/viennarna/rnaplot.py +208 -0
- biotite/application/viennarna/util.py +77 -0
- biotite/application/webapp.py +76 -0
- biotite/copyable.py +71 -0
- biotite/database/__init__.py +23 -0
- biotite/database/afdb/__init__.py +12 -0
- biotite/database/afdb/download.py +197 -0
- biotite/database/entrez/__init__.py +15 -0
- biotite/database/entrez/check.py +60 -0
- biotite/database/entrez/dbnames.py +101 -0
- biotite/database/entrez/download.py +228 -0
- biotite/database/entrez/key.py +44 -0
- biotite/database/entrez/query.py +263 -0
- biotite/database/error.py +16 -0
- biotite/database/pubchem/__init__.py +21 -0
- biotite/database/pubchem/download.py +258 -0
- biotite/database/pubchem/error.py +30 -0
- biotite/database/pubchem/query.py +819 -0
- biotite/database/pubchem/throttle.py +98 -0
- biotite/database/rcsb/__init__.py +13 -0
- biotite/database/rcsb/download.py +161 -0
- biotite/database/rcsb/query.py +963 -0
- biotite/database/uniprot/__init__.py +13 -0
- biotite/database/uniprot/check.py +40 -0
- biotite/database/uniprot/download.py +126 -0
- biotite/database/uniprot/query.py +292 -0
- biotite/file.py +244 -0
- biotite/interface/__init__.py +19 -0
- biotite/interface/openmm/__init__.py +20 -0
- biotite/interface/openmm/state.py +93 -0
- biotite/interface/openmm/system.py +227 -0
- biotite/interface/pymol/__init__.py +201 -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 +1228 -0
- biotite/interface/pymol/shapes.py +178 -0
- biotite/interface/pymol/startup.py +169 -0
- biotite/interface/rdkit/__init__.py +19 -0
- biotite/interface/rdkit/mol.py +490 -0
- biotite/interface/version.py +94 -0
- biotite/interface/warning.py +19 -0
- biotite/sequence/__init__.py +84 -0
- biotite/sequence/align/__init__.py +199 -0
- biotite/sequence/align/alignment.py +702 -0
- biotite/sequence/align/banded.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/banded.pyx +652 -0
- biotite/sequence/align/buckets.py +71 -0
- biotite/sequence/align/cigar.py +425 -0
- biotite/sequence/align/kmeralphabet.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmeralphabet.pyx +595 -0
- biotite/sequence/align/kmersimilarity.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmersimilarity.pyx +233 -0
- biotite/sequence/align/kmertable.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmertable.pyx +3411 -0
- biotite/sequence/align/localgapped.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/localgapped.pyx +892 -0
- biotite/sequence/align/localungapped.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/localungapped.pyx +279 -0
- biotite/sequence/align/matrix.py +631 -0
- biotite/sequence/align/matrix_data/3Di.mat +24 -0
- biotite/sequence/align/matrix_data/BLOSUM100.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM30.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM35.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM40.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM45.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM50.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM50_13p.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM50_14.3.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM50_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM55.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM60.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM62.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM62_13p.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM62_14.3.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM62_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM65.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM70.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM75.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM80.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM85.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM90.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUMN.mat +31 -0
- biotite/sequence/align/matrix_data/CorBLOSUM49_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/CorBLOSUM57_13p.mat +25 -0
- biotite/sequence/align/matrix_data/CorBLOSUM57_14.3.mat +25 -0
- biotite/sequence/align/matrix_data/CorBLOSUM61_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/CorBLOSUM66_13p.mat +25 -0
- biotite/sequence/align/matrix_data/CorBLOSUM67_14.3.mat +25 -0
- biotite/sequence/align/matrix_data/DAYHOFF.mat +32 -0
- biotite/sequence/align/matrix_data/GONNET.mat +26 -0
- biotite/sequence/align/matrix_data/IDENTITY.mat +25 -0
- biotite/sequence/align/matrix_data/MATCH.mat +25 -0
- biotite/sequence/align/matrix_data/NUC.mat +25 -0
- biotite/sequence/align/matrix_data/PAM10.mat +34 -0
- biotite/sequence/align/matrix_data/PAM100.mat +34 -0
- biotite/sequence/align/matrix_data/PAM110.mat +34 -0
- biotite/sequence/align/matrix_data/PAM120.mat +34 -0
- biotite/sequence/align/matrix_data/PAM130.mat +34 -0
- biotite/sequence/align/matrix_data/PAM140.mat +34 -0
- biotite/sequence/align/matrix_data/PAM150.mat +34 -0
- biotite/sequence/align/matrix_data/PAM160.mat +34 -0
- biotite/sequence/align/matrix_data/PAM170.mat +34 -0
- biotite/sequence/align/matrix_data/PAM180.mat +34 -0
- biotite/sequence/align/matrix_data/PAM190.mat +34 -0
- biotite/sequence/align/matrix_data/PAM20.mat +34 -0
- biotite/sequence/align/matrix_data/PAM200.mat +34 -0
- biotite/sequence/align/matrix_data/PAM210.mat +34 -0
- biotite/sequence/align/matrix_data/PAM220.mat +34 -0
- biotite/sequence/align/matrix_data/PAM230.mat +34 -0
- biotite/sequence/align/matrix_data/PAM240.mat +34 -0
- biotite/sequence/align/matrix_data/PAM250.mat +34 -0
- biotite/sequence/align/matrix_data/PAM260.mat +34 -0
- biotite/sequence/align/matrix_data/PAM270.mat +34 -0
- biotite/sequence/align/matrix_data/PAM280.mat +34 -0
- biotite/sequence/align/matrix_data/PAM290.mat +34 -0
- biotite/sequence/align/matrix_data/PAM30.mat +34 -0
- biotite/sequence/align/matrix_data/PAM300.mat +34 -0
- biotite/sequence/align/matrix_data/PAM310.mat +34 -0
- biotite/sequence/align/matrix_data/PAM320.mat +34 -0
- biotite/sequence/align/matrix_data/PAM330.mat +34 -0
- biotite/sequence/align/matrix_data/PAM340.mat +34 -0
- biotite/sequence/align/matrix_data/PAM350.mat +34 -0
- biotite/sequence/align/matrix_data/PAM360.mat +34 -0
- biotite/sequence/align/matrix_data/PAM370.mat +34 -0
- biotite/sequence/align/matrix_data/PAM380.mat +34 -0
- biotite/sequence/align/matrix_data/PAM390.mat +34 -0
- biotite/sequence/align/matrix_data/PAM40.mat +34 -0
- biotite/sequence/align/matrix_data/PAM400.mat +34 -0
- biotite/sequence/align/matrix_data/PAM410.mat +34 -0
- biotite/sequence/align/matrix_data/PAM420.mat +34 -0
- biotite/sequence/align/matrix_data/PAM430.mat +34 -0
- biotite/sequence/align/matrix_data/PAM440.mat +34 -0
- biotite/sequence/align/matrix_data/PAM450.mat +34 -0
- biotite/sequence/align/matrix_data/PAM460.mat +34 -0
- biotite/sequence/align/matrix_data/PAM470.mat +34 -0
- biotite/sequence/align/matrix_data/PAM480.mat +34 -0
- biotite/sequence/align/matrix_data/PAM490.mat +34 -0
- biotite/sequence/align/matrix_data/PAM50.mat +34 -0
- biotite/sequence/align/matrix_data/PAM500.mat +34 -0
- biotite/sequence/align/matrix_data/PAM60.mat +34 -0
- biotite/sequence/align/matrix_data/PAM70.mat +34 -0
- biotite/sequence/align/matrix_data/PAM80.mat +34 -0
- biotite/sequence/align/matrix_data/PAM90.mat +34 -0
- biotite/sequence/align/matrix_data/PB.license +21 -0
- biotite/sequence/align/matrix_data/PB.mat +18 -0
- biotite/sequence/align/matrix_data/RBLOSUM52_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/RBLOSUM59_13p.mat +25 -0
- biotite/sequence/align/matrix_data/RBLOSUM59_14.3.mat +25 -0
- biotite/sequence/align/matrix_data/RBLOSUM64_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/RBLOSUM69_13p.mat +25 -0
- biotite/sequence/align/matrix_data/RBLOSUM69_14.3.mat +25 -0
- biotite/sequence/align/multiple.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/multiple.pyx +619 -0
- biotite/sequence/align/pairwise.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/pairwise.pyx +585 -0
- biotite/sequence/align/permutation.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/permutation.pyx +313 -0
- biotite/sequence/align/primes.txt +821 -0
- biotite/sequence/align/selector.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/selector.pyx +954 -0
- biotite/sequence/align/statistics.py +264 -0
- biotite/sequence/align/tracetable.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/tracetable.pxd +64 -0
- biotite/sequence/align/tracetable.pyx +370 -0
- biotite/sequence/alphabet.py +555 -0
- biotite/sequence/annotation.py +836 -0
- biotite/sequence/codec.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/codec.pyx +155 -0
- biotite/sequence/codon.py +476 -0
- biotite/sequence/codon_tables.txt +202 -0
- biotite/sequence/graphics/__init__.py +33 -0
- biotite/sequence/graphics/alignment.py +1101 -0
- biotite/sequence/graphics/color_schemes/3di_flower.json +48 -0
- biotite/sequence/graphics/color_schemes/autumn.json +51 -0
- biotite/sequence/graphics/color_schemes/blossom.json +51 -0
- biotite/sequence/graphics/color_schemes/clustalx_dna.json +11 -0
- biotite/sequence/graphics/color_schemes/clustalx_protein.json +28 -0
- biotite/sequence/graphics/color_schemes/flower.json +51 -0
- biotite/sequence/graphics/color_schemes/jalview_buried.json +31 -0
- biotite/sequence/graphics/color_schemes/jalview_hydrophobicity.json +31 -0
- biotite/sequence/graphics/color_schemes/jalview_prop_helix.json +31 -0
- biotite/sequence/graphics/color_schemes/jalview_prop_strand.json +31 -0
- biotite/sequence/graphics/color_schemes/jalview_prop_turn.json +31 -0
- biotite/sequence/graphics/color_schemes/jalview_taylor.json +28 -0
- biotite/sequence/graphics/color_schemes/jalview_zappo.json +28 -0
- biotite/sequence/graphics/color_schemes/ocean.json +51 -0
- biotite/sequence/graphics/color_schemes/pb_flower.json +40 -0
- biotite/sequence/graphics/color_schemes/rainbow_dna.json +11 -0
- biotite/sequence/graphics/color_schemes/rainbow_protein.json +30 -0
- biotite/sequence/graphics/color_schemes/spring.json +51 -0
- biotite/sequence/graphics/color_schemes/sunset.json +51 -0
- biotite/sequence/graphics/color_schemes/wither.json +51 -0
- biotite/sequence/graphics/colorschemes.py +170 -0
- biotite/sequence/graphics/dendrogram.py +231 -0
- biotite/sequence/graphics/features.py +544 -0
- biotite/sequence/graphics/logo.py +102 -0
- biotite/sequence/graphics/plasmid.py +712 -0
- biotite/sequence/io/__init__.py +12 -0
- biotite/sequence/io/fasta/__init__.py +22 -0
- biotite/sequence/io/fasta/convert.py +283 -0
- biotite/sequence/io/fasta/file.py +265 -0
- biotite/sequence/io/fastq/__init__.py +19 -0
- biotite/sequence/io/fastq/convert.py +117 -0
- biotite/sequence/io/fastq/file.py +507 -0
- biotite/sequence/io/genbank/__init__.py +17 -0
- biotite/sequence/io/genbank/annotation.py +269 -0
- biotite/sequence/io/genbank/file.py +573 -0
- biotite/sequence/io/genbank/metadata.py +336 -0
- biotite/sequence/io/genbank/sequence.py +173 -0
- biotite/sequence/io/general.py +201 -0
- biotite/sequence/io/gff/__init__.py +26 -0
- biotite/sequence/io/gff/convert.py +128 -0
- biotite/sequence/io/gff/file.py +449 -0
- biotite/sequence/phylo/__init__.py +36 -0
- biotite/sequence/phylo/nj.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/phylo/nj.pyx +221 -0
- biotite/sequence/phylo/tree.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/phylo/tree.pyx +1169 -0
- biotite/sequence/phylo/upgma.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/phylo/upgma.pyx +164 -0
- biotite/sequence/profile.py +561 -0
- biotite/sequence/search.py +117 -0
- biotite/sequence/seqtypes.py +720 -0
- biotite/sequence/sequence.py +373 -0
- biotite/setup_ccd.py +197 -0
- biotite/structure/__init__.py +135 -0
- 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 +1562 -0
- biotite/structure/basepairs.py +1403 -0
- biotite/structure/bonds.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/bonds.pyx +2036 -0
- biotite/structure/box.py +724 -0
- biotite/structure/celllist.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/celllist.pyx +864 -0
- biotite/structure/chains.py +310 -0
- biotite/structure/charges.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/charges.pyx +520 -0
- biotite/structure/compare.py +683 -0
- biotite/structure/density.py +109 -0
- biotite/structure/dotbracket.py +213 -0
- biotite/structure/error.py +39 -0
- biotite/structure/filter.py +591 -0
- biotite/structure/geometry.py +817 -0
- biotite/structure/graphics/__init__.py +13 -0
- biotite/structure/graphics/atoms.py +243 -0
- biotite/structure/graphics/rna.py +298 -0
- biotite/structure/hbond.py +425 -0
- biotite/structure/info/__init__.py +24 -0
- biotite/structure/info/atom_masses.json +121 -0
- biotite/structure/info/atoms.py +98 -0
- biotite/structure/info/bonds.py +149 -0
- biotite/structure/info/ccd.py +200 -0
- biotite/structure/info/components.bcif +0 -0
- biotite/structure/info/groups.py +128 -0
- biotite/structure/info/masses.py +121 -0
- biotite/structure/info/misc.py +137 -0
- biotite/structure/info/radii.py +267 -0
- biotite/structure/info/standardize.py +185 -0
- biotite/structure/integrity.py +213 -0
- biotite/structure/io/__init__.py +29 -0
- biotite/structure/io/dcd/__init__.py +13 -0
- biotite/structure/io/dcd/file.py +67 -0
- biotite/structure/io/general.py +243 -0
- biotite/structure/io/gro/__init__.py +14 -0
- biotite/structure/io/gro/file.py +343 -0
- biotite/structure/io/mol/__init__.py +20 -0
- biotite/structure/io/mol/convert.py +112 -0
- biotite/structure/io/mol/ctab.py +420 -0
- biotite/structure/io/mol/header.py +120 -0
- biotite/structure/io/mol/mol.py +149 -0
- biotite/structure/io/mol/sdf.py +940 -0
- biotite/structure/io/netcdf/__init__.py +13 -0
- biotite/structure/io/netcdf/file.py +64 -0
- biotite/structure/io/pdb/__init__.py +20 -0
- biotite/structure/io/pdb/convert.py +389 -0
- biotite/structure/io/pdb/file.py +1380 -0
- biotite/structure/io/pdb/hybrid36.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/io/pdb/hybrid36.pyx +242 -0
- biotite/structure/io/pdbqt/__init__.py +15 -0
- biotite/structure/io/pdbqt/convert.py +113 -0
- biotite/structure/io/pdbqt/file.py +688 -0
- biotite/structure/io/pdbx/__init__.py +23 -0
- biotite/structure/io/pdbx/bcif.py +674 -0
- biotite/structure/io/pdbx/cif.py +1091 -0
- biotite/structure/io/pdbx/component.py +251 -0
- biotite/structure/io/pdbx/compress.py +362 -0
- biotite/structure/io/pdbx/convert.py +2113 -0
- biotite/structure/io/pdbx/encoding.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/io/pdbx/encoding.pyx +1078 -0
- biotite/structure/io/trajfile.py +696 -0
- biotite/structure/io/trr/__init__.py +13 -0
- biotite/structure/io/trr/file.py +43 -0
- biotite/structure/io/util.py +38 -0
- biotite/structure/io/xtc/__init__.py +13 -0
- biotite/structure/io/xtc/file.py +43 -0
- biotite/structure/mechanics.py +72 -0
- biotite/structure/molecules.py +337 -0
- biotite/structure/pseudoknots.py +622 -0
- biotite/structure/rdf.py +245 -0
- biotite/structure/repair.py +302 -0
- biotite/structure/residues.py +716 -0
- biotite/structure/rings.py +451 -0
- biotite/structure/sasa.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/sasa.pyx +322 -0
- biotite/structure/segments.py +328 -0
- biotite/structure/sequence.py +110 -0
- biotite/structure/spacegroups.json +1567 -0
- biotite/structure/spacegroups.license +26 -0
- biotite/structure/sse.py +306 -0
- biotite/structure/superimpose.py +511 -0
- biotite/structure/tm.py +581 -0
- biotite/structure/transform.py +736 -0
- biotite/structure/util.py +160 -0
- biotite/version.py +34 -0
- biotite/visualize.py +375 -0
- biotite-1.5.0.dist-info/METADATA +162 -0
- biotite-1.5.0.dist-info/RECORD +354 -0
- biotite-1.5.0.dist-info/WHEEL +6 -0
- biotite-1.5.0.dist-info/licenses/LICENSE.rst +30 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This source code is part of the Biotite package and is distributed
|
|
2
|
+
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
|
|
3
|
+
# information.
|
|
4
|
+
|
|
5
|
+
__name__ = "biotite.structure.io.trr"
|
|
6
|
+
__author__ = "Patrick Kunzmann"
|
|
7
|
+
__all__ = ["TRRFile"]
|
|
8
|
+
|
|
9
|
+
import biotraj
|
|
10
|
+
import numpy as np
|
|
11
|
+
from biotite.structure.io.trajfile import TrajectoryFile
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TRRFile(TrajectoryFile):
|
|
15
|
+
"""
|
|
16
|
+
This file class represents a TRR trajectory file.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def traj_type(cls):
|
|
21
|
+
return biotraj.TRRTrajectoryFile
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def process_read_values(cls, read_values):
|
|
25
|
+
# nm to Angstrom
|
|
26
|
+
coord = read_values[0] * 10
|
|
27
|
+
box = read_values[3]
|
|
28
|
+
if box is not None:
|
|
29
|
+
box *= 10
|
|
30
|
+
time = read_values[1]
|
|
31
|
+
return coord, box, time
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def prepare_write_values(cls, coord, box, time):
|
|
35
|
+
# Angstrom to nm
|
|
36
|
+
xyz = np.divide(coord, 10, dtype=np.float32) if coord is not None else None
|
|
37
|
+
time = time.astype(np.float32, copy=False) if time is not None else None
|
|
38
|
+
box = np.divide(box, 10, dtype=np.float32) if box is not None else None
|
|
39
|
+
return {
|
|
40
|
+
"xyz": xyz,
|
|
41
|
+
"box": box,
|
|
42
|
+
"time": time,
|
|
43
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# This source code is part of the Biotite package and is distributed
|
|
2
|
+
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
|
|
3
|
+
# information.
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Common functions used by a number of subpackages.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__name__ = "biotite.structure.io"
|
|
10
|
+
__author__ = "Patrick Kunzmann"
|
|
11
|
+
__all__ = ["number_of_integer_digits"]
|
|
12
|
+
|
|
13
|
+
import numpy as np
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def number_of_integer_digits(values):
|
|
17
|
+
"""
|
|
18
|
+
Get the maximum number of characters needed to represent the
|
|
19
|
+
pre-decimal positions of the given numeric values.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
values : ndarray, dtype=float
|
|
24
|
+
The values to be checked.
|
|
25
|
+
|
|
26
|
+
Returns
|
|
27
|
+
-------
|
|
28
|
+
n_digits : int
|
|
29
|
+
The maximum number of characters needed to represent the
|
|
30
|
+
pre-decimal positions of the given numeric values.
|
|
31
|
+
"""
|
|
32
|
+
if len(values) == 0:
|
|
33
|
+
return 0
|
|
34
|
+
values = values.astype(int, copy=False)
|
|
35
|
+
n_digits = 0
|
|
36
|
+
n_digits = max(n_digits, len(str(np.min(values))))
|
|
37
|
+
n_digits = max(n_digits, len(str(np.max(values))))
|
|
38
|
+
return n_digits
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# This source code is part of the Biotite package and is distributed
|
|
2
|
+
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
|
|
3
|
+
# information.
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
This subpackage is used for reading and writing trajectories in the
|
|
7
|
+
compressed *Gromacs* XTC format.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__name__ = "biotite.structure.io.xtc"
|
|
11
|
+
__author__ = "Patrick Kunzmann"
|
|
12
|
+
|
|
13
|
+
from .file import *
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This source code is part of the Biotite package and is distributed
|
|
2
|
+
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
|
|
3
|
+
# information.
|
|
4
|
+
|
|
5
|
+
__name__ = "biotite.structure.io.xtc"
|
|
6
|
+
__author__ = "Patrick Kunzmann"
|
|
7
|
+
__all__ = ["XTCFile"]
|
|
8
|
+
|
|
9
|
+
import biotraj
|
|
10
|
+
import numpy as np
|
|
11
|
+
from biotite.structure.io.trajfile import TrajectoryFile
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class XTCFile(TrajectoryFile):
|
|
15
|
+
"""
|
|
16
|
+
This file class represents a XTC trajectory file.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def traj_type(cls):
|
|
21
|
+
return biotraj.XTCTrajectoryFile
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def process_read_values(cls, read_values):
|
|
25
|
+
# nm to Angstrom
|
|
26
|
+
coord = read_values[0] * 10
|
|
27
|
+
box = read_values[3]
|
|
28
|
+
if box is not None:
|
|
29
|
+
box *= 10
|
|
30
|
+
time = read_values[1]
|
|
31
|
+
return coord, box, time
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def prepare_write_values(cls, coord, box, time):
|
|
35
|
+
# Angstrom to nm
|
|
36
|
+
xyz = np.divide(coord, 10, dtype=np.float32) if coord is not None else None
|
|
37
|
+
time = time.astype(np.float32, copy=False) if time is not None else None
|
|
38
|
+
box = np.divide(box, 10, dtype=np.float32) if box is not None else None
|
|
39
|
+
return {
|
|
40
|
+
"xyz": xyz,
|
|
41
|
+
"box": box,
|
|
42
|
+
"time": time,
|
|
43
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# This source code is part of the Biotite package and is distributed
|
|
2
|
+
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
|
|
3
|
+
# information.
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
This module provides functions for calculation of mechanical or
|
|
7
|
+
mass-related properties of a molecular structure.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__name__ = "biotite.structure"
|
|
11
|
+
__author__ = "Patrick Kunzmann"
|
|
12
|
+
__all__ = ["mass_center", "gyration_radius"]
|
|
13
|
+
|
|
14
|
+
import numpy as np
|
|
15
|
+
from biotite.structure.geometry import distance
|
|
16
|
+
from biotite.structure.info.masses import mass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def gyration_radius(array, masses=None):
|
|
20
|
+
"""
|
|
21
|
+
Compute the radius/radii of gyration of an atom array or stack.
|
|
22
|
+
|
|
23
|
+
Parameters
|
|
24
|
+
----------
|
|
25
|
+
array : AtomArray or AtomArrayStack
|
|
26
|
+
The array or stack to calculate the radius/radii of gyration
|
|
27
|
+
for.
|
|
28
|
+
masses : ndarray, optional
|
|
29
|
+
The masses to use for each atom in the input `array`.
|
|
30
|
+
Must have the same length as `array`. By default, the standard
|
|
31
|
+
atomic mass for each element is taken.
|
|
32
|
+
|
|
33
|
+
Returns
|
|
34
|
+
-------
|
|
35
|
+
masses : float or ndarray, dtype=float
|
|
36
|
+
If `array` is an :class:`AtomArray`, the radius of gyration is
|
|
37
|
+
returned as single float.
|
|
38
|
+
If `array` is an :class:`AtomArrayStack`, a :class:`ndarray`
|
|
39
|
+
containing the radii of gyration for every model is returned.
|
|
40
|
+
"""
|
|
41
|
+
if masses is None:
|
|
42
|
+
masses = np.array([mass(element) for element in array.element])
|
|
43
|
+
center = mass_center(array, masses)
|
|
44
|
+
radii = distance(array, center[..., np.newaxis, :])
|
|
45
|
+
inertia_moment = np.sum(masses * radii * radii, axis=-1)
|
|
46
|
+
return np.sqrt(inertia_moment / np.sum(masses))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def mass_center(array, masses=None):
|
|
50
|
+
"""
|
|
51
|
+
Calculate the center(s) of mass of an atom array or stack.
|
|
52
|
+
|
|
53
|
+
Parameters
|
|
54
|
+
----------
|
|
55
|
+
array : AtomArray or AtomArrayStack
|
|
56
|
+
The array or stack to calculate the center(s) of mass for.
|
|
57
|
+
masses : ndarray, optional
|
|
58
|
+
The masses to use for each atom in the input `array`.
|
|
59
|
+
Must have the same length as `array`. By default, the standard
|
|
60
|
+
atomic mass for each element is taken.
|
|
61
|
+
|
|
62
|
+
Returns
|
|
63
|
+
-------
|
|
64
|
+
radius : ndarray, ndarray, dtype=float
|
|
65
|
+
Array containing the the coordinates of the center of mass.
|
|
66
|
+
If `array` is an :class:`AtomArray`, this will be an length 3
|
|
67
|
+
:class:`ndarray`; if it is an :class:`AtomArrayStack` with *n* models,
|
|
68
|
+
a (*n x 3*) :class:`ndarray` is returned.
|
|
69
|
+
"""
|
|
70
|
+
if masses is None:
|
|
71
|
+
masses = np.array([mass(element) for element in array.element])
|
|
72
|
+
return np.sum(masses[:, np.newaxis] * array.coord, axis=-2) / np.sum(masses)
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
# This source code is part of the Biotite package and is distributed
|
|
2
|
+
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
|
|
3
|
+
# information.
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
This module provides utility for separating structures into single
|
|
7
|
+
molecules.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__name__ = "biotite.structure"
|
|
11
|
+
__author__ = "Patrick Kunzmann"
|
|
12
|
+
__all__ = ["get_molecule_indices", "get_molecule_masks", "molecule_iter"]
|
|
13
|
+
|
|
14
|
+
import numpy as np
|
|
15
|
+
from biotite.structure.atoms import AtomArray, AtomArrayStack
|
|
16
|
+
from biotite.structure.bonds import BondList, find_connected
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_molecule_indices(array):
|
|
20
|
+
"""
|
|
21
|
+
Get an index array for each molecule in the given structure.
|
|
22
|
+
|
|
23
|
+
A molecule is defined as a group of atoms that are directly or
|
|
24
|
+
indirectly connected via covalent bonds.
|
|
25
|
+
In this function a single atom, that has no connection to any other
|
|
26
|
+
atom (e.g. an ion), also qualifies as a molecule.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
array : AtomArray or AtomArrayStack or BondList
|
|
31
|
+
The input structure with an associated :class:`BondList`.
|
|
32
|
+
Alternatively, the :class:`BondList` can be directly supplied.
|
|
33
|
+
|
|
34
|
+
Returns
|
|
35
|
+
-------
|
|
36
|
+
indices : list of ndarray, dtype=int
|
|
37
|
+
Each element in the list is an index array referring to the
|
|
38
|
+
atoms of a single molecule.
|
|
39
|
+
Consequently, the length of this list is equal to the number of
|
|
40
|
+
molecules in the input `array`.
|
|
41
|
+
|
|
42
|
+
Examples
|
|
43
|
+
--------
|
|
44
|
+
Get an :class:`AtomArray` for ATP and show that it is a single
|
|
45
|
+
molecule:
|
|
46
|
+
|
|
47
|
+
>>> atp = residue("ATP")
|
|
48
|
+
>>> indices = get_molecule_indices(atp)
|
|
49
|
+
>>> print(len(indices))
|
|
50
|
+
1
|
|
51
|
+
|
|
52
|
+
Separate ATP into two molecules by breaking the glycosidic bond
|
|
53
|
+
to the triphosphate:
|
|
54
|
+
|
|
55
|
+
>>> i, j = np.where(np.isin(atp.atom_name, ("O5'", "PA")))[0]
|
|
56
|
+
>>> atp.bonds.remove_bond(i, j)
|
|
57
|
+
>>> indices = get_molecule_indices(atp)
|
|
58
|
+
>>> print(len(indices))
|
|
59
|
+
2
|
|
60
|
+
>>> print(atp[indices[0]])
|
|
61
|
+
HET 0 ATP PG P 1.200 -0.226 -6.850
|
|
62
|
+
HET 0 ATP O1G O 1.740 1.140 -6.672
|
|
63
|
+
HET 0 ATP O2G O 2.123 -1.036 -7.891
|
|
64
|
+
HET 0 ATP O3G O -0.302 -0.139 -7.421
|
|
65
|
+
HET 0 ATP PB P 0.255 -0.130 -4.446
|
|
66
|
+
HET 0 ATP O1B O 0.810 1.234 -4.304
|
|
67
|
+
HET 0 ATP O2B O -1.231 -0.044 -5.057
|
|
68
|
+
HET 0 ATP O3B O 1.192 -0.990 -5.433
|
|
69
|
+
HET 0 ATP PA P -0.745 0.068 -2.071
|
|
70
|
+
HET 0 ATP O1A O -2.097 0.143 -2.669
|
|
71
|
+
HET 0 ATP O2A O -0.125 1.549 -1.957
|
|
72
|
+
HET 0 ATP O3A O 0.203 -0.840 -3.002
|
|
73
|
+
HET 0 ATP HOG2 H 2.100 -0.546 -8.725
|
|
74
|
+
HET 0 ATP HOG3 H -0.616 -1.048 -7.522
|
|
75
|
+
HET 0 ATP HOB2 H -1.554 -0.952 -5.132
|
|
76
|
+
HET 0 ATP HOA2 H 0.752 1.455 -1.563
|
|
77
|
+
>>> print(atp[indices[1]])
|
|
78
|
+
HET 0 ATP O5' O -0.844 -0.587 -0.604
|
|
79
|
+
HET 0 ATP C5' C -1.694 0.260 0.170
|
|
80
|
+
HET 0 ATP C4' C -1.831 -0.309 1.584
|
|
81
|
+
HET 0 ATP O4' O -0.542 -0.355 2.234
|
|
82
|
+
HET 0 ATP C3' C -2.683 0.630 2.465
|
|
83
|
+
HET 0 ATP O3' O -4.033 0.165 2.534
|
|
84
|
+
HET 0 ATP C2' C -2.011 0.555 3.856
|
|
85
|
+
HET 0 ATP O2' O -2.926 0.043 4.827
|
|
86
|
+
HET 0 ATP C1' C -0.830 -0.418 3.647
|
|
87
|
+
HET 0 ATP N9 N 0.332 0.015 4.425
|
|
88
|
+
HET 0 ATP C8 C 1.302 0.879 4.012
|
|
89
|
+
HET 0 ATP N7 N 2.184 1.042 4.955
|
|
90
|
+
HET 0 ATP C5 C 1.833 0.300 6.033
|
|
91
|
+
HET 0 ATP C6 C 2.391 0.077 7.303
|
|
92
|
+
HET 0 ATP N6 N 3.564 0.706 7.681
|
|
93
|
+
HET 0 ATP N1 N 1.763 -0.747 8.135
|
|
94
|
+
HET 0 ATP C2 C 0.644 -1.352 7.783
|
|
95
|
+
HET 0 ATP N3 N 0.088 -1.178 6.602
|
|
96
|
+
HET 0 ATP C4 C 0.644 -0.371 5.704
|
|
97
|
+
HET 0 ATP H5'1 H -2.678 0.312 -0.296
|
|
98
|
+
HET 0 ATP H5'2 H -1.263 1.259 0.221
|
|
99
|
+
HET 0 ATP H4' H -2.275 -1.304 1.550
|
|
100
|
+
HET 0 ATP H3' H -2.651 1.649 2.078
|
|
101
|
+
HET 0 ATP HO3' H -4.515 0.788 3.094
|
|
102
|
+
HET 0 ATP H2' H -1.646 1.537 4.157
|
|
103
|
+
HET 0 ATP HO2' H -3.667 0.662 4.867
|
|
104
|
+
HET 0 ATP H1' H -1.119 -1.430 3.931
|
|
105
|
+
HET 0 ATP H8 H 1.334 1.357 3.044
|
|
106
|
+
HET 0 ATP HN61 H 3.938 0.548 8.562
|
|
107
|
+
HET 0 ATP HN62 H 4.015 1.303 7.064
|
|
108
|
+
HET 0 ATP H2 H 0.166 -2.014 8.490
|
|
109
|
+
"""
|
|
110
|
+
if isinstance(array, BondList):
|
|
111
|
+
bonds = array
|
|
112
|
+
elif isinstance(array, (AtomArray, AtomArrayStack)):
|
|
113
|
+
if array.bonds is None:
|
|
114
|
+
raise ValueError("An associated BondList is required")
|
|
115
|
+
bonds = array.bonds
|
|
116
|
+
else:
|
|
117
|
+
raise TypeError(
|
|
118
|
+
f"Expected a 'BondList', 'AtomArray' or 'AtomArrayStack', "
|
|
119
|
+
f"not '{type(array).__name__}'"
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
molecule_indices = []
|
|
123
|
+
visited_mask = np.zeros(bonds.get_atom_count(), dtype=bool)
|
|
124
|
+
while not visited_mask.all():
|
|
125
|
+
root = np.argmin(visited_mask)
|
|
126
|
+
connected = find_connected(bonds, root)
|
|
127
|
+
visited_mask[connected] = True
|
|
128
|
+
molecule_indices.append(connected)
|
|
129
|
+
return molecule_indices
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def get_molecule_masks(array):
|
|
133
|
+
"""
|
|
134
|
+
Get a boolean mask for each molecule in the given structure.
|
|
135
|
+
|
|
136
|
+
A molecule is defined as a group of atoms that are directly or
|
|
137
|
+
indirectly connected via covalent bonds.
|
|
138
|
+
In this function a single atom, that has no connection to any other
|
|
139
|
+
atom (e.g. an ion), also qualifies as a molecule.
|
|
140
|
+
|
|
141
|
+
Parameters
|
|
142
|
+
----------
|
|
143
|
+
array : AtomArray, shape=(n,) or AtomArrayStack, shape=(m,n) or BondList
|
|
144
|
+
The input structure with an associated :class:`BondList`.
|
|
145
|
+
Alternatively, the :class:`BondList` can be directly supplied.
|
|
146
|
+
|
|
147
|
+
Returns
|
|
148
|
+
-------
|
|
149
|
+
masks : ndarray, shape=(k,n), dtype=bool,
|
|
150
|
+
Each element in the array is a boolean mask referring to the
|
|
151
|
+
atoms of a single molecule.
|
|
152
|
+
Consequently, the length of this list is equal to the number of
|
|
153
|
+
molecules in the input `array`.
|
|
154
|
+
|
|
155
|
+
Examples
|
|
156
|
+
--------
|
|
157
|
+
Get an :class:`AtomArray` for ATP and show that it is a single
|
|
158
|
+
molecule:
|
|
159
|
+
|
|
160
|
+
>>> atp = residue("ATP")
|
|
161
|
+
>>> masks = get_molecule_masks(atp)
|
|
162
|
+
>>> print(len(masks))
|
|
163
|
+
1
|
|
164
|
+
|
|
165
|
+
Separate ATP into two molecules by breaking the glycosidic bond
|
|
166
|
+
to the triphosphate:
|
|
167
|
+
|
|
168
|
+
>>> i, j = np.where(np.isin(atp.atom_name, ("O5'", "PA")))[0]
|
|
169
|
+
>>> atp.bonds.remove_bond(i, j)
|
|
170
|
+
>>> masks = get_molecule_masks(atp)
|
|
171
|
+
>>> print(len(masks))
|
|
172
|
+
2
|
|
173
|
+
>>> print(atp[masks[0]])
|
|
174
|
+
HET 0 ATP PG P 1.200 -0.226 -6.850
|
|
175
|
+
HET 0 ATP O1G O 1.740 1.140 -6.672
|
|
176
|
+
HET 0 ATP O2G O 2.123 -1.036 -7.891
|
|
177
|
+
HET 0 ATP O3G O -0.302 -0.139 -7.421
|
|
178
|
+
HET 0 ATP PB P 0.255 -0.130 -4.446
|
|
179
|
+
HET 0 ATP O1B O 0.810 1.234 -4.304
|
|
180
|
+
HET 0 ATP O2B O -1.231 -0.044 -5.057
|
|
181
|
+
HET 0 ATP O3B O 1.192 -0.990 -5.433
|
|
182
|
+
HET 0 ATP PA P -0.745 0.068 -2.071
|
|
183
|
+
HET 0 ATP O1A O -2.097 0.143 -2.669
|
|
184
|
+
HET 0 ATP O2A O -0.125 1.549 -1.957
|
|
185
|
+
HET 0 ATP O3A O 0.203 -0.840 -3.002
|
|
186
|
+
HET 0 ATP HOG2 H 2.100 -0.546 -8.725
|
|
187
|
+
HET 0 ATP HOG3 H -0.616 -1.048 -7.522
|
|
188
|
+
HET 0 ATP HOB2 H -1.554 -0.952 -5.132
|
|
189
|
+
HET 0 ATP HOA2 H 0.752 1.455 -1.563
|
|
190
|
+
>>> print(atp[masks[1]])
|
|
191
|
+
HET 0 ATP O5' O -0.844 -0.587 -0.604
|
|
192
|
+
HET 0 ATP C5' C -1.694 0.260 0.170
|
|
193
|
+
HET 0 ATP C4' C -1.831 -0.309 1.584
|
|
194
|
+
HET 0 ATP O4' O -0.542 -0.355 2.234
|
|
195
|
+
HET 0 ATP C3' C -2.683 0.630 2.465
|
|
196
|
+
HET 0 ATP O3' O -4.033 0.165 2.534
|
|
197
|
+
HET 0 ATP C2' C -2.011 0.555 3.856
|
|
198
|
+
HET 0 ATP O2' O -2.926 0.043 4.827
|
|
199
|
+
HET 0 ATP C1' C -0.830 -0.418 3.647
|
|
200
|
+
HET 0 ATP N9 N 0.332 0.015 4.425
|
|
201
|
+
HET 0 ATP C8 C 1.302 0.879 4.012
|
|
202
|
+
HET 0 ATP N7 N 2.184 1.042 4.955
|
|
203
|
+
HET 0 ATP C5 C 1.833 0.300 6.033
|
|
204
|
+
HET 0 ATP C6 C 2.391 0.077 7.303
|
|
205
|
+
HET 0 ATP N6 N 3.564 0.706 7.681
|
|
206
|
+
HET 0 ATP N1 N 1.763 -0.747 8.135
|
|
207
|
+
HET 0 ATP C2 C 0.644 -1.352 7.783
|
|
208
|
+
HET 0 ATP N3 N 0.088 -1.178 6.602
|
|
209
|
+
HET 0 ATP C4 C 0.644 -0.371 5.704
|
|
210
|
+
HET 0 ATP H5'1 H -2.678 0.312 -0.296
|
|
211
|
+
HET 0 ATP H5'2 H -1.263 1.259 0.221
|
|
212
|
+
HET 0 ATP H4' H -2.275 -1.304 1.550
|
|
213
|
+
HET 0 ATP H3' H -2.651 1.649 2.078
|
|
214
|
+
HET 0 ATP HO3' H -4.515 0.788 3.094
|
|
215
|
+
HET 0 ATP H2' H -1.646 1.537 4.157
|
|
216
|
+
HET 0 ATP HO2' H -3.667 0.662 4.867
|
|
217
|
+
HET 0 ATP H1' H -1.119 -1.430 3.931
|
|
218
|
+
HET 0 ATP H8 H 1.334 1.357 3.044
|
|
219
|
+
HET 0 ATP HN61 H 3.938 0.548 8.562
|
|
220
|
+
HET 0 ATP HN62 H 4.015 1.303 7.064
|
|
221
|
+
HET 0 ATP H2 H 0.166 -2.014 8.490
|
|
222
|
+
"""
|
|
223
|
+
if isinstance(array, BondList):
|
|
224
|
+
bonds = array
|
|
225
|
+
elif isinstance(array, (AtomArray, AtomArrayStack)):
|
|
226
|
+
if array.bonds is None:
|
|
227
|
+
raise ValueError("An associated BondList is required")
|
|
228
|
+
bonds = array.bonds
|
|
229
|
+
else:
|
|
230
|
+
raise TypeError(
|
|
231
|
+
f"Expected a 'BondList', 'AtomArray' or 'AtomArrayStack', "
|
|
232
|
+
f"not '{type(array).__name__}'"
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
molecule_indices = get_molecule_indices(bonds)
|
|
236
|
+
molecule_masks = np.zeros(
|
|
237
|
+
(len(molecule_indices), bonds.get_atom_count()), dtype=bool
|
|
238
|
+
)
|
|
239
|
+
for i in range(len(molecule_indices)):
|
|
240
|
+
molecule_masks[i, molecule_indices[i]] = True
|
|
241
|
+
return molecule_masks
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def molecule_iter(array):
|
|
245
|
+
"""
|
|
246
|
+
Iterate over each molecule in a input structure.
|
|
247
|
+
|
|
248
|
+
A molecule is defined as a group of atoms that are directly or
|
|
249
|
+
indirectly connected via covalent bonds.
|
|
250
|
+
In this function a single atom, that has no connection to any other
|
|
251
|
+
atom (e.g. an ion), also qualifies as a molecule.
|
|
252
|
+
|
|
253
|
+
Parameters
|
|
254
|
+
----------
|
|
255
|
+
array : AtomArray or AtomArrayStack
|
|
256
|
+
The input structure with an associated :class:`BondList`.
|
|
257
|
+
|
|
258
|
+
Yields
|
|
259
|
+
------
|
|
260
|
+
molecule : AtomArray or AtomArrayStack
|
|
261
|
+
A single molecule of the input `array`.
|
|
262
|
+
|
|
263
|
+
Examples
|
|
264
|
+
--------
|
|
265
|
+
Get an :class:`AtomArray` for ATP and break it into two molecules
|
|
266
|
+
at the glycosidic bond to the triphosphate:
|
|
267
|
+
|
|
268
|
+
>>> atp = residue("ATP")
|
|
269
|
+
>>> i, j = np.where(np.isin(atp.atom_name, ("O5'", "PA")))[0]
|
|
270
|
+
>>> atp.bonds.remove_bond(i, j)
|
|
271
|
+
>>> for molecule in molecule_iter(atp):
|
|
272
|
+
... print("New molecule")
|
|
273
|
+
... print(molecule)
|
|
274
|
+
... print()
|
|
275
|
+
New molecule
|
|
276
|
+
HET 0 ATP PG P 1.200 -0.226 -6.850
|
|
277
|
+
HET 0 ATP O1G O 1.740 1.140 -6.672
|
|
278
|
+
HET 0 ATP O2G O 2.123 -1.036 -7.891
|
|
279
|
+
HET 0 ATP O3G O -0.302 -0.139 -7.421
|
|
280
|
+
HET 0 ATP PB P 0.255 -0.130 -4.446
|
|
281
|
+
HET 0 ATP O1B O 0.810 1.234 -4.304
|
|
282
|
+
HET 0 ATP O2B O -1.231 -0.044 -5.057
|
|
283
|
+
HET 0 ATP O3B O 1.192 -0.990 -5.433
|
|
284
|
+
HET 0 ATP PA P -0.745 0.068 -2.071
|
|
285
|
+
HET 0 ATP O1A O -2.097 0.143 -2.669
|
|
286
|
+
HET 0 ATP O2A O -0.125 1.549 -1.957
|
|
287
|
+
HET 0 ATP O3A O 0.203 -0.840 -3.002
|
|
288
|
+
HET 0 ATP HOG2 H 2.100 -0.546 -8.725
|
|
289
|
+
HET 0 ATP HOG3 H -0.616 -1.048 -7.522
|
|
290
|
+
HET 0 ATP HOB2 H -1.554 -0.952 -5.132
|
|
291
|
+
HET 0 ATP HOA2 H 0.752 1.455 -1.563
|
|
292
|
+
<BLANKLINE>
|
|
293
|
+
New molecule
|
|
294
|
+
HET 0 ATP O5' O -0.844 -0.587 -0.604
|
|
295
|
+
HET 0 ATP C5' C -1.694 0.260 0.170
|
|
296
|
+
HET 0 ATP C4' C -1.831 -0.309 1.584
|
|
297
|
+
HET 0 ATP O4' O -0.542 -0.355 2.234
|
|
298
|
+
HET 0 ATP C3' C -2.683 0.630 2.465
|
|
299
|
+
HET 0 ATP O3' O -4.033 0.165 2.534
|
|
300
|
+
HET 0 ATP C2' C -2.011 0.555 3.856
|
|
301
|
+
HET 0 ATP O2' O -2.926 0.043 4.827
|
|
302
|
+
HET 0 ATP C1' C -0.830 -0.418 3.647
|
|
303
|
+
HET 0 ATP N9 N 0.332 0.015 4.425
|
|
304
|
+
HET 0 ATP C8 C 1.302 0.879 4.012
|
|
305
|
+
HET 0 ATP N7 N 2.184 1.042 4.955
|
|
306
|
+
HET 0 ATP C5 C 1.833 0.300 6.033
|
|
307
|
+
HET 0 ATP C6 C 2.391 0.077 7.303
|
|
308
|
+
HET 0 ATP N6 N 3.564 0.706 7.681
|
|
309
|
+
HET 0 ATP N1 N 1.763 -0.747 8.135
|
|
310
|
+
HET 0 ATP C2 C 0.644 -1.352 7.783
|
|
311
|
+
HET 0 ATP N3 N 0.088 -1.178 6.602
|
|
312
|
+
HET 0 ATP C4 C 0.644 -0.371 5.704
|
|
313
|
+
HET 0 ATP H5'1 H -2.678 0.312 -0.296
|
|
314
|
+
HET 0 ATP H5'2 H -1.263 1.259 0.221
|
|
315
|
+
HET 0 ATP H4' H -2.275 -1.304 1.550
|
|
316
|
+
HET 0 ATP H3' H -2.651 1.649 2.078
|
|
317
|
+
HET 0 ATP HO3' H -4.515 0.788 3.094
|
|
318
|
+
HET 0 ATP H2' H -1.646 1.537 4.157
|
|
319
|
+
HET 0 ATP HO2' H -3.667 0.662 4.867
|
|
320
|
+
HET 0 ATP H1' H -1.119 -1.430 3.931
|
|
321
|
+
HET 0 ATP H8 H 1.334 1.357 3.044
|
|
322
|
+
HET 0 ATP HN61 H 3.938 0.548 8.562
|
|
323
|
+
HET 0 ATP HN62 H 4.015 1.303 7.064
|
|
324
|
+
HET 0 ATP H2 H 0.166 -2.014 8.490
|
|
325
|
+
<BLANKLINE>
|
|
326
|
+
"""
|
|
327
|
+
if array.bonds is None:
|
|
328
|
+
raise ValueError("An associated BondList is required")
|
|
329
|
+
bonds = array.bonds
|
|
330
|
+
|
|
331
|
+
visited_mask = np.zeros(bonds.get_atom_count(), dtype=bool)
|
|
332
|
+
while not visited_mask.all():
|
|
333
|
+
# Take the first atom that has not been considered yet as root
|
|
334
|
+
root = np.argmin(visited_mask)
|
|
335
|
+
connected = find_connected(bonds, root)
|
|
336
|
+
visited_mask[connected] = True
|
|
337
|
+
yield array[..., connected]
|