biotite 1.5.0__cp313-cp313-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-313-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-313-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmeralphabet.pyx +595 -0
- biotite/sequence/align/kmersimilarity.cpython-313-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmersimilarity.pyx +233 -0
- biotite/sequence/align/kmertable.cpython-313-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmertable.pyx +3411 -0
- biotite/sequence/align/localgapped.cpython-313-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/localgapped.pyx +892 -0
- biotite/sequence/align/localungapped.cpython-313-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-313-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/multiple.pyx +619 -0
- biotite/sequence/align/pairwise.cpython-313-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/pairwise.pyx +585 -0
- biotite/sequence/align/permutation.cpython-313-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-313-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-313-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-313-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-313-x86_64-linux-gnu.so +0 -0
- biotite/sequence/phylo/nj.pyx +221 -0
- biotite/sequence/phylo/tree.cpython-313-x86_64-linux-gnu.so +0 -0
- biotite/sequence/phylo/tree.pyx +1169 -0
- biotite/sequence/phylo/upgma.cpython-313-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-313-x86_64-linux-gnu.so +0 -0
- biotite/structure/bonds.pyx +2036 -0
- biotite/structure/box.py +724 -0
- biotite/structure/celllist.cpython-313-x86_64-linux-gnu.so +0 -0
- biotite/structure/celllist.pyx +864 -0
- biotite/structure/chains.py +310 -0
- biotite/structure/charges.cpython-313-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-313-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-313-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-313-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,213 @@
|
|
|
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 allows checking of atom arrays and atom array stacks for
|
|
7
|
+
errors in the structure.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__name__ = "biotite.structure"
|
|
11
|
+
__author__ = "Patrick Kunzmann, Daniel Bauer"
|
|
12
|
+
__all__ = [
|
|
13
|
+
"check_atom_id_continuity",
|
|
14
|
+
"check_res_id_continuity",
|
|
15
|
+
"check_backbone_continuity",
|
|
16
|
+
"check_duplicate_atoms",
|
|
17
|
+
"check_linear_continuity",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
import numpy as np
|
|
21
|
+
from biotite.structure.box import coord_to_fraction
|
|
22
|
+
from biotite.structure.filter import (
|
|
23
|
+
filter_linear_bond_continuity,
|
|
24
|
+
filter_peptide_backbone,
|
|
25
|
+
filter_phosphate_backbone,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _check_continuity(array):
|
|
30
|
+
diff = np.diff(array)
|
|
31
|
+
discontinuity = np.where(((diff != 0) & (diff != 1)))
|
|
32
|
+
return discontinuity[0] + 1
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def check_atom_id_continuity(array):
|
|
36
|
+
"""
|
|
37
|
+
Check if the atom IDs are incremented by more than 1 or
|
|
38
|
+
decremented, from one atom to the next one.
|
|
39
|
+
|
|
40
|
+
An increment by more than 1 is as strong clue for missing atoms.
|
|
41
|
+
|
|
42
|
+
Parameters
|
|
43
|
+
----------
|
|
44
|
+
array : AtomArray or AtomArrayStack
|
|
45
|
+
The array to be checked.
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
discontinuity : ndarray, dtype=int
|
|
50
|
+
Contains the indices of atoms after a discontinuity.
|
|
51
|
+
"""
|
|
52
|
+
ids = array.atom_id
|
|
53
|
+
return _check_continuity(ids)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def check_res_id_continuity(array):
|
|
57
|
+
"""
|
|
58
|
+
Check if the residue IDs are incremented by more than 1 or
|
|
59
|
+
decremented, from one atom to the next one.
|
|
60
|
+
|
|
61
|
+
An increment by more than 1 is as strong clue for missing residues,
|
|
62
|
+
a decrement means probably a start of a new chain.
|
|
63
|
+
|
|
64
|
+
Parameters
|
|
65
|
+
----------
|
|
66
|
+
array : AtomArray or AtomArrayStack
|
|
67
|
+
The array to be checked.
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
discontinuity : ndarray, dtype=int
|
|
72
|
+
Contains the indices of atoms after a discontinuity.
|
|
73
|
+
"""
|
|
74
|
+
ids = array.res_id
|
|
75
|
+
return _check_continuity(ids)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def check_linear_continuity(array, min_len=1.2, max_len=1.8):
|
|
79
|
+
"""
|
|
80
|
+
Check linear (consecutive) bond continuity of atoms in atom array.
|
|
81
|
+
|
|
82
|
+
Parameters
|
|
83
|
+
----------
|
|
84
|
+
array : AtomArray
|
|
85
|
+
Arbitrary structure.
|
|
86
|
+
min_len : float, optional
|
|
87
|
+
Minimum bond length.
|
|
88
|
+
max_len : float, optional
|
|
89
|
+
Maximum bond length.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
discontinuity : ndarray, dtype=int
|
|
94
|
+
Indices of `array` corresponding to atoms where the bond
|
|
95
|
+
with the preceding atom is beyond the provided bounds.
|
|
96
|
+
|
|
97
|
+
See Also
|
|
98
|
+
--------
|
|
99
|
+
filter_linear_bond_continuity : A function to filter for atoms preserving the continuity (used here).
|
|
100
|
+
BondList : A class that doesn't depend on the atoms' order to identify bonds.
|
|
101
|
+
"""
|
|
102
|
+
con_mask = filter_linear_bond_continuity(array, min_len, max_len)
|
|
103
|
+
# The continuity mask `con_mask` points to atoms for which the next atom is continuous.
|
|
104
|
+
# We invert this mask and shift-extend by one from the left.
|
|
105
|
+
# The resulting discontinuity mask points to atoms having the preceding atom exceeding
|
|
106
|
+
# the bond length requirements.
|
|
107
|
+
discon_mask = np.insert(~con_mask[:-1], 0, False)
|
|
108
|
+
return np.where(discon_mask)[0]
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def check_backbone_continuity(array, min_len=1.2, max_len=1.8):
|
|
112
|
+
"""
|
|
113
|
+
Check if the (peptide or phosphate) backbone atoms have
|
|
114
|
+
non-reasonable distance to the next atom.
|
|
115
|
+
|
|
116
|
+
A large or very small distance is a very strong clue, that there is
|
|
117
|
+
no bond between those atoms, therefore the chain is discontinued.
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
array : AtomArray
|
|
122
|
+
The array to be checked.
|
|
123
|
+
min_len, max_len : float, optional
|
|
124
|
+
The interval in which the atom-atom distance is evaluated as
|
|
125
|
+
bond.
|
|
126
|
+
|
|
127
|
+
Returns
|
|
128
|
+
-------
|
|
129
|
+
discontinuity : ndarray, dtype=int
|
|
130
|
+
Contains the indices of atoms after a discontinuity.
|
|
131
|
+
|
|
132
|
+
See Also
|
|
133
|
+
--------
|
|
134
|
+
filter_linear_bond_continuity : A function to filter for atoms preserving the continuity.
|
|
135
|
+
filter_peptide_backbone : A function to filter for peptide backbone atoms.
|
|
136
|
+
filter_phosphate_backbone : A function to filter for phosphate backbone atoms.
|
|
137
|
+
"""
|
|
138
|
+
backbone_mask = filter_peptide_backbone(array) | filter_phosphate_backbone(array)
|
|
139
|
+
con_mask = filter_linear_bond_continuity(array[backbone_mask], min_len, max_len)
|
|
140
|
+
|
|
141
|
+
# See the comments for `check_linear_continuity()`
|
|
142
|
+
discon_mask = np.insert(~con_mask[:-1], 0, False)
|
|
143
|
+
discon_mask_full = np.full_like(backbone_mask, False)
|
|
144
|
+
discon_mask_full[backbone_mask] = discon_mask
|
|
145
|
+
|
|
146
|
+
return np.where(discon_mask_full)[0]
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def check_duplicate_atoms(array):
|
|
150
|
+
"""
|
|
151
|
+
Check if a structure contains duplicate atoms, i.e. two atoms in a
|
|
152
|
+
structure have the same annotations (coordinates may be different).
|
|
153
|
+
|
|
154
|
+
Duplicate atoms may appear, when a structure has occupancy for an
|
|
155
|
+
atom at two or more positions or when the *altloc* positions are
|
|
156
|
+
improperly read.
|
|
157
|
+
|
|
158
|
+
Parameters
|
|
159
|
+
----------
|
|
160
|
+
array : AtomArray or AtomArrayStack
|
|
161
|
+
The array to be checked.
|
|
162
|
+
|
|
163
|
+
Returns
|
|
164
|
+
-------
|
|
165
|
+
duplicate : ndarray, dtype=int
|
|
166
|
+
Contains the indices of duplicate atoms.
|
|
167
|
+
The first occurence of an atom is not counted as duplicate.
|
|
168
|
+
"""
|
|
169
|
+
duplicates = []
|
|
170
|
+
annots = [
|
|
171
|
+
array.get_annotation(category) for category in array.get_annotation_categories()
|
|
172
|
+
]
|
|
173
|
+
for i in range(1, array.array_length()):
|
|
174
|
+
# Start with assumption that all atoms in the array
|
|
175
|
+
# until index i are duplicates of the atom at index i
|
|
176
|
+
is_duplicate = np.full(i, True, dtype=bool)
|
|
177
|
+
for annot in annots:
|
|
178
|
+
# For each annotation array filter out the atoms until
|
|
179
|
+
# index i that have an unequal annotation
|
|
180
|
+
# to the atom at index i
|
|
181
|
+
is_duplicate &= annot[:i] == annot[i]
|
|
182
|
+
# After checking all annotation arrays,
|
|
183
|
+
# if there still is any duplicate to the atom at index i,
|
|
184
|
+
# add i the the list of duplicate atom indices
|
|
185
|
+
if is_duplicate.any():
|
|
186
|
+
duplicates.append(i)
|
|
187
|
+
return np.array(duplicates)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def check_in_box(array):
|
|
191
|
+
r"""
|
|
192
|
+
Check if a structure contains atoms whose position is outside the
|
|
193
|
+
box.
|
|
194
|
+
|
|
195
|
+
Coordinates are outside the box, when they cannot be represented by
|
|
196
|
+
a linear combination of the box vectors with scalar factors
|
|
197
|
+
:math:`0 \le a_i \le 1`.
|
|
198
|
+
|
|
199
|
+
Parameters
|
|
200
|
+
----------
|
|
201
|
+
array : AtomArray or AtomArrayStack
|
|
202
|
+
The array to be checked.
|
|
203
|
+
|
|
204
|
+
Returns
|
|
205
|
+
-------
|
|
206
|
+
outside : ndarray, dtype=int
|
|
207
|
+
Contains the indices of atoms outside the atom array's box.
|
|
208
|
+
"""
|
|
209
|
+
if array.box is None:
|
|
210
|
+
raise TypeError("Structure has no box")
|
|
211
|
+
box = array.box
|
|
212
|
+
fractions = coord_to_fraction(array, box)
|
|
213
|
+
return np.where(((fractions >= 0) & (fractions < 1)).all(axis=-1))[0]
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
A subpackage for reading and writing structure related data.
|
|
7
|
+
|
|
8
|
+
Macromolecular structure files (PDB, PDBx/mmCIF, BinaryCIF, etc.) and
|
|
9
|
+
small molecule files (MOL, SDF, etc.) can be used
|
|
10
|
+
to load an :class:`AtomArray` or :class:`AtomArrayStack`.
|
|
11
|
+
|
|
12
|
+
Since the data model for the :class:`AtomArray` and
|
|
13
|
+
:class:`AtomArrayStack` class does not support duplicate atoms,
|
|
14
|
+
only one *altloc* can be chosen for each atom. Hence, the amount of
|
|
15
|
+
atoms may be lower in the atom array (stack) than in respective
|
|
16
|
+
structure file.
|
|
17
|
+
|
|
18
|
+
The recommended format for reading structure files is *BinaryCIF*.
|
|
19
|
+
It has by far the shortest parsing time and file size.
|
|
20
|
+
|
|
21
|
+
Besides the mentioned structure formats, common trajectory formats can be
|
|
22
|
+
loaded as well.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
__name__ = "biotite.structure.io"
|
|
26
|
+
__author__ = "Patrick Kunzmann"
|
|
27
|
+
|
|
28
|
+
from .general import *
|
|
29
|
+
from .trajfile import *
|
|
@@ -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
|
+
CDC format used by software like *CHARMM*, *OpenMM* and *NAMD*.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__name__ = "biotite.structure.io.dcd"
|
|
11
|
+
__author__ = "Patrick Kunzmann"
|
|
12
|
+
|
|
13
|
+
from .file import *
|
|
@@ -0,0 +1,67 @@
|
|
|
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.dcd"
|
|
6
|
+
__author__ = "Patrick Kunzmann"
|
|
7
|
+
__all__ = ["DCDFile"]
|
|
8
|
+
|
|
9
|
+
import biotraj
|
|
10
|
+
import numpy as np
|
|
11
|
+
from biotite.structure.box import unitcell_from_vectors, vectors_from_unitcell
|
|
12
|
+
from biotite.structure.io.trajfile import TrajectoryFile
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DCDFile(TrajectoryFile):
|
|
16
|
+
"""
|
|
17
|
+
This file class represents a DCD trajectory file.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def traj_type(cls):
|
|
22
|
+
return biotraj.DCDTrajectoryFile
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def process_read_values(cls, read_values):
|
|
26
|
+
# .netcdf files use Angstrom
|
|
27
|
+
coord = read_values[0]
|
|
28
|
+
cell_lengths = read_values[1]
|
|
29
|
+
cell_angles = read_values[2]
|
|
30
|
+
if cell_lengths is None or cell_angles is None:
|
|
31
|
+
box = None
|
|
32
|
+
else:
|
|
33
|
+
box = np.stack(
|
|
34
|
+
[
|
|
35
|
+
vectors_from_unitcell(a, b, c, alpha, beta, gamma)
|
|
36
|
+
for (a, b, c), (alpha, beta, gamma) in zip(
|
|
37
|
+
cell_lengths, np.deg2rad(cell_angles)
|
|
38
|
+
)
|
|
39
|
+
],
|
|
40
|
+
axis=0,
|
|
41
|
+
)
|
|
42
|
+
return coord, box, None
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def prepare_write_values(cls, coord, box, time):
|
|
46
|
+
xyz = coord.astype(np.float32, copy=False) if coord is not None else None
|
|
47
|
+
if box is None:
|
|
48
|
+
cell_lengths = None
|
|
49
|
+
cell_angles = None
|
|
50
|
+
else:
|
|
51
|
+
cell_lengths = np.zeros((len(box), 3), dtype=np.float32)
|
|
52
|
+
cell_angles = np.zeros((len(box), 3), dtype=np.float32)
|
|
53
|
+
for i, model_box in enumerate(box):
|
|
54
|
+
a, b, c, alpha, beta, gamma = unitcell_from_vectors(model_box)
|
|
55
|
+
cell_lengths[i] = np.array((a, b, c))
|
|
56
|
+
cell_angles[i] = np.rad2deg((alpha, beta, gamma))
|
|
57
|
+
return {
|
|
58
|
+
"xyz": xyz,
|
|
59
|
+
"cell_lengths": cell_lengths,
|
|
60
|
+
"cell_angles": cell_angles,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
def set_time(self, time):
|
|
64
|
+
if time is not None:
|
|
65
|
+
raise NotImplementedError(
|
|
66
|
+
"This trajectory file does not support writing simulation time"
|
|
67
|
+
)
|
|
@@ -0,0 +1,243 @@
|
|
|
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 contains a convenience function for loading structures from
|
|
7
|
+
general structure files.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__name__ = "biotite.structure.io"
|
|
11
|
+
__author__ = "Patrick Kunzmann"
|
|
12
|
+
__all__ = ["load_structure", "save_structure"]
|
|
13
|
+
|
|
14
|
+
import datetime
|
|
15
|
+
import io
|
|
16
|
+
import os.path
|
|
17
|
+
from biotite.structure.atoms import AtomArrayStack
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def load_structure(file_path, template=None, **kwargs):
|
|
21
|
+
"""
|
|
22
|
+
Load an :class:`AtomArray` or class`AtomArrayStack` from a structure
|
|
23
|
+
file without the need to manually instantiate a :class:`File`
|
|
24
|
+
object.
|
|
25
|
+
|
|
26
|
+
Internally this function uses a :class:`File` object, based on the
|
|
27
|
+
file extension.
|
|
28
|
+
Trajectory files furthermore require specification of the `template`
|
|
29
|
+
parameter.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
file_path : str
|
|
34
|
+
The path to structure file.
|
|
35
|
+
template : AtomArray or AtomArrayStack or file-like object or str, optional
|
|
36
|
+
Only required when reading a trajectory file.
|
|
37
|
+
**kwargs
|
|
38
|
+
Additional parameters will be passed to either the
|
|
39
|
+
:func:`get_structure()` or :func:`read()` method of the file
|
|
40
|
+
object.
|
|
41
|
+
This does not affect files given via the `template` parameter.
|
|
42
|
+
The only exception is the `atom_i`, which is applied to the template
|
|
43
|
+
as well if number of atoms do not match.
|
|
44
|
+
|
|
45
|
+
Returns
|
|
46
|
+
-------
|
|
47
|
+
array : AtomArray or AtomArrayStack
|
|
48
|
+
If the file contains multiple models, an AtomArrayStack is
|
|
49
|
+
returned, otherwise an AtomArray is returned.
|
|
50
|
+
|
|
51
|
+
Raises
|
|
52
|
+
------
|
|
53
|
+
ValueError
|
|
54
|
+
If the file format (i.e. the file extension) is unknown.
|
|
55
|
+
TypeError
|
|
56
|
+
If a trajectory file is loaded without specifying the
|
|
57
|
+
`template` parameter.
|
|
58
|
+
"""
|
|
59
|
+
# Optionally load template from file
|
|
60
|
+
if isinstance(template, (io.IOBase, str)):
|
|
61
|
+
template = load_structure(template)
|
|
62
|
+
|
|
63
|
+
# We only need the suffix here
|
|
64
|
+
_, suffix = os.path.splitext(file_path)
|
|
65
|
+
match suffix:
|
|
66
|
+
case ".pdb":
|
|
67
|
+
from biotite.structure.io.pdb import PDBFile
|
|
68
|
+
|
|
69
|
+
file = PDBFile.read(file_path)
|
|
70
|
+
array = file.get_structure(**kwargs)
|
|
71
|
+
return _as_single_model_if_possible(array)
|
|
72
|
+
case ".pdbqt":
|
|
73
|
+
from biotite.structure.io.pdbqt import PDBQTFile
|
|
74
|
+
|
|
75
|
+
file = PDBQTFile.read(file_path)
|
|
76
|
+
array = file.get_structure(**kwargs)
|
|
77
|
+
return _as_single_model_if_possible(array)
|
|
78
|
+
case ".cif" | ".pdbx":
|
|
79
|
+
from biotite.structure.io.pdbx import CIFFile, get_structure
|
|
80
|
+
|
|
81
|
+
file = CIFFile.read(file_path)
|
|
82
|
+
array = get_structure(file, **kwargs)
|
|
83
|
+
return _as_single_model_if_possible(array)
|
|
84
|
+
case ".bcif":
|
|
85
|
+
from biotite.structure.io.pdbx import BinaryCIFFile, get_structure
|
|
86
|
+
|
|
87
|
+
file = BinaryCIFFile.read(file_path)
|
|
88
|
+
array = get_structure(file, **kwargs)
|
|
89
|
+
return _as_single_model_if_possible(array)
|
|
90
|
+
case ".gro":
|
|
91
|
+
from biotite.structure.io.gro import GROFile
|
|
92
|
+
|
|
93
|
+
file = GROFile.read(file_path)
|
|
94
|
+
array = file.get_structure(**kwargs)
|
|
95
|
+
return _as_single_model_if_possible(array)
|
|
96
|
+
case ".mol":
|
|
97
|
+
from biotite.structure.io.mol import MOLFile
|
|
98
|
+
|
|
99
|
+
file = MOLFile.read(file_path)
|
|
100
|
+
array = file.get_structure(**kwargs)
|
|
101
|
+
# MOL and SDF files only contain a single model
|
|
102
|
+
return array
|
|
103
|
+
case ".sdf" | ".sd":
|
|
104
|
+
from biotite.structure.io.mol import SDFile, get_structure
|
|
105
|
+
|
|
106
|
+
file = SDFile.read(file_path)
|
|
107
|
+
array = get_structure(file, **kwargs)
|
|
108
|
+
return array
|
|
109
|
+
case ".trr" | ".xtc" | ".dcd" | ".netcdf":
|
|
110
|
+
if template is None:
|
|
111
|
+
raise TypeError("Template must be specified for trajectory files")
|
|
112
|
+
# Filter template for atom ids, if an unfiltered template
|
|
113
|
+
if "atom_i" in kwargs and template.shape[-1] != len(kwargs["atom_i"]):
|
|
114
|
+
template = template[..., kwargs["atom_i"]]
|
|
115
|
+
from biotite.structure.io.dcd import DCDFile
|
|
116
|
+
from biotite.structure.io.netcdf import NetCDFFile
|
|
117
|
+
from biotite.structure.io.trr import TRRFile
|
|
118
|
+
from biotite.structure.io.xtc import XTCFile
|
|
119
|
+
|
|
120
|
+
if suffix == ".trr":
|
|
121
|
+
traj_file_cls = TRRFile
|
|
122
|
+
if suffix == ".xtc":
|
|
123
|
+
traj_file_cls = XTCFile
|
|
124
|
+
if suffix == ".dcd":
|
|
125
|
+
traj_file_cls = DCDFile
|
|
126
|
+
if suffix == ".netcdf":
|
|
127
|
+
traj_file_cls = NetCDFFile
|
|
128
|
+
file = traj_file_cls.read(file_path, **kwargs)
|
|
129
|
+
return file.get_structure(template)
|
|
130
|
+
case unknown_suffix:
|
|
131
|
+
raise ValueError(f"Unknown file format '{unknown_suffix}'")
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def save_structure(file_path, array, **kwargs):
|
|
135
|
+
"""
|
|
136
|
+
Save an :class:`AtomArray` or class`AtomArrayStack` to a structure
|
|
137
|
+
file without the need to manually instantiate a :class:`File`
|
|
138
|
+
object.
|
|
139
|
+
|
|
140
|
+
Internally this function uses a :class:`File` object, based on the
|
|
141
|
+
file extension.
|
|
142
|
+
|
|
143
|
+
Parameters
|
|
144
|
+
----------
|
|
145
|
+
file_path : str
|
|
146
|
+
The path to structure file.
|
|
147
|
+
array : AtomArray or AtomArrayStack
|
|
148
|
+
The structure to be saved.
|
|
149
|
+
**kwargs
|
|
150
|
+
Additional parameters will be passed to the respective `set_structure`
|
|
151
|
+
method.
|
|
152
|
+
|
|
153
|
+
Raises
|
|
154
|
+
------
|
|
155
|
+
ValueError
|
|
156
|
+
If the file format (i.e. the file extension) is unknown.
|
|
157
|
+
"""
|
|
158
|
+
# We only need the suffix here
|
|
159
|
+
_, suffix = os.path.splitext(file_path)
|
|
160
|
+
match suffix:
|
|
161
|
+
case ".pdb":
|
|
162
|
+
from biotite.structure.io.pdb import PDBFile
|
|
163
|
+
|
|
164
|
+
file = PDBFile()
|
|
165
|
+
file.set_structure(array, **kwargs)
|
|
166
|
+
file.write(file_path)
|
|
167
|
+
case ".pdbqt":
|
|
168
|
+
from biotite.structure.io.pdbqt import PDBQTFile
|
|
169
|
+
|
|
170
|
+
file = PDBQTFile()
|
|
171
|
+
file.set_structure(array, **kwargs)
|
|
172
|
+
file.write(file_path)
|
|
173
|
+
case ".cif" | ".pdbx":
|
|
174
|
+
from biotite.structure.io.pdbx import CIFFile, set_structure
|
|
175
|
+
|
|
176
|
+
file = CIFFile()
|
|
177
|
+
set_structure(file, array, **kwargs)
|
|
178
|
+
file.write(file_path)
|
|
179
|
+
case ".bcif":
|
|
180
|
+
from biotite.structure.io.pdbx import BinaryCIFFile, set_structure
|
|
181
|
+
|
|
182
|
+
file = BinaryCIFFile()
|
|
183
|
+
set_structure(file, array, **kwargs)
|
|
184
|
+
file.write(file_path)
|
|
185
|
+
case ".gro":
|
|
186
|
+
from biotite.structure.io.gro import GROFile
|
|
187
|
+
|
|
188
|
+
file = GROFile()
|
|
189
|
+
file.set_structure(array, **kwargs)
|
|
190
|
+
file.write(file_path)
|
|
191
|
+
case ".mol":
|
|
192
|
+
from biotite.structure.io.mol import MOLFile
|
|
193
|
+
|
|
194
|
+
file = MOLFile()
|
|
195
|
+
file.set_structure(array, **kwargs)
|
|
196
|
+
file.header = _mol_header()
|
|
197
|
+
file.write(file_path)
|
|
198
|
+
case ".sdf" | ".sd":
|
|
199
|
+
from biotite.structure.io.mol import SDFile, SDRecord, set_structure
|
|
200
|
+
|
|
201
|
+
record = SDRecord()
|
|
202
|
+
record.set_structure(array, **kwargs)
|
|
203
|
+
record.header = _mol_header()
|
|
204
|
+
file = SDFile({"Molecule": record})
|
|
205
|
+
file.write(file_path)
|
|
206
|
+
case ".trr" | ".xtc" | ".dcd" | ".netcdf":
|
|
207
|
+
from biotite.structure.io.dcd import DCDFile
|
|
208
|
+
from biotite.structure.io.netcdf import NetCDFFile
|
|
209
|
+
from biotite.structure.io.trr import TRRFile
|
|
210
|
+
from biotite.structure.io.xtc import XTCFile
|
|
211
|
+
|
|
212
|
+
if suffix == ".trr":
|
|
213
|
+
traj_file_cls = TRRFile
|
|
214
|
+
if suffix == ".xtc":
|
|
215
|
+
traj_file_cls = XTCFile
|
|
216
|
+
if suffix == ".dcd":
|
|
217
|
+
traj_file_cls = DCDFile
|
|
218
|
+
if suffix == ".netcdf":
|
|
219
|
+
traj_file_cls = NetCDFFile
|
|
220
|
+
file = traj_file_cls()
|
|
221
|
+
file.set_structure(array, **kwargs)
|
|
222
|
+
file.write(file_path)
|
|
223
|
+
case unknown_suffix:
|
|
224
|
+
raise ValueError(f"Unknown file format '{unknown_suffix}'")
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def _as_single_model_if_possible(atoms):
|
|
228
|
+
if isinstance(atoms, AtomArrayStack) and atoms.stack_depth() == 1:
|
|
229
|
+
# Stack containing only one model -> return as atom array
|
|
230
|
+
return atoms[0]
|
|
231
|
+
else:
|
|
232
|
+
return atoms
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def _mol_header():
|
|
236
|
+
from biotite.structure.io.mol import Header
|
|
237
|
+
|
|
238
|
+
return Header(
|
|
239
|
+
mol_name="Molecule",
|
|
240
|
+
program="Biotite",
|
|
241
|
+
time=datetime.datetime.now(),
|
|
242
|
+
dimensions="3D",
|
|
243
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
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 an :class:`AtomArray` or
|
|
7
|
+
:class:`AtomArrayStack` using the Gro format used by the gromacs
|
|
8
|
+
software package.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__name__ = "biotite.structure.io.gro"
|
|
12
|
+
__author__ = "Daniel Bauer"
|
|
13
|
+
|
|
14
|
+
from .file import *
|