stcrpy 1.0.5__py3-none-any.whl → 1.0.6__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.
@@ -8,6 +8,7 @@ from ..tcr_processing.TCRParser import TCRParser
8
8
  try:
9
9
  import plip
10
10
  from plip.basic.remote import VisualizerData
11
+ from plip.visualization.visualize import visualize_in_pymol
11
12
 
12
13
  except ModuleNotFoundError as e:
13
14
  if "pymol" in str(e):
@@ -413,7 +414,8 @@ class TCRInteractionProfiler:
413
414
  heatmap_b[pair[0][1], ligand_number_mapping[int(pair[1][1])]] = (
414
415
  heatmap_b[pair[0][1], ligand_number_mapping[int(pair[1][1])]] + 1
415
416
  )
416
- ax_beta.imshow(heatmap_b.T, cmap="PuRd")
417
+
418
+ im_beta = ax_beta.imshow(heatmap_b.T, cmap="PuRd")
417
419
  for i in plot_index:
418
420
  ax_beta.axhline(y=i - 0.5, color="blue", linewidth=1)
419
421
  ax_beta.axhline(y=i + 0.5, color="blue", linewidth=1)
@@ -427,6 +429,11 @@ class TCRInteractionProfiler:
427
429
  ax_beta.set_xticks([], [], rotation=90)
428
430
  ax_beta.set_yticks([], [])
429
431
 
432
+ cbar = fig.colorbar(
433
+ im_beta, ax=[ax_alpha, ax_beta], orientation="vertical", shrink=0.8
434
+ )
435
+ cbar.set_label("Interaction count", rotation=270, labelpad=15)
436
+
430
437
  if save_as is not None:
431
438
  fig.savefig(save_as, bbox_inches="tight", dpi=200)
432
439
 
@@ -1130,9 +1130,11 @@ class TCRParser(PDBParser, MMCIFParser):
1130
1130
  and len(mhc_complexes) > 0
1131
1131
  ): # check if all TCRs have been paired if MHC is present.
1132
1132
  # try searching for symmetry mates
