pidibble 1.5.0__tar.gz → 1.5.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 (52) hide show
  1. {pidibble-1.5.0 → pidibble-1.5.2}/PKG-INFO +3 -1
  2. {pidibble-1.5.0 → pidibble-1.5.2}/README.md +2 -0
  3. {pidibble-1.5.0 → pidibble-1.5.2}/pidibble/baseparsers.py +6 -3
  4. {pidibble-1.5.0 → pidibble-1.5.2}/pidibble/pdbparse.py +25 -12
  5. {pidibble-1.5.0 → pidibble-1.5.2}/pyproject.toml +1 -1
  6. {pidibble-1.5.0 → pidibble-1.5.2}/.github/workflows/release.yaml +0 -0
  7. {pidibble-1.5.0 → pidibble-1.5.2}/.gitignore +0 -0
  8. {pidibble-1.5.0 → pidibble-1.5.2}/.readthedocs.yaml +0 -0
  9. {pidibble-1.5.0 → pidibble-1.5.2}/LICENSE +0 -0
  10. {pidibble-1.5.0 → pidibble-1.5.2}/MANIFEST.in +0 -0
  11. {pidibble-1.5.0 → pidibble-1.5.2}/docs/Makefile +0 -0
  12. {pidibble-1.5.0 → pidibble-1.5.2}/docs/make.bat +0 -0
  13. {pidibble-1.5.0 → pidibble-1.5.2}/docs/requirements.txt +0 -0
  14. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/_static/css/custom.css +0 -0
  15. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/api/API.rst +0 -0
  16. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/api/pidibble.baseparsers.rst +0 -0
  17. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/api/pidibble.baserecord.rst +0 -0
  18. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/api/pidibble.hex.rst +0 -0
  19. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/api/pidibble.mmcif_parse.rst +0 -0
  20. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/api/pidibble.pdbparse.rst +0 -0
  21. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/api/pidibble.pdbrecord.rst +0 -0
  22. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/api/pidibble.resources.rst +0 -0
  23. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/api/pidibble.rst +0 -0
  24. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/conf.py +0 -0
  25. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/index.rst +0 -0
  26. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/installation.rst +0 -0
  27. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/notes.md +0 -0
  28. {pidibble-1.5.0 → pidibble-1.5.2}/docs/source/usage.rst +0 -0
  29. {pidibble-1.5.0 → pidibble-1.5.2}/pidibble/__init__.py +0 -0
  30. {pidibble-1.5.0 → pidibble-1.5.2}/pidibble/baserecord.py +0 -0
  31. {pidibble-1.5.0 → pidibble-1.5.2}/pidibble/hex.py +0 -0
  32. {pidibble-1.5.0 → pidibble-1.5.2}/pidibble/mmcif_parse.py +0 -0
  33. {pidibble-1.5.0 → pidibble-1.5.2}/pidibble/pdbrecord.py +0 -0
  34. {pidibble-1.5.0 → pidibble-1.5.2}/pidibble/resources/__init__.py +0 -0
  35. {pidibble-1.5.0 → pidibble-1.5.2}/pidibble/resources/mmcif_format.yaml +0 -0
  36. {pidibble-1.5.0 → pidibble-1.5.2}/pidibble/resources/pdb_format.yaml +0 -0
  37. {pidibble-1.5.0 → pidibble-1.5.2}/tests/__init__.py +0 -0
  38. {pidibble-1.5.0 → pidibble-1.5.2}/tests/conftest.py +0 -0
  39. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_hex/my_system.pdb +0 -0
  40. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_hex.py +0 -0
  41. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/4tvp.cif +0 -0
  42. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/4tvp.pdb +0 -0
  43. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/4zmj-newresnames.pdb +0 -0
  44. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/4zmj.cif +0 -0
  45. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/4zmj.pdb +0 -0
  46. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/6m0j.pdb +0 -0
  47. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/8fae.cif +0 -0
  48. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/G.pdb +0 -0
  49. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/GG.pdb +0 -0
  50. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/test.pdb +0 -0
  51. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb/test_pdb_format.yaml +0 -0
  52. {pidibble-1.5.0 → pidibble-1.5.2}/tests/unit/test_rcsb.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pidibble
3
- Version: 1.5.0
3
+ Version: 1.5.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/
@@ -91,6 +91,8 @@ ATOM
91
91
  ```
92
92
 
93
93
  ## Release History
94
+ * 1.5.2
95
+ * added capability to download from OPM and split out DUM resi's into a "dum" pdb
94
96
  * 1.4.2
95
97
  * updated alphafold interface
96
98
  * 1.4.1
@@ -73,6 +73,8 @@ ATOM
73
73
  ```
74
74
 
75
75
  ## Release History
76
+ * 1.5.2
77
+ * added capability to download from OPM and split out DUM resi's into a "dum" pdb
76
78
  * 1.4.2
77
79
  * updated alphafold interface
78
80
  * 1.4.1
@@ -87,7 +87,7 @@ class StringParser:
87
87
  self.fields={k:v for k,v in fmtdict.items()}
88
88
  self.allowed=allowed
89
89
 
90
- def parse(self,record):
90
+ def parse(self, record):
91
91
  """
92
92
  Parse a fixed-width string record into a dictionary of fields.
93
93
 
@@ -104,7 +104,10 @@ class StringParser:
104
104
  if len(record)>80:
105
105
  logger.warning('The following record exceeds 80 bytes in length:')
106
106
  self.report_record_error(record)
107
- assert len(record)<=80,f'Record is too long; something wrong with your PDB file?'
107
+ logger.warning('Stripping...')
108
+ record = record.strip()
109
+ if len(record)>80:
110
+ raise ValueError(f'Record is too long; something wrong with your PDB file?')
108
111
  input_dict={}
109
112
  record+=' '*(80-len(record)) # pad
110
113
  for k,v in self.fields.items():
@@ -141,7 +144,7 @@ class StringParser:
141
144
  """
