pidibble 1.2.0__tar.gz → 1.2.2__tar.gz

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.
Files changed (44) hide show
  1. pidibble-1.2.2/.github/workflows/release.yaml +41 -0
  2. {pidibble-1.2.0 → pidibble-1.2.2}/PKG-INFO +6 -2
  3. {pidibble-1.2.0 → pidibble-1.2.2}/README.md +4 -0
  4. {pidibble-1.2.0 → pidibble-1.2.2}/docs/source/conf.py +2 -2
  5. pidibble-1.2.2/docs/source/generated/pidibble.rst +6 -0
  6. {pidibble-1.2.0 → pidibble-1.2.2}/docs/source/usage.rst +3 -1
  7. {pidibble-1.2.0 → pidibble-1.2.2}/pidibble/hex.py +1 -1
  8. {pidibble-1.2.0 → pidibble-1.2.2}/pidibble/mmcif_parse.py +32 -2
  9. {pidibble-1.2.0 → pidibble-1.2.2}/pidibble/pdbparse.py +6 -2
  10. {pidibble-1.2.0 → pidibble-1.2.2}/pidibble/resources/mmcif_format.yaml +102 -18
  11. {pidibble-1.2.0 → pidibble-1.2.2}/pidibble/resources/pdb_format.yaml +1 -1
  12. {pidibble-1.2.0 → pidibble-1.2.2}/pyproject.toml +1 -1
  13. pidibble-1.2.2/tests/unit/test_rcsb/8fae.cif +23794 -0
  14. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb.py +139 -114
  15. pidibble-1.2.0/docs/source/generated/pidibble.rst +0 -23
  16. {pidibble-1.2.0 → pidibble-1.2.2}/.gitignore +0 -0
  17. {pidibble-1.2.0 → pidibble-1.2.2}/.readthedocs.yaml +0 -0
  18. {pidibble-1.2.0 → pidibble-1.2.2}/LICENSE +0 -0
  19. {pidibble-1.2.0 → pidibble-1.2.2}/MANIFEST.in +0 -0
  20. {pidibble-1.2.0 → pidibble-1.2.2}/docs/Makefile +0 -0
  21. {pidibble-1.2.0 → pidibble-1.2.2}/docs/make.bat +0 -0
  22. {pidibble-1.2.0 → pidibble-1.2.2}/docs/requirements.txt +0 -0
  23. {pidibble-1.2.0 → pidibble-1.2.2}/docs/source/api.rst +0 -0
  24. {pidibble-1.2.0 → pidibble-1.2.2}/docs/source/index.rst +0 -0
  25. {pidibble-1.2.0 → pidibble-1.2.2}/docs/source/notes.md +0 -0
  26. {pidibble-1.2.0 → pidibble-1.2.2}/pidibble/__init__.py +0 -0
  27. {pidibble-1.2.0 → pidibble-1.2.2}/pidibble/baseparsers.py +0 -0
  28. {pidibble-1.2.0 → pidibble-1.2.2}/pidibble/baserecord.py +0 -0
  29. {pidibble-1.2.0 → pidibble-1.2.2}/pidibble/pdbrecord.py +0 -0
  30. {pidibble-1.2.0 → pidibble-1.2.2}/pidibble/resources/__init__.py +0 -0
  31. {pidibble-1.2.0 → pidibble-1.2.2}/tests/__init__.py +0 -0
  32. {pidibble-1.2.0 → pidibble-1.2.2}/tests/conftest.py +0 -0
  33. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_hex/my_system.pdb +0 -0
  34. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_hex.py +0 -0
  35. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb/4tvp.cif +0 -0
  36. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb/4tvp.pdb +0 -0
  37. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb/4zmj-newresnames.pdb +0 -0
  38. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb/4zmj.cif +0 -0
  39. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb/4zmj.pdb +0 -0
  40. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb/6m0j.pdb +0 -0
  41. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb/G.pdb +0 -0
  42. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb/GG.pdb +0 -0
  43. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb/test.pdb +0 -0
  44. {pidibble-1.2.0 → pidibble-1.2.2}/tests/unit/test_rcsb/test_pdb_format.yaml +0 -0