1133
- symmetry_mates = self._generate_symmetry_mates()
1134
- mhc_complexes.extend([m for t in symmetry_mates for m in t.get_MHCs()])
1135
-
1133
+ try:
1134
+ symmetry_mates = self._generate_symmetry_mates()
1135
+ mhc_complexes.extend([m for t in symmetry_mates for m in t.get_MHCs()])
1136
+ except Exception as e:
1137
+ warnings.warn(f"Symmetry mate generation failed with: {str(e)}")
1136
1138
  (
1137
1139
  model,
1138
1140
  tcell_receptors,
@@ -35,33 +35,39 @@ def get_symmetry_mates(filename):
35
35
  tcp = TCRParser()
36
36
  pdp = PDBParser(QUIET=True)
37
37
  pdbio = PDBIO()
38
- with tempfile.TemporaryDirectory() as tmpdir:
39
- for i, obj in enumerate(cmd.get_object_list()):
40
- fn = os.path.join(tmpdir, f"{obj_name}_symmetry_mate_{i}.pdb")
41
- cmd.save(fn, obj)
42
- symmetry_mate = pdp.get_structure("tmp", fn)
43
- if i == 0:
44
- chain_ids = generate_chain_id_list(
45
- len(list(symmetry_mate.get_chains()) * len(cmd.get_object_list()))
46
- )
47
- for c in symmetry_mate.get_chains():
48
- chain_ids.remove(
49
- c.id
50
- ) # remove all chain ids of the original structure
51
- if i > 0: # Skip the original structure
52
- # rename chain ids, this cannot be done directly to TCR structure without breaking the TCR and MHC chain assignments.
53
- for chain in reversed(list(symmetry_mate.get_chains())):
54
- symmetry_mate[0].detach_child(chain.id)
55
- new_id = chain_ids.pop(0)
56
- chain.id = new_id
57
- symmetry_mate[0].add(chain)
58
- pdbio.set_structure(symmetry_mate)
59
- pdbio.save(fn)
38
+ try:
39
+ with tempfile.TemporaryDirectory() as tmpdir:
40
+ for i, obj in enumerate(cmd.get_object_list()):
41
+ fn = os.path.join(tmpdir, f"{obj_name}_symmetry_mate_{i}.pdb")
42
+ cmd.save(fn, obj)
43
+ symmetry_mate = pdp.get_structure("tmp", fn)
44
+ if i == 0:
45
+ chain_ids = generate_chain_id_list(
46
+ len(
47
+ list(symmetry_mate.get_chains())
48
+ * len(cmd.get_object_list())
49
+ )
50
+ )
51
+ for c in symmetry_mate.get_chains():
52
+ chain_ids.remove(
53
+ c.id
54
+ ) # remove all chain ids of the original structure
55
+ if i > 0: # Skip the original structure
56
+ # rename chain ids, this cannot be done directly to TCR structure without breaking the TCR and MHC chain assignments.
57
+ for chain in reversed(list(symmetry_mate.get_chains())):
58
+ symmetry_mate[0].detach_child(chain.id)
59
+ new_id = chain_ids.pop(0)
60
+ chain.id = new_id
61
+ symmetry_mate[0].add(chain)
62
+ pdbio.set_structure(symmetry_mate)
63
+ pdbio.save(fn)
60
64
 
61
- symmetry_mate = tcp.get_tcr_structure(
62
- f"{obj_name}_symmetry_{i}", fn, include_symmetry_mates=False
63
- )
64
- tcr_symmetry_mates.append(symmetry_mate)
65
+ symmetry_mate = tcp.get_tcr_structure(
66
+ f"{obj_name}_symmetry_{i}", fn, include_symmetry_mates=False
67
+ )
68
+ tcr_symmetry_mates.append(symmetry_mate)
69
+ except Exception as e:
70
+ warnings.warn(f"Symmetry mate generation failed with: {str(e)}")
65
71
 
66
72
  # clean up the pymol cmd space
67
73
  for obj in cmd.get_object_list():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stcrpy
3
- Version: 1.0.5
3
+ Version: 1.0.6
4
4
  Summary: Set of methods to parse, annotate, and calculate features of TCR structures
5
5
  Maintainer-email: Nele Quast <quast@stats.ox.ac.uk>
6
6
  Requires-Python: >=3.10
@@ -12,6 +12,7 @@ Requires-Dist: numpy==1.26.4
12
12
  Requires-Dist: lxml
13
13
  Requires-Dist: openbabel-wheel==3.1.1.21
14
14
  Requires-Dist: rdkit
15
+ Requires-Dist: pyhmmer==0.11.4
15
16
  Requires-Dist: anarci-mhc
16
17
  Requires-Dist: pandas
17
18
  Requires-Dist: matplotlib
@@ -42,7 +43,7 @@ Please feel free to reach out with any comments or feedback.
42
43
 
43
44
  Under review, please cite:
44
45
 
45
- **Quast, N. , Deane, C., & Raybould, M. (2025). STCRpy: a software suite for TCR:pMHC structure parsing, interaction profiling, and machine learning dataset preparation. BioRxiv. https://doi.org/10.1101/2025.04.25.650667**
46
+ **Quast, N. , Deane, C., & Raybould, M. (2025). STCRpy: a software suite for TCR:pMHC structure parsing, interaction profiling, and machine learning dataset preparation. Bioinformatics. [https://doi.org/10.1093/bioinformatics/btaf566](https://doi.org/10.1093/bioinformatics/btaf566)**
46
47
 
47
48
  <img src="./stcrpy_main_fig.png" alt="drawing" width="1500"/>
48
49
 
@@ -33,7 +33,7 @@ stcrpy/tcr_geometry/reference_data/reference_D.pdb,sha256=O9LHeh3bWxeEWwuTcp1Hwz
33
33
  stcrpy/tcr_geometry/reference_data/reference_G.pdb,sha256=Fs8e_UDb6dI1qqhNSttWaHrzkjgzjFpMpC38_W9OXTg,2434
34
34
  stcrpy/tcr_geometry/reference_data/reference_data.py,sha256=q3L-cQ1UQUfZxeIMKIiiase_6SEEuWlx7UsLndwNLAk,1658
35
35
  stcrpy/tcr_interactions/PLIPParser.py,sha256=zetY_LvH_8E-26xXc02c7_edoHWEwIWB9_XIu1szRcA,5785
36
- stcrpy/tcr_interactions/TCRInteractionProfiler.py,sha256=56NeZZVIAjEqbbsM_qepjJQjoaR-RFt5OhhtcebiunI,17772
36
+ stcrpy/tcr_interactions/TCRInteractionProfiler.py,sha256=Bn2HAHG158nE3PhL1UoaZCaexm-gK9F9_exYtTCJXtQ,18038
37
37
  stcrpy/tcr_interactions/TCRpMHC_PLIP_Model_Parser.py,sha256=-fm_rtPJhU-h3WuX1U5Cv3vjO0eAlzwbm1HTreQIDCI,5464
38
38
  stcrpy/tcr_interactions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  stcrpy/tcr_interactions/utils.py,sha256=KEGybd1ugZvFdj4Gqn9Xo4lnJbU1ivADmEDjkvuaNiw,5177
@@ -59,7 +59,7 @@ stcrpy/tcr_processing/Model.py,sha256=K8wTrSCECHyqJX9811wU9MxgdGDVyCXraQ4-rOOa08
59
59
  stcrpy/tcr_processing/Select.py,sha256=VuVSgmqHBPD1DGRumM44HDzcQ-aQOwg_6zQHM3Ulm0U,3543
60
60
  stcrpy/tcr_processing/TCR.py,sha256=dcMdw2WEGa-BUZUqAAe0Dw4U2Qyh1xYUaS4N7E7J2AQ,33220
61
61
  stcrpy/tcr_processing/TCRIO.py,sha256=tSJLVN6MG6gyT26PreVJOz5DqD1e-VsBjBpu3mBBPKg,1501
62
- stcrpy/tcr_processing/TCRParser.py,sha256=Raz2W9tygpK3knzjIVCfqUyCGSFA7yhh4UBT5wuWLM4,56134
62
+ stcrpy/tcr_processing/TCRParser.py,sha256=4C7wmW6ENgNLAZsxoxzl3lk6UFQmYOPcMLvIzjmms8k,56274
63
63
  stcrpy/tcr_processing/TCRStructure.py,sha256=yFiUeo02KXIBBEljy0mebv5ol5uCQRTy-Sfs94Rt6Hc,3810
64
64
  stcrpy/tcr_processing/TCRchain.py,sha256=2CdP_JX5LG7nM8Lsuhcevf7SyRaQUZlizt3ntEYVPjg,4769
65
65
  stcrpy/tcr_processing/__init__.py,sha256=BefeJ0jefteeOzWrkOMvxLCvzd0aJDhXWrdTm7zlP94,94
@@ -68,12 +68,12 @@ stcrpy/tcr_processing/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
68
68
  stcrpy/tcr_processing/utils/common.py,sha256=5e-dP6jPlaFZEErusakdQYpyj79E3WvEGF5-sG0LitI,1869
69
69
  stcrpy/tcr_processing/utils/constants.py,sha256=AHReE1QkeqTnhjvQI7nrPqLF4XdtzHV9C1w1uHTiVcM,8151
70
70
  stcrpy/tcr_processing/utils/region_definitions.py,sha256=t3HT6FHFlGqS_DdV2xWLdTxhIUEjWHsf_0_f-06w94E,19198
71
- stcrpy/tcr_processing/utils/symmetry_mates.py,sha256=9U29IHs63llBzV9xBNCmv4BKTIachwO7T3orHywDn48,3262
71
+ stcrpy/tcr_processing/utils/symmetry_mates.py,sha256=dvyfEWovnjh9SZMqSTCsO_HgpyA2TqxIwHkmG_HxcK8,3557
72
72
  stcrpy/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
73
  stcrpy/utils/error_stream.py,sha256=BLHJnf-tWU41MXh6sHSZgkTFOMiWZsCgwM2qIKBnwr4,247
74
- stcrpy-1.0.5.dist-info/licenses/LICENCE,sha256=G1FnVDsfeYoveKTu9Xaqukcm-4xZ4mzakjLpFMnNfJ0,1507
75
- stcrpy-1.0.5.dist-info/licenses/stcrpy/tcr_geometry/TCRCoM_LICENCE,sha256=93k_qqF0rgpyWEmxpcl2sbZS3CK1dkGrIuvJtKsBlCA,7844
76
- stcrpy-1.0.5.dist-info/METADATA,sha256=6rbC0l_TnXd9UMykkNKAlQCsy4VuBBud4DPQEXh-FtY,10512
77
- stcrpy-1.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
78
- stcrpy-1.0.5.dist-info/top_level.txt,sha256=kAkgyHyGW-_YswJpcuA3pSqzuQVbUggFUmZg2OTx_B8,16
79
- stcrpy-1.0.5.dist-info/RECORD,,
74
+ stcrpy-1.0.6.dist-info/licenses/LICENCE,sha256=G1FnVDsfeYoveKTu9Xaqukcm-4xZ4mzakjLpFMnNfJ0,1507
75
+ stcrpy-1.0.6.dist-info/licenses/stcrpy/tcr_geometry/TCRCoM_LICENCE,sha256=93k_qqF0rgpyWEmxpcl2sbZS3CK1dkGrIuvJtKsBlCA,7844
76
+ stcrpy-1.0.6.dist-info/METADATA,sha256=jYS1OQgMW6ZtxxfsHlqbIuCcwIGfZ9ikRGg_9BN1TbI,10605
77
+ stcrpy-1.0.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
78
+ stcrpy-1.0.6.dist-info/top_level.txt,sha256=kAkgyHyGW-_YswJpcuA3pSqzuQVbUggFUmZg2OTx_B8,16
79
+ stcrpy-1.0.6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5