142
145
  if byte_range:
143
146
  record=record[:byte_range[0]-1]+'\033[91m'+record[byte_range[0]:byte_range[1]+1]+'\033[0m'+record[byte_range[1]+1:]
144
- repstr=_cols+'\n'+record
147
+ repstr=_cols+'\n'+record+'|'
145
148
  logger.warning(repstr)
146
149
 
147
150
  def report_field_error(self,record,k):
@@ -120,7 +120,7 @@ class PDBParser:
120
120
  bool
121
121
  True if the file was successfully fetched, False otherwise.
122
122
  """
123
- assert self.source_db is not None or self.filepath is not None, f'source_db or filepath must be specified for fetch()'
123
+ assert self.source_db is not None or self.filepath is not None, f'source_db {self.source_db} or filepath {self.filepath} must be specified for fetch()'
124
124
  if self.source_db is not None and self.source_id is None:
125
125
  raise ValueError(f'You must specify a source ID code for source_db {self.source_db}')
126
126
  if self.source_db is not None and self.source_db not in ['rcsb', 'alphafold', 'opm']:
@@ -176,6 +176,19 @@ class PDBParser:
176
176
  except:
177
177
  logger.warning(f'Could not fetch {self.filepath.name} from {self.source_db}')
178
178
  return False
179
+ logger.warning(f'Stripping blanks and END lines from OPM pdb')
180
+ badlines = self.filepath.read_text().split('\n')
181
+ with open(self.filepath.name, 'w') as f_base:
182
+ with open(f'{self.filepath.stem}-dum.pdb', 'w') as f_dum:
183
+ f = f_base
184
+ for line in badlines:
185
+ sline = line.strip()
186
+ if not sline.startswith('END') and len(sline) > 0:
187
+ f.write(sline+'\n')
188
+ if sline.startswith('END') and f is f_base:
189
+ f = f_dum
190
+ logger.debug(f'Generated {self.filepath.name} and {self.filepath.stem}-dum.pdb')
191
+
179
192
  return True
180
193
  case '_':
181
194
  logger.debug(f'Source db {self.source_db} is not recognized.')
@@ -187,10 +200,10 @@ class PDBParser:
187
200
  This method opens the PDB file, reads its contents, and splits it into lines.
188
201
  If the last line is empty, it removes it from the list of lines.
189
202
  """
190
- with open(self.filepath,'r') as f:
191
- self.pdb_lines=f.read().split('\n')
192
- if self.pdb_lines[-1]=='':
193
- self.pdb_lines=self.pdb_lines[:-1]
203
+ with open(self.filepath, 'r') as f:
204
+ self.pdb_lines = f.read().split('\n')
205
+ if self.pdb_lines[-1] == '':
206
+ self.pdb_lines = self.pdb_lines[:-1]
194
207
 
195
208
  def read_mmCIF(self):
196
209
  """
@@ -198,16 +211,16 @@ class PDBParser:
198
211
  This method uses the :class:`mmcif.io.IoAdapterCore.IoAdapterCore` to read the
199
212
  mmCIF file and store the data in :attr:`PDBParser.cif_data`.
200
213
  """
201
- io=IoAdapterCore()
202
- l_dc=io.readFile(self.filepath)
203
- self.cif_data=l_dc[0]
214
+ io = IoAdapterCore()
215
+ l_dc = io.readFile(self.filepath)
216
+ self.cif_data = l_dc[0]
204
217
 
205
218
  def read(self):
206
219
  """
207
220
  Read the PDB or mmCIF file based on the input format.
208
221
  This method checks the input format and calls the appropriate read method.
209
222
  """
210
- if self.input_format=='mmCIF':
223
+ if self.input_format == 'mmCIF':
211
224
  self.read_mmCIF()
212
225
  else:
213
226
  self.read_PDB()
@@ -219,7 +232,7 @@ class PDBParser:
219
232
  If the input format is mmCIF, it uses the :class:`.mmcif_parse.MMCIF_Parser` to parse the mmCIF data.
220
233
  If the input format is PDB, it uses the :class:`.pdbrecord.PDBRecord` class to parse the PDB lines.
221
234
  """
222
- if self.input_format=='mmCIF':
235
+ if self.input_format == 'mmCIF':
223
236
  self.parse_mmCIF()
224
237
  else:
225
238
  self.parse_PDB()
@@ -230,8 +243,8 @@ class PDBParser:
230
243
  This method uses the :class:`.mmcif_parse.MMCIF_Parser` to parse the mmCIF data and store the parsed records
231
244
  in :attr:`PDBParser.parsed`.
232
245
  """
233
- mmcif_parser=MMCIF_Parser(self.mmcif_format_dict,self.pdb_format_dict['record_formats'],self.cif_data)
234
- self.parsed=mmcif_parser.parse()
246
+ mmcif_parser = MMCIF_Parser(self.mmcif_format_dict,self.pdb_format_dict['record_formats'],self.cif_data)
247
+ self.parsed = mmcif_parser.parse()
235
248
 
236
249
  def parse_PDB(self):
237
250
  """
@@ -3,7 +3,7 @@ requires = ["hatchling"]
3
3
  build-backend = "hatchling.build"
4
4
  [project]
5
5
  name = "pidibble"
6
- version = "1.5.0"
6
+ version = "1.5.2"
7
7
  authors = [
8
8
  { name="Cameron F Abrams", email="cfa22@drexel.edu" },
9
9
  ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes