alphapulldown-input-parser 0.2.0__tar.gz → 0.3.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alphapulldown-input-parser
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Fold specification parser for AlphaPulldown
5
5
  Author-email: Kosinski Lab <alphapulldown@embl-hamburg.de>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "alphapulldown-input-parser"
7
- version = "0.2.0"
7
+ version = "0.3.0"
8
8
  description = "Fold specification parser for AlphaPulldown"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -309,20 +309,48 @@ def expand_fold_specification(
309
309
  if not pf:
310
310
  continue
311
311
 
312
- if pf.endswith(".json"):
313
- path_pf = Path(pf)
312
+ tokens = [token.strip() for token in pf.split(":")]
313
+ base_token = tokens[0] if tokens else ""
314
+
315
+ # JSON inputs: support optional copy number, but no ranges.
316
+ if base_token.endswith(".json"):
317
+ path_pf = Path(base_token)
314
318
  json_path: Optional[str] = None
315
319
  for json_key in (path_pf.name, path_pf.stem):
316
320
  json_path = index.json_path(json_key)
317
321
  if json_path:
318
- formatted_folds.append({"json_input": json_path})
322
+ # Handle optional copy number for JSON inputs.
323
+ if len(tokens) == 1:
324
+ copies = 1
325
+ else:
326
+ extra_tokens = tokens[1:]
327
+ # Ranges (e.g. "1-10") are not supported for JSON feature files.
328
+ if any("-" in tok for tok in extra_tokens):
329
+ _format_error(
330
+ spec,
331
+ msg="Region ranges are not supported for JSON feature files.",
332
+ )
333
+ if len(extra_tokens) != 1:
334
+ _format_error(
335
+ spec,
336
+ msg="JSON feature files support only an optional copy number.",
337
+ )
338
+ try:
339
+ copies = int(extra_tokens[0])
340
+ except ValueError:
341
+ _format_error(
342
+ spec,
343
+ msg="Copy number for JSON feature file must be an integer.",
344
+ )
345
+
346
+ for _ in range(copies):
347
+ formatted_folds.append({"json_input": json_path})
319
348
  break
320
349
  if json_path:
321
350
  continue
322
351
  missing_features.append(path_pf.name)
323
352
  continue
324
353
 
325
- tokens = [token.strip() for token in pf.split(":")]
326
354
  if not tokens or not tokens[0]:
327
355
  _format_error(spec, msg="Protein token is empty.")
328
356
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alphapulldown-input-parser
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Fold specification parser for AlphaPulldown
5
5
  Author-email: Kosinski Lab <alphapulldown@embl-hamburg.de>
6
6
  License: MIT
@@ -211,6 +211,32 @@ def patch_feature_index(monkeypatch):
211
211
  None,
212
212
  id="json_in_multiple_dirs",
213
213
  ),
214
+ pytest.param(
215
+ ["protein1.json:3"],
216
+ ["dir1"],
217
+ "+",
218
+ {"pkl": {}, "json": {"protein1.json": "dir1/protein1.json"}},
219
+ [
220
+ [
221
+ {"json_input": "dir1/protein1.json"},
222
+ {"json_input": "dir1/protein1.json"},
223
+ {"json_input": "dir1/protein1.json"},
224
+ ]
225
+ ],
226
+ None,
227
+ None,
228
+ id="json_with_copy_number",
229
+ ),
230
+ pytest.param(
231
+ ["protein1.json:1-10"],
232
+ ["dir1"],
233
+ "+",
234
+ {"pkl": {}, "json": {"protein1.json": "dir1/protein1.json"}},
235
+ None,
236
+ FormatError,
237
+ None,
238
+ id="json_with_range_not_supported",
239
+ ),
214
240
  ],
215
241
  )
216
242
  def test_parse_fold(