@@ -0,0 +1,41 @@
1
+ name: Release & Upload to PyPI (Hatch)
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ release:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v3
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v4
18
+ with:
19
+ python-version: "3.9"
20
+
21
+ - name: Install Hatch
22
+ run: python -m pip install --upgrade pip hatch
23
+
24
+ - name: Clean previous builds
25
+ run: rm -rf dist/
26
+
27
+ - name: Build the package with Hatch
28
+ run: hatch build
29
+
30
+ - name: Upload to GitHub Release
31
+ uses: softprops/action-gh-release@v1
32
+ with:
33
+ files: |
34
+ dist/*.tar.gz
35
+ dist/*.whl
36
+
37
+ - name: Publish to PyPI using Hatch
38
+ env:
39
+ HATCH_INDEX_USER: __token__
40
+ HATCH_INDEX_AUTH: ${{ secrets.PYPI_API_TOKEN }}
41
+ run: hatch publish
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pidibble
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: A complete Protein Data Bank (PDB) file parser
5
5
  Project-URL: Source, https://github.com/cameronabrams/pidibble
6
6
  Project-URL: Documentation, https://pidibble.readthedocs.io/en/latest/
@@ -88,6 +88,10 @@ ATOM
88
88
  ```
89
89
 
90
90
  ## Release History
91
+ * 1.2.2:
92
+ * bugfix: negative resids allowed
93
+ * 1.2.1:
94
+ * bugfix: hex issues AGAIN
91
95
  * 1.2.0
92
96
  * bugfix: hex issues again
93
97
  * 1.1.9
@@ -70,6 +70,10 @@ ATOM
70
70
  ```
71
71
 
72
72
  ## Release History
73
+ * 1.2.2:
74
+ * bugfix: negative resids allowed
75
+ * 1.2.1:
76
+ * bugfix: hex issues AGAIN
73
77
  * 1.2.0
74
78
  * bugfix: hex issues again
75
79
  * 1.1.9
@@ -6,8 +6,8 @@ project = 'Pidibble'
6
6
  copyright = '2023-2024, Cameron F. Abrams'
7
7
  author = 'cfa22@drexel.edu'
8
8
 
9
- release = '1.1'
10
- version = '1.1.4'
9
+ release = '1.3'
10
+ version = '1.3.0'
11
11
 
12
12
  # -- General configuration
13
13
 
@@ -0,0 +1,6 @@
1
+ pidibble
2
+ ========
3
+
4
+ .. automodule:: pidibble
5
+
6
+
@@ -175,4 +175,6 @@ Currently, only ``ATOM``, ``HETATM``, ``SEQADV``, ``REMARK 350``, and ``REMARK 4
175
175
  >>> ', '.join(list(p.parsed.keys()))
176
176
  'ATOM, HETATM, LINK, SSBOND, SEQADV, REMARK.350.BIOMOLECULE1.TRANSFORM1, REMARK.350.BIOMOLECULE1.TRANSFORM2, REMARK.350.BIOMOLECULE1.TRANSFORM3, REMARK.465'
177
177
 
178
- These records are the bare minimum needed to generate (say) input coordinate and topology files for an MD simulation. Future versions of ``pidibble`` will provide complete PDB-like parsings of ``mmCIF`` files. This is probably not useful.
178
+ These records are the bare minimum needed to generate (say) input coordinate and topology files for an MD simulation. Future versions of ``pidibble`` will provide complete PDB-like parsings of ``mmCIF`` files. This is probably not useful.
179
+
180
+ Importantly: ``pidibble`` parses mmCIF input to generate a structure that is the equivalent of the PDB format; that is, it uses ``auth`` fields instead of ``label`` fields.
@@ -4,7 +4,7 @@ def str2atomSerial(arg):
4
4
  assert type(arg)==str
5
5
  if arg=='nan':
6
6
  return_object=0
7
- elif __hex_tripped__ or any([(x in arg) for x in 'abcdef']):
7
+ elif __hex_tripped__ or any([(x in arg) for x in 'abcdefABCDEF']):
8
8
  return_object=int(arg,16)
9
9
  elif '*' in arg:
10
10
  return_object=0
@@ -1,3 +1,4 @@
1
+ from collections import UserDict
1
2
  from .pdbrecord import PDBRecord
2
3
  from .baserecord import BaseRecord
3
4
  import logging
@@ -28,6 +29,27 @@ def rectify(val):
28
29
  pass
29
30
  return val
30
31
 
32
+ def resolve(key,aDict):
33
+ pass
34
+
35
+ class MMCIFDict(UserDict):
36
+ def __init__(self,data,linkers={},blankers=[' ','','?']):
37
+ self.data=data
38
+ self.linkers=linkers
39
+ self.blankers=blankers
40
+
41
+ def get(self,key):
42
+ val=self[key]
43
+ if val in self.blankers:
44
+ return ''
45
+
46
+ key_link=self.linkers.get(val,None)
47
+ if key_link:
48
+ if key_link in self.keys():
49
+ val=self[key_link]
50
+ return val
51
+
52
+
31
53
  class MMCIF_Parser:
32
54
  def __init__(self,mmcif_formats,pdb_formats,cif_data):
33
55
  self.formats=mmcif_formats
@@ -73,6 +95,7 @@ class MMCIF_Parser:
73
95
  global_ids=mapspec.get('global_ids',{})
74
96
  spawns_on=mapspec.get('spawns_on',None)
75
97
  allcaps=mapspec.get('allcaps',[])
98
+ if_dot_replace_with=mapspec.get('if_dot_replace_with',{})
76
99
  cifrec=self.cif_data.getObj(mapspec['data_obj'])
77
100
  if not tables:
78
101
  for idx in range(len(cifrec)):
@@ -101,8 +124,15 @@ class MMCIF_Parser:
101
124
  if k in map_values:
102
125
  mapper=self.global_maps[map_values[k]]
103
126
  if type(val)==list:
104
- val=list(set([mapper[x] for x in val]))
105
- val.sort()
127
+ logger.debug(f'mapper {mapper}')
128
+ logger.debug(f'list before mapping {val}')
129
+ mapped_val=list(set([str(mapper[x]) for x in val]))
130
+ logger.debug(f'list after mapping {mapped_val}')
131
+ try:
132
+ mapped_val.sort()
133
+ val=mapped_val
134
+ except:
135
+ raise TypeError(f'could not sort list {mapped_val} at key {k}')
106
136
  else:
107
137
  val=mapper[val]
108
138
  idict[k]=val
@@ -30,8 +30,12 @@ def safe_float(x):
30
30
 
31
31
  __version__ = importlib.metadata.version("pidibble")
32
32
 
33
- def str2int_sig(arg):
34
- if not arg.strip().isnumeric(): return -1
33
+ def str2int_sig(arg:str):
34
+ if not arg.strip().isnumeric():
35
+ if arg.strip()[0]=='1':
36
+ return int(arg)
37
+ else:
38
+ return -1
35
39
  return int(arg)
36
40
 
37
41
  class PDBParser:
@@ -9,11 +9,17 @@ ATOM:
9
9
  value: auth_asym_id
10
10
  global_ids:
11
11
  modelNum: pdbx_PDB_model_num
12
+ if_dot_replace_with:
13
+ label_seq_id: auth_seq_id
12
14
  attr_map:
13
15
  serial: id
14
- name: auth_atom_id
16
+ name: label_atom_id
15
17
  altLoc: label_alt_id
16
18
  residue:
19
+ chainID: label_asym_id
20
+ resName: label_comp_id
21
+ seqNum: label_seq_id
22
+ residue_auth:
17
23
  chainID: auth_asym_id
18
24
  resName: auth_comp_id
19
25
  seqNum: auth_seq_id
@@ -25,10 +31,7 @@ ATOM:
25
31
  tempFactor: B_iso_or_equiv
26
32
  element: type_symbol
27
33
  charge: pdbx_formal_charge
28
- label_atom_id: label_atom_id
29
- label_comp_id: label_comp_id
30
- label_asym_id: label_asym_id
31
- label_seq_id: label_seq_id
34
+ auth_atom_id: auth_atom_id
32
35
  HETATM:
33
36
  data_obj: atom_site
34
37
  signal_attr: group_PDB
@@ -41,9 +44,13 @@ HETATM:
41
44
  modelNum: pdbx_PDB_model_num
42
45
  attr_map:
43
46
  serial: id
44
- name: auth_atom_id
47
+ name: label_atom_id
45
48
  altLoc: label_alt_id
46
49
  residue:
50
+ chainID: label_asym_id
51
+ resName: label_comp_id
52
+ seqNum: label_seq_id
53
+ residue_auth:
47
54
  chainID: auth_asym_id
48
55
  resName: auth_comp_id
49
56
  seqNum: auth_seq_id
@@ -55,10 +62,42 @@ HETATM:
55
62
  tempFactor: B_iso_or_equiv
56
63
  element: type_symbol
57
64
  charge: pdbx_formal_charge
58
- label_atom_id: label_atom_id
59
- label_comp_id: label_comp_id
60
- label_asym_id: label_asym_id
61
- label_seq_id: label_seq_id
65
+ auth_atom_id: auth_atom_id
66
+ # _struct_conn.id
67
+ # _struct_conn.conn_type_id
68
+ # _struct_conn.pdbx_leaving_atom_flag
69
+ # _struct_conn.pdbx_PDB_id
70
+ # _struct_conn.ptnr1_label_asym_id
71
+ # _struct_conn.ptnr1_label_comp_id
72
+ # _struct_conn.ptnr1_label_seq_id
73
+ # _struct_conn.ptnr1_label_atom_id
74
+ # _struct_conn.pdbx_ptnr1_label_alt_id
75
+ # _struct_conn.pdbx_ptnr1_PDB_ins_code
76
+ # _struct_conn.pdbx_ptnr1_standard_comp_id
77
+ # _struct_conn.ptnr1_symmetry
78
+ # _struct_conn.ptnr2_label_asym_id
79
+ # _struct_conn.ptnr2_label_comp_id
80
+ # _struct_conn.ptnr2_label_seq_id
81
+ # _struct_conn.ptnr2_label_atom_id
82
+ # _struct_conn.pdbx_ptnr2_label_alt_id
83
+ # _struct_conn.pdbx_ptnr2_PDB_ins_code
84
+ # _struct_conn.ptnr1_auth_asym_id
85
+ # _struct_conn.ptnr1_auth_comp_id
86
+ # _struct_conn.ptnr1_auth_seq_id
87
+ # _struct_conn.ptnr2_auth_asym_id
88
+ # _struct_conn.ptnr2_auth_comp_id
89
+ # _struct_conn.ptnr2_auth_seq_id
90
+ # _struct_conn.ptnr2_symmetry
91
+ # _struct_conn.pdbx_ptnr3_label_atom_id
92
+ # _struct_conn.pdbx_ptnr3_label_seq_id
93
+ # _struct_conn.pdbx_ptnr3_label_comp_id
94
+ # _struct_conn.pdbx_ptnr3_label_asym_id
95
+ # _struct_conn.pdbx_ptnr3_label_alt_id
96
+ # _struct_conn.pdbx_ptnr3_PDB_ins_code
97
+ # _struct_conn.details
98
+ # _struct_conn.pdbx_dist_value
99
+ # _struct_conn.pdbx_value_order
100
+ # _struct_conn.pdbx_role
62
101
  LINK:
63
102
  data_obj: struct_conn
64
103
  signal_attr: conn_type_id
@@ -69,22 +108,30 @@ LINK:
69
108
  length: pdbx_dist_value
70
109
  name1: ptnr1_label_atom_id
71
110
  altLoc1: pdbx_ptnr1_label_alt_id
72
- residue1:
111
+ residue1_auth:
73
112
  chainID: ptnr1_auth_asym_id
74
113
  resName: ptnr1_auth_comp_id
75
114
  seqNum: ptnr1_auth_seq_id
76
115
  iCode: pdbx_ptnr1_PDB_ins_code
116
+ residue1:
117
+ chainID: ptnr1_label_asym_id
118
+ resName: ptnr1_label_comp_id
119
+ seqNum: ptnr1_label_seq_id
77
120
  ptnr1_label_atom_id: ptnr1_label_atom_id
78
121
  ptnr1_label_comp_id: ptnr1_label_comp_id
79
122
  ptnr1_label_asym_id: ptnr1_label_asym_id
80
123
  ptnr1_label_seq_id: ptnr1_label_seq_id
81
124
  name2: ptnr2_label_atom_id
82
125
  altLoc2: pdbx_ptnr2_label_alt_id
83
- residue2:
126
+ residue2_auth:
84
127
  chainID: ptnr2_auth_asym_id
85
128
  resName: ptnr2_auth_comp_id
86
129
  seqNum: ptnr2_auth_seq_id
87
130
  iCode: pdbx_ptnr2_PDB_ins_code
131
+ residue2:
132
+ chainID: ptnr2_label_asym_id
133
+ resName: ptnr2_label_comp_id
134
+ seqNum: ptnr2_label_seq_id
88
135
  ptnr2_label_atom_id: ptnr2_label_atom_id
89
136
  ptnr2_label_comp_id: ptnr2_label_comp_id
90
137
  ptnr2_label_asym_id: ptnr2_label_asym_id
@@ -98,33 +145,56 @@ SSBOND:
98
145
  sym1: ptnr1_symmetry
99
146
  sym2: ptnr2_symmetry
100
147
  length: pdbx_dist_value
101
- residue1:
148
+ residue1_auth:
102
149
  chainID: ptnr1_auth_asym_id
103
150
  resName: ptnr1_auth_comp_id
104
151
  seqNum: ptnr1_auth_seq_id
105
152
  iCode: pdbx_ptnr1_PDB_ins_code
153
+ residue1:
154
+ chainID: ptnr1_label_asym_id
155
+ resName: ptnr1_label_comp_id
156
+ seqNum: ptnr1_label_seq_id
106
157
  ptnr1_label_atom_id: ptnr1_label_atom_id
107
158
  ptnr1_label_comp_id: ptnr1_label_comp_id
108
159
  ptnr1_label_asym_id: ptnr1_label_asym_id
109
160
  ptnr1_label_seq_id: ptnr1_label_seq_id
110
- residue2:
161
+ residue2_auth:
111
162
  chainID: ptnr2_auth_asym_id
112
163
  resName: ptnr2_auth_comp_id
113
164
  seqNum: ptnr2_auth_seq_id
114
165
  iCode: pdbx_ptnr2_PDB_ins_code
166
+ residue2:
167
+ chainID: ptnr2_label_asym_id
168
+ resName: ptnr2_label_comp_id
169
+ seqNum: ptnr2_label_seq_id
115
170
  ptnr2_label_atom_id: ptnr2_label_atom_id
116
171
  ptnr2_label_comp_id: ptnr2_label_comp_id
117
172
  ptnr2_label_asym_id: ptnr2_label_asym_id
118
173
  ptnr2_label_seq_id: ptnr2_label_seq_id
119
174
  SEQADV:
175
+ # _struct_ref_seq_dif.align_id
176
+ # _struct_ref_seq_dif.pdbx_pdb_id_code
177
+ # _struct_ref_seq_dif.mon_id
178
+ # _struct_ref_seq_dif.pdbx_pdb_strand_id
179
+ # _struct_ref_seq_dif.seq_num
180
+ # _struct_ref_seq_dif.pdbx_pdb_ins_code
181
+ # _struct_ref_seq_dif.pdbx_seq_db_name
182
+ # _struct_ref_seq_dif.pdbx_seq_db_accession_code
183
+ # _struct_ref_seq_dif.db_mon_id
184
+ # _struct_ref_seq_dif.pdbx_seq_db_seq_num
185
+ # _struct_ref_seq_dif.details
186
+ # _struct_ref_seq_dif.pdbx_auth_seq_num
187
+ # _struct_ref_seq_dif.pdbx_ordinal
120
188
  data_obj: struct_ref_seq_dif
121
189
  attr_map:
122
190
  idCode: pdbx_pdb_id_code
123
- residue:
191
+ residue_auth:
124
192
  chainID: pdbx_pdb_strand_id
125
193
  resName: mon_id
126
194
  seqNum: pdbx_auth_seq_num
127
195
  iCode: pdbx_pdb_ins_code
196
+ residue:
197
+ chainID:
128
198
  database: pdbx_seq_db_name
129
199
  dbAccession: pdbx_seq_db_accession_code
130
200
  dbRes: db_mon_id
@@ -174,15 +244,29 @@ REMARK.350:
174
244
  - 1
175
245
  - 2
176
246
  - 3
247
+ # _pdbx_unobs_or_zero_occ_residues.id
248
+ # _pdbx_unobs_or_zero_occ_residues.PDB_model_num
249
+ # _pdbx_unobs_or_zero_occ_residues.polymer_flag
250
+ # _pdbx_unobs_or_zero_occ_residues.occupancy_flag
251
+ # _pdbx_unobs_or_zero_occ_residues.auth_asym_id
252
+ # _pdbx_unobs_or_zero_occ_residues.auth_comp_id
253
+ # _pdbx_unobs_or_zero_occ_residues.auth_seq_id
254
+ # _pdbx_unobs_or_zero_occ_residues.PDB_ins_code
255
+ # _pdbx_unobs_or_zero_occ_residues.label_asym_id
256
+ # _pdbx_unobs_or_zero_occ_residues.label_comp_id
257
+ # _pdbx_unobs_or_zero_occ_residues.label_seq_id
177
258
  REMARK.465:
178
259
  data_obj: pdbx_unobs_or_zero_occ_residues
179
260
  tables:
180
261
  MISSING:
181
262
  row_attr_map:
182
263
  modelNum: PDB_model_num
183
- resName: auth_comp_id
184
- chainID: auth_asym_id
185
- seqNum: auth_seq_id
264
+ resName: label_comp_id
265
+ chainID: label_asym_id
266
+ seqNum: label_seq_id
267
+ auth_chainID: auth_asym_id
268
+ auth_resName: auth_comp_id
269
+ auth_seqNum: auth_seq_id
186
270
  iCode: PDB_ins_code
187
271
  blank_if_single_valued:
188
272
  - modelNum
@@ -405,7 +405,7 @@ record_formats:
405
405
  HELIX:
406
406
  type: 3
407
407
  fields:
408
- serNum: [nteger,[8,10]]
408
+ serNum: [Integer,[8,10]]
409
409
  helixID: [String,[12,14]]
410
410
  initRes: [Residue11,[16,26]]
411
411
  endRes: [Residue11,[28,38]]
@@ -3,7 +3,7 @@ requires = ["hatchling"]
3
3
  build-backend = "hatchling.build"
4
4
  [project]
5
5
  name = "pidibble"
6
- version = "1.2.0"
6
+ version = "1.2.2"
7
7
  authors = [
8
8
  { name="Cameron F Abrams", email="cfa22@drexel.edu" },
9
9
  ]