stjames 0.0.57__py3-none-any.whl → 0.0.59__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 stjames might be problematic. Click here for more details.

@@ -399,12 +399,12 @@ def update_models_list(mmcif_dict: dict[str, Any], data_dict: dict[str, Any]) ->
399
399
  # sequences = make_sequences(mmcif_dict)
400
400
  secondary_structure = make_secondary_structure(mmcif_dict)
401
401
  aniso = make_aniso(mmcif_dict)
402
- model: dict[str, Any] = {"polymer": {}, "non-polymer": {}, "water": {}, "branched": {}}
402
+ model: dict[str, Any] = {"polymer": {}, "non_polymer": {}, "water": {}, "branched": {}}
403
403
  model_num = mmcif_dict["atom_site"][0]["pdbx_PDB_model_num"]
404
404
  for atom in mmcif_dict["atom_site"]:
405
405
  if atom["pdbx_PDB_model_num"] != model_num:
406
406
  data_dict["models"].append(model)
407
- model = {"polymer": {}, "non-polymer": {}, "water": {}, "branched": {}}
407
+ model = {"polymer": {}, "non_polymer": {}, "water": {}, "branched": {}}
408
408
  model_num = atom["pdbx_PDB_model_num"]
409
409
  mol_type = types[entities[atom["label_asym_id"]]]
410
410
  if mol_type == "polymer" or mol_type == "branched":
