gemmi-protools 1.1.0__py3-none-any.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.
- gemmi_protools/__init__.py +5 -0
- gemmi_protools/data/CD1/CD21029_review.fasta +141 -0
- gemmi_protools/data/MHC/MHC_combined.hmm +1092 -0
- gemmi_protools/data/MHC/MHC_combined.hmm.h3f +0 -0
- gemmi_protools/data/MHC/MHC_combined.hmm.h3i +0 -0
- gemmi_protools/data/MHC/MHC_combined.hmm.h3m +0 -0
- gemmi_protools/data/MHC/MHC_combined.hmm.h3p +0 -0
- gemmi_protools/io/__init__.py +3 -0
- gemmi_protools/io/convert.py +93 -0
- gemmi_protools/io/reader.py +911 -0
- gemmi_protools/tools/__init__.py +3 -0
- gemmi_protools/tools/align.py +336 -0
- gemmi_protools/tools/dockq.py +128 -0
- gemmi_protools/tools/mesh.py +197 -0
- gemmi_protools/tools/pdb_annot.py +862 -0
- gemmi_protools-1.1.0.dist-info/METADATA +46 -0
- gemmi_protools-1.1.0.dist-info/RECORD +20 -0
- gemmi_protools-1.1.0.dist-info/WHEEL +5 -0
- gemmi_protools-1.1.0.dist-info/licenses/LICENSE +21 -0
- gemmi_protools-1.1.0.dist-info/top_level.txt +1 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""
|
|
2
|
+
@Author: Luo Jiejian
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import gemmi
|
|
6
|
+
import numpy as np
|
|
7
|
+
from Bio.PDB.Structure import Structure as BioStructure
|
|
8
|
+
from Bio.PDB.StructureBuilder import StructureBuilder
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def gemmi2bio(gemmi_structure: gemmi.Structure) -> BioStructure:
|
|
12
|
+
"""
|
|
13
|
+
Convert gemmi structure to biopython structure
|
|
14
|
+
:param gemmi_structure:
|
|
15
|
+
:return:
|
|
16
|
+
return biopython structure
|
|
17
|
+
"""
|
|
18
|
+
structure_builder = StructureBuilder()
|
|
19
|
+
structure_builder.init_structure(structure_id=gemmi_structure.name)
|
|
20
|
+
|
|
21
|
+
for model_idx, gemmi_model in enumerate(gemmi_structure):
|
|
22
|
+
structure_builder.init_model(model_idx)
|
|
23
|
+
|
|
24
|
+
for gemmi_chain in gemmi_model:
|
|
25
|
+
structure_builder.init_chain(gemmi_chain.name)
|
|
26
|
+
|
|
27
|
+
for gemmi_residue in gemmi_chain:
|
|
28
|
+
if gemmi_residue.het_flag == "H":
|
|
29
|
+
if gemmi_residue.name in ["HOH", "WAT"]:
|
|
30
|
+
het_flag = "W"
|
|
31
|
+
else:
|
|
32
|
+
het_flag = "H"
|
|
33
|
+
else:
|
|
34
|
+
het_flag = " "
|
|
35
|
+
|
|
36
|
+
structure_builder.init_residue(resname=gemmi_residue.name, field=het_flag,
|
|
37
|
+
resseq=gemmi_residue.seqid.num, icode=gemmi_residue.seqid.icode)
|
|
38
|
+
for gemmi_atom in gemmi_residue:
|
|
39
|
+
coord = np.array([gemmi_atom.pos.x, gemmi_atom.pos.y, gemmi_atom.pos.z])
|
|
40
|
+
structure_builder.init_atom(name=gemmi_atom.name,
|
|
41
|
+
coord=coord,
|
|
42
|
+
b_factor=gemmi_atom.b_iso,
|
|
43
|
+
occupancy=gemmi_atom.occ,
|
|
44
|
+
altloc=gemmi_atom.altloc if gemmi_atom.has_altloc() else ' ',
|
|
45
|
+
fullname=gemmi_atom.name.center(4),
|
|
46
|
+
serial_number=gemmi_atom.serial,
|
|
47
|
+
element=gemmi_atom.element.name.upper())
|
|
48
|
+
|
|
49
|
+
bio_structure = structure_builder.get_structure()
|
|
50
|
+
return bio_structure
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def bio2gemmi(bio_structure: BioStructure) -> gemmi.Structure:
|
|
54
|
+
"""
|
|
55
|
+
Convert biopython structure to gemmi structure
|
|
56
|
+
:param bio_structure:
|
|
57
|
+
:return:
|
|
58
|
+
return gemmi structure
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
g_structure = gemmi.Structure()
|
|
62
|
+
g_structure.name = bio_structure.id
|
|
63
|
+
|
|
64
|
+
for bio_model in bio_structure:
|
|
65
|
+
# bio model start from 0, gemmi model start from 1
|
|
66
|
+
g_model = gemmi.Model(bio_model.id + 1)
|
|
67
|
+
for bio_chain in bio_model:
|
|
68
|
+
g_chain = gemmi.Chain(bio_chain.id)
|
|
69
|
+
for bio_residue in bio_chain:
|
|
70
|
+
g_residue = gemmi.Residue()
|
|
71
|
+
g_residue.name = bio_residue.resname
|
|
72
|
+
het_flag, r_num, i_code = bio_residue.id
|
|
73
|
+
g_residue.seqid.num = r_num
|
|
74
|
+
g_residue.seqid.icode = i_code
|
|
75
|
+
g_residue.het_flag = "A" if het_flag == " " else "H"
|
|
76
|
+
|
|
77
|
+
for bio_atom in bio_residue:
|
|
78
|
+
g_atom = gemmi.Atom()
|
|
79
|
+
g_atom.name = bio_atom.name
|
|
80
|
+
g_atom.b_iso = bio_atom.bfactor
|
|
81
|
+
g_atom.occ = bio_atom.occupancy
|
|
82
|
+
g_atom.altloc = "\x00" if bio_atom.altloc == " " else bio_atom.altloc
|
|
83
|
+
g_atom.element = gemmi.Element(bio_atom.element)
|
|
84
|
+
g_atom.serial = bio_atom.serial_number
|
|
85
|
+
px, py, pz = bio_atom.coord
|
|
86
|
+
g_atom.pos = gemmi.Position(px, py, pz)
|
|
87
|
+
g_residue.add_atom(g_atom)
|
|
88
|
+
g_chain.add_residue(g_residue)
|
|
89
|
+
g_model.add_chain(g_chain)
|
|
90
|
+
g_structure.add_model(g_model)
|
|
91
|
+
g_structure.setup_entities()
|
|
92
|
+
g_structure.assign_het_flags()
|
|
93
|
+
return g_structure
|