gemmi-protools 0.1.9__py3-none-any.whl → 0.1.10__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.
Potentially problematic release.
This version of gemmi-protools might be problematic. Click here for more details.
- gemmi_protools/io/cif_opts.py +8 -0
- gemmi_protools/io/parser.py +33 -25
- gemmi_protools/io/reader.py +13 -0
- {gemmi_protools-0.1.9.dist-info → gemmi_protools-0.1.10.dist-info}/METADATA +1 -1
- {gemmi_protools-0.1.9.dist-info → gemmi_protools-0.1.10.dist-info}/RECORD +8 -8
- {gemmi_protools-0.1.9.dist-info → gemmi_protools-0.1.10.dist-info}/WHEEL +0 -0
- {gemmi_protools-0.1.9.dist-info → gemmi_protools-0.1.10.dist-info}/licenses/LICENSE +0 -0
- {gemmi_protools-0.1.9.dist-info → gemmi_protools-0.1.10.dist-info}/top_level.txt +0 -0
gemmi_protools/io/cif_opts.py
CHANGED
|
@@ -135,6 +135,14 @@ def _cif_entity_info(block: gemmi.cif.Block) -> Entity:
|
|
|
135
135
|
def _cif_block_for_output(structure: gemmi.Structure, entity: Entity) -> gemmi.cif.Block:
|
|
136
136
|
block = structure.make_mmcif_block()
|
|
137
137
|
|
|
138
|
+
reflns = block.find_mmcif_category(category="_reflns.")
|
|
139
|
+
if "_reflns.d_resolution_high" not in list(reflns.tags) or "_reflns.d_resolution_low" not in list(reflns.tags):
|
|
140
|
+
reflns.erase()
|
|
141
|
+
|
|
142
|
+
resolution = "%.2f" % structure.resolution
|
|
143
|
+
reflns_loop = block.init_loop(prefix="_reflns.", tags=["d_resolution_high", "d_resolution_low"])
|
|
144
|
+
reflns_loop.add_row([resolution, resolution])
|
|
145
|
+
|
|
138
146
|
ta = block.find_mmcif_category(category="_entity.")
|
|
139
147
|
da = pd.DataFrame(list(ta), columns=list(ta.tags))
|
|
140
148
|
if "_entity.id" in da.columns:
|
gemmi_protools/io/parser.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@Author: Luo Jiejian
|
|
3
3
|
"""
|
|
4
4
|
import pathlib
|
|
5
|
-
from collections import
|
|
5
|
+
from collections import Counter
|
|
6
6
|
from typing import Union, Optional, Dict, List
|
|
7
7
|
|
|
8
8
|
import gemmi
|
|
@@ -114,6 +114,19 @@ def _update_entity_names(entity: Entity, mapper: Dict[str, str]):
|
|
|
114
114
|
tmp[mapper[key]] = entity[super_key][key]
|
|
115
115
|
entity.__setattr__(super_key, tmp)
|
|
116
116
|
|
|
117
|
+
new_polymer2eid = dict()
|
|
118
|
+
for c, old_eid in entity.polymer2eid.items():
|
|
119
|
+
new_polymer2eid[c] = mapper[old_eid]
|
|
120
|
+
entity.__setattr__(name="polymer2eid", value=new_polymer2eid)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _melt_dict(inputs: dict):
|
|
124
|
+
outputs = dict()
|
|
125
|
+
for keys, val in inputs.items():
|
|
126
|
+
for k in keys.split(","):
|
|
127
|
+
outputs[k] = val
|
|
128
|
+
return outputs
|
|
129
|
+
|
|
117
130
|
|
|
118
131
|
@typechecked
|
|
119
132
|
def pdb_parser(path: Union[str, pathlib.Path]):
|
|
@@ -126,39 +139,34 @@ def pdb_parser(path: Union[str, pathlib.Path]):
|
|
|
126
139
|
struct = gemmi.read_structure(str(path))
|
|
127
140
|
struct.resolution = _get_pdb_resolution(struct.raw_remarks)
|
|
128
141
|
ent_0 = _pdb_entity_info(path)
|
|
142
|
+
ch2desc = _melt_dict(ent_0.eid2desc)
|
|
143
|
+
ch2specie = _melt_dict(ent_0.eid2specie)
|
|
144
|
+
ch2taxid = _melt_dict(ent_0.eid2taxid)
|
|
129
145
|
|
|
130
146
|
struct.setup_entities()
|
|
131
|
-
|
|
132
|
-
# pdb have "A,B,C" chains
|
|
133
|
-
# after setup, entities will merge
|
|
134
147
|
block = struct.make_mmcif_block()
|
|
135
148
|
ent_t = _cif_entity_info(block)
|
|
136
|
-
rec = defaultdict(list)
|
|
137
|
-
|
|
138
|
-
for cn, middle_eid in ent_t.polymer2eid.items():
|
|
139
|
-
rec[middle_eid].append(cn)
|
|
140
149
|
|
|
141
|
-
|
|
142
|
-
|
|
150
|
+
# set non-polymer entity names
|
|
151
|
+
non_polymer_entities = [e.name for e in struct.entities if e.polymer_type.name == "Unknown"]
|
|
152
|
+
for k in non_polymer_entities:
|
|
153
|
+
assert k in ent_t.eid2desc
|
|
154
|
+
if ent_t.eid2desc[k] == "?":
|
|
155
|
+
ent_t.eid2desc[k] = k
|
|
143
156
|
|
|
144
|
-
for
|
|
145
|
-
if
|
|
146
|
-
|
|
147
|
-
mid.sort()
|
|
148
|
-
old_eid = str(",".join(mid))
|
|
149
|
-
_mapper_n[old_eid] = new_eid
|
|
157
|
+
for k in ent_t.eid2desc.keys():
|
|
158
|
+
if k not in non_polymer_entities:
|
|
159
|
+
ent_t.eid2desc[k] = ch2desc.get(k, "?")
|
|
150
160
|
|
|
151
|
-
|
|
152
|
-
|
|
161
|
+
polymer_chs_used_as_eid = set(ch2specie.keys()).intersection(ent_t.eid2desc.keys())
|
|
162
|
+
for k in polymer_chs_used_as_eid:
|
|
163
|
+
ent_t.eid2specie[k] = ch2specie.get(k, "?")
|
|
164
|
+
ent_t.eid2taxid[k] = ch2taxid.get(k, "?")
|
|
153
165
|
|
|
154
|
-
|
|
166
|
+
m = _assign_digital_entity_names(struct)
|
|
167
|
+
_update_entity_names(ent_t, m)
|
|
155
168
|
|
|
156
|
-
|
|
157
|
-
for super_key in ["eid2desc", "polymer2eid"]:
|
|
158
|
-
for key, val in ent_1[super_key].items():
|
|
159
|
-
if key not in ent_0[super_key]:
|
|
160
|
-
ent_0[super_key][key] = val
|
|
161
|
-
return struct, ent_0
|
|
169
|
+
return struct, ent_t
|
|
162
170
|
else:
|
|
163
171
|
raise ValueError("Only support .pdb or .pdb.gz file, but got %s" % path)
|
|
164
172
|
|
gemmi_protools/io/reader.py
CHANGED
|
@@ -83,6 +83,19 @@ class StructureParser(object):
|
|
|
83
83
|
def to_pdb(self, outfile: str, write_minimal_pdb=False):
|
|
84
84
|
compound_source = _compound_source_string(self.ENTITY)
|
|
85
85
|
struct = self.STRUCT.clone()
|
|
86
|
+
|
|
87
|
+
rs = "REMARK 2 RESOLUTION. %.2f ANGSTROMS." % struct.resolution
|
|
88
|
+
resolution_remarks = ["%-80s" % "REMARK 2",
|
|
89
|
+
"%-80s" % rs]
|
|
90
|
+
|
|
91
|
+
resolution_remark_exist = False
|
|
92
|
+
for line in struct.raw_remarks:
|
|
93
|
+
if "REMARK 2 RESOLUTION" in line:
|
|
94
|
+
resolution_remark_exist = True
|
|
95
|
+
|
|
96
|
+
if not resolution_remark_exist:
|
|
97
|
+
struct.raw_remarks = resolution_remarks + struct.raw_remarks
|
|
98
|
+
|
|
86
99
|
struct.raw_remarks = compound_source + struct.raw_remarks
|
|
87
100
|
if write_minimal_pdb:
|
|
88
101
|
struct.write_minimal_pdb(outfile)
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
gemmi_protools/__init__.py,sha256=hwUw-EieCG0kwzHjTjzHF9Bc3D-J5R_l6G8PCcFegkw,331
|
|
2
2
|
gemmi_protools/io/__init__.py,sha256=F6e1xNT_7lZAWQgNIneH06o2qtWYrHNr_xPUPTwwx5E,29
|
|
3
|
-
gemmi_protools/io/cif_opts.py,sha256=
|
|
3
|
+
gemmi_protools/io/cif_opts.py,sha256=ZSZTbey3SvHyHaJ1T7m432Vg9oraYB1Jgay6ikIvWeQ,6779
|
|
4
4
|
gemmi_protools/io/convert.py,sha256=780sQcwhslUD4Hj5UZMVlQdbicniJ6jNjncTl_7jaMk,3841
|
|
5
5
|
gemmi_protools/io/parse_pdb_header.py,sha256=UOGMsE3-d3APhO7zaAEE0NT31n-iqt55VpDh_RPOicI,14223
|
|
6
|
-
gemmi_protools/io/parser.py,sha256=
|
|
6
|
+
gemmi_protools/io/parser.py,sha256=HFc4Kovr6rxEpLAEDUtF_e-RnA5OsWMeMFjuVNm7UYY,9507
|
|
7
7
|
gemmi_protools/io/pdb_opts.py,sha256=laUqxlecOe6goax12q8EJGZuZbHyIGsXVucMV3gVrgg,5741
|
|
8
8
|
gemmi_protools/io/peptide.py,sha256=a2wiEutJmvhl6gDCIzzqRCbmyknk2mwgy2FZ53lXclU,750
|
|
9
|
-
gemmi_protools/io/reader.py,sha256=
|
|
9
|
+
gemmi_protools/io/reader.py,sha256=lI9JTXqsct3D719qVN7Dsvg-zHudElojpW5-odtXa8A,16527
|
|
10
10
|
gemmi_protools/io/struct_info.py,sha256=9nBj1Zer03S8_Wks7L7uRlc9PlbfCKzoaT32pKR58X8,2769
|
|
11
11
|
gemmi_protools/utils/__init__.py,sha256=F6e1xNT_7lZAWQgNIneH06o2qtWYrHNr_xPUPTwwx5E,29
|
|
12
12
|
gemmi_protools/utils/align.py,sha256=CZcrvjy-ZbX2u7OAn-YGblbxaj9YFUDX4CFZcpbpnB8,6959
|
|
13
13
|
gemmi_protools/utils/dockq.py,sha256=XmMwVEy-H4p6sH_HPcDWA3TP77OWdih0fE_BQJDr4pU,4189
|
|
14
14
|
gemmi_protools/utils/fixer.py,sha256=RDmpoZpTrGdwuJQTTK1eif132MHV1I-T6Nt47ezgxTM,10236
|
|
15
15
|
gemmi_protools/utils/ppi.py,sha256=VWYsdxWwQoS1xwEYj5KB96Zz3F8r5Eyuw6NT3ReD-wc,2330
|
|
16
|
-
gemmi_protools-0.1.
|
|
17
|
-
gemmi_protools-0.1.
|
|
18
|
-
gemmi_protools-0.1.
|
|
19
|
-
gemmi_protools-0.1.
|
|
20
|
-
gemmi_protools-0.1.
|
|
16
|
+
gemmi_protools-0.1.10.dist-info/licenses/LICENSE,sha256=JuQvKcgj6n11y5y6nXr9rABv3gJSswc4eTCd5WZBtSY,1062
|
|
17
|
+
gemmi_protools-0.1.10.dist-info/METADATA,sha256=0xlRghvF1tEfCJi6OxLEGCIsJctUat4y2Sgt18tSrU0,568
|
|
18
|
+
gemmi_protools-0.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
gemmi_protools-0.1.10.dist-info/top_level.txt,sha256=P12mYJi5O5EKIn5u-RFaWxuix431CgLacSRD7rBid_U,15
|
|
20
|
+
gemmi_protools-0.1.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|