@@ -501,13 +501,13 @@ def add_atom_to_polymer(atom: dict[str, Any], aniso: dict[int, Any], model: dict
501
501
 
502
502
 
503
503
  def add_atom_to_non_polymer(atom: dict[str, Any], aniso: dict[int, Any], model: dict[str, Any], mol_type: str, names: dict[str, Any]) -> None:
504
- """Takes an MMCIF atom dictionary, converts it, and adds it to a non-polymer
504
+ """Takes an MMCIF atom dictionary, converts it, and adds it to a non_polymer
505
505
  dictionary.
506
506
 
507
507
  :param dict atom: the .mmcif dictionary to read.
508
508
  :param dict aniso: lookup dictionary for anisotropy information.
509
509
  :param dict model: the model to update.
510
- :param str mol_type: non-polymer or water.
510
+ :param str mol_type: non_polymer or water.
511
511
  :param dict names: the lookup dictionary for full name information."""
512
512
 
513
513
  mol_id = make_residue_id(atom)
@@ -606,6 +606,16 @@ def atom_dict_to_atom_dict(d: dict[str, Any], aniso_dict: dict[int, Any]) -> dic
606
606
  for key in ["x", "y", "z", "charge", "bvalue", "occupancy"]:
607
607
  if atom[key] is not None:
608
608
  atom[key] = float(atom[key])
609
+ if atom["charge"] == 0:
610
+ atom["charge"] = None
611
+ if not atom["is_hetatm"]:
612
+ atom["is_hetatm"] = None
613
+ if not atom["alt_loc"]:
614
+ atom["alt_loc"] = None
615
+ if atom["occupancy"] == 1:
616
+ atom["occupancy"] = None
617
+ if atom["name"] == atom["element"]:
618
+ atom["name"] = None
609
619
  return atom
610
620
 
611
621
 
@@ -145,7 +145,7 @@ def update_models_list(pdb_dict: dict[str, Any], data_dict: dict[str, Any]) -> N
145
145
  for model_lines in pdb_dict["MODEL"]:
146
146
  aniso = make_aniso(model_lines)
147
147
  last_ter = get_last_ter_line(model_lines)
148
- model: dict[str, Any] = {"polymer": {}, "non-polymer": {}, "water": {}}
148
+ model: dict[str, Any] = {"polymer": {}, "non_polymer": {}, "water": {}}
149
149
  for index, line in enumerate(model_lines):
150
150
  if line[:6] in ["ATOM ", "HETATM"]:
151
151
  chain_id = line[21] if index < last_ter else id_from_line(line)
@@ -512,7 +512,7 @@ def add_atom_to_non_polymer(line: str, model: dict[Any, Any], res_id: str, aniso
512
512
  :param str res_id: the molecule ID to add to.
513
513
  :param dict aniso_dict: lookup dictionary for anisotropy information."""
514
514
 
515
- key = "water" if line[17:20] in ["HOH", "DOD"] else "non-polymer"
515
+ key = "water" if line[17:20] in ["HOH", "DOD"] else "non_polymer"
516
516
  try:
517
517
  model[key][res_id]["atoms"][int(line[6:11])] = atom_line_to_dict(line, aniso_dict)
518
518
  except Exception:
@@ -557,6 +557,10 @@ def atom_line_to_dict(line: str, aniso_dict: dict[Any, Any]) -> dict[str, Any]:
557
557
  a["is_hetatm"] = None
558
558
  if not a["alt_loc"]:
559
559
  a["alt_loc"] = None
560
+ if a["occupancy"] == 1:
561
+ a["occupancy"] = None
562
+ if a["name"] == a["element"]:
563
+ a["name"] = None
560
564
  return a
561
565
 
562
566
 
stjames/pdb.py CHANGED
@@ -22,7 +22,7 @@ class PDBAtom(BaseModel):
22
22
  y: float
23
23
  z: float
24
24
  element: str
25
- name: str
25
+ name: str | None = None
26
26
  charge: float | None = None
27
27
  occupancy: float | None = None
28
28
  alt_loc: str | None = None
@@ -84,7 +84,7 @@ class PDBModel(BaseModel):
84
84
  model_config = ConfigDict(extra=EXTRA)
85
85
 
86
86
  polymer: dict[str, PDBPolymer] = {}
87
- non_polymer: dict[str, PDBNonPolymer] = Field(alias="non-polymer", default_factory=dict)
87
+ non_polymer: dict[str, PDBNonPolymer] = {}
88
88
  branched: dict[str, Any] = {}
89
89
  water: dict[str, PDBWater] = {}
90
90
 
@@ -413,12 +413,15 @@ def _format_atom_line(
413
413
  else:
414
414
  chg = " "
415
415
 
416
+ atom_name = atom.name if atom.name else atom.element
417
+ occupancy = atom.occupancy if atom.occupancy else 1.0
418
+
416
419
  # Construct the line.
417
420
  # Use exact spacing & field widths to match PDB guidelines.
418
421
  line = (
419
422
  f"{record_type}"
420
423
  f"{serial:5d} " # atom serial number (columns 7-11)
421
- f"{atom.name:<4}" # atom name (columns 13-16, left-justified in this snippet)
424
+ f"{atom_name:<4}" # atom name (columns 13-16, left-justified in this snippet)
422
425
  f"{alt_loc_char}" # altLoc (column 17)
423
426
  f"{residue_name:>3}" # residue name (columns 18-20)
424
427
  f" {chain_char}" # chain ID (column 22)
@@ -427,7 +430,7 @@ def _format_atom_line(
427
430
  f"{atom.x:8.3f}" # x (columns 31-38)
428
431
  f"{atom.y:8.3f}" # y (columns 39-46)
429
432
  f"{atom.z:8.3f}" # z (columns 47-54)
430
- f"{atom.occupancy:6.2f}" # occupancy (columns 55-60)
433
+ f"{occupancy:6.2f}" # occupancy (columns 55-60)
431
434
  f"{atom.bvalue:6.2f}" # temp factor (columns 61-66)
432
435
  f" " # columns 67-76 (padding)
433
436
  f"{atom.element:>2}" # element (columns 77-78)
@@ -468,6 +471,8 @@ def _format_anisou_line(
468
471
  else:
469
472
  chg = " "
470
473
 
474
+ atom_name = atom.name if atom.name else atom.element
475
+
471
476
  if atom.anisotropy:
472
477
  aniso_lines = (
473
478
  f"{_float_to_pdb_string(atom.anisotropy[0]):>7}" # x (columns 29-35)
@@ -493,7 +498,7 @@ def _format_anisou_line(
493
498
  line = (
494
499
  f"{record_type}"
495
500
  f"{serial:5d} " # atom serial number (columns 7-11)
496
- f"{atom.name:<4}" # atom name (columns 13-16, left-justified in this snippet)
501
+ f"{atom_name:<4}" # atom name (columns 13-16, left-justified in this snippet)
497
502
  f"{alt_loc_char}" # altLoc (column 17)
498
503
  f"{residue_name:>3}" # residue name (columns 18-20)
499
504
  f" {chain_char}" # chain ID (column 22)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: stjames
3
- Version: 0.0.57
3
+ Version: 0.0.59
4
4
  Summary: standardized JSON atom/molecule encoding scheme
5
5
  Author-email: Corin Wagen <corin@rowansci.com>
6
6
  Project-URL: Homepage, https://github.com/rowansci/stjames
@@ -15,7 +15,7 @@ stjames/method.py,sha256=5hBHk2xQLpxZ52LwJ9FHWaqQMdFKnsbQEOxaVe6O4Go,2321
15
15
  stjames/mode.py,sha256=xw46Cc7f3eTS8i35qECi-8DocAlANhayK3w4akD4HBU,496
16
16
  stjames/molecule.py,sha256=DeNYmFdvbuKeXvLqlu-UxHMyZVK6y4j-Lw3HITGMnHw,12406
17
17
  stjames/opt_settings.py,sha256=gxXGtjy9l-Q5Wen9eO6T6HHRCuS8rfOofdVQIJj0JcI,550
18
- stjames/pdb.py,sha256=u2DHcKER2igG0Tn94lSSFuwNRCEtk3ye8C1k6nzW6ew,25274
18
+ stjames/pdb.py,sha256=UxbgtIbc28L9O74AESYQiLBeiWZhdEbrBUT3mlyqRt8,25411
19
19
  stjames/periodic_cell.py,sha256=eV_mArsY_MPEFSrFEsTC-CyCc6V8ITAXdk7yhjjNI7M,1080
20
20
  stjames/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  stjames/scf_settings.py,sha256=WotVgVrayQ_8PUHP39zVtG7iLT9PV41lpzruttFACP8,2356
@@ -27,8 +27,8 @@ stjames/thermochem_settings.py,sha256=ZTLz31v8Ltutde5Nfm0vH5YahWjcfFWfr_R856Kffx
27
27
  stjames/types.py,sha256=hw-3UBikESvN3DzfK5doZB030kIEfx9gC3yBkIbebsI,3764
28
28
  stjames/atomium_stjames/__init__.py,sha256=gZkzC7i9D_fmWUTN55gtygITo3-qvJUda5CXLR0jyCQ,306
29
29
  stjames/atomium_stjames/data.py,sha256=-hzwBpTHq5JetsOVyopUJswKnKAkMtJ_XkONxjXVupU,5675
30
- stjames/atomium_stjames/mmcif.py,sha256=16LNhQW7GkwEmRAG2lDEnhQaeBabtzIiEbzjjBnLhNg,27108
31
- stjames/atomium_stjames/pdb.py,sha256=nkCqdc6fy6rKNcIZZDysDLTdlPJWWRmTYBYEFr1wcAQ,22365
30
+ stjames/atomium_stjames/mmcif.py,sha256=SjyWd1Zg_Pd0zM9OhaZ3rWGg3TDUuRJS88Zsvdbi-5M,27420
31
+ stjames/atomium_stjames/pdb.py,sha256=C2mEcBDDrnoXD9ZCMIH2uJpjiWPJy6ktXq8IFZsrQKM,22482
32
32
  stjames/atomium_stjames/utilities.py,sha256=PSrOGn6MED4sXvbTLb65Jv20Ylptz4slZtjWEDzeRrI,4776
33
33
  stjames/data/__init__.py,sha256=O59Ksp7AIqwOELCWymfCx7YeBzwNOGCMlGQi7tNLqiE,24
34
34
  stjames/data/bragg_radii.json,sha256=hhbn-xyZNSdmnULIjN2Cvq-_BGIZIqG243Ls_mey61w,1350
@@ -57,8 +57,8 @@ stjames/workflows/scan.py,sha256=uNSuUmVMAV4exNvcv1viVe7930i7GZMn7RtEimnwEE8,100
57
57
  stjames/workflows/spin_states.py,sha256=b-uCf-pHjF_JHbExeb5GdRToE0pIxP0JTd50U130ckI,4693
58
58
  stjames/workflows/tautomer.py,sha256=x3TC8hkMs87ZUodLyhce5EUzYoV276ePfPMi7ISWyNU,651
59
59
  stjames/workflows/workflow.py,sha256=tIu5naADYgYS7kdW8quvGEWHWosBcrIdcD7L86v-uMQ,976
60
- stjames-0.0.57.dist-info/LICENSE,sha256=i7ehYBS-6gGmbTcgU4mgk28pyOx2kScJ0kcx8n7bWLM,1084
61
- stjames-0.0.57.dist-info/METADATA,sha256=FNtbr8EoBU0v70X_3-1GaQtu1MniVytVf3g9vgHSarI,1713
62
- stjames-0.0.57.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
63
- stjames-0.0.57.dist-info/top_level.txt,sha256=FYCwxl6quhYOAgG-mnPQcCK8vsVM7B8rIUrO-WrQ_PI,8
64
- stjames-0.0.57.dist-info/RECORD,,
60
+ stjames-0.0.59.dist-info/LICENSE,sha256=i7ehYBS-6gGmbTcgU4mgk28pyOx2kScJ0kcx8n7bWLM,1084
61
+ stjames-0.0.59.dist-info/METADATA,sha256=SDY-2LM12v5-wk8e25U1-U6L9ylteTXnMbm1FLkdohc,1713
62
+ stjames-0.0.59.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
63
+ stjames-0.0.59.dist-info/top_level.txt,sha256=FYCwxl6quhYOAgG-mnPQcCK8vsVM7B8rIUrO-WrQ_PI,8
64
+ stjames-0.0.59.dist-info/RECORD,,