pyjess 0.4.1__cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl → 0.5.0__cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.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 pyjess might be problematic. Click here for more details.

pyjess/_jess.pyi CHANGED
@@ -39,7 +39,7 @@ class Molecule(Sequence[Atom]):
39
39
 
40
40
  class Atom:
41
41
  @classmethod
42
- def load(cls, file: Union[str, bytes, os.PathLike[Any], TextIO]) -> Atom: ...
42
+ def load(cls, file: Union[TextIO, str, os.PathLike[str]]) -> Atom: ...
43
43
  @classmethod
44
44
  def loads(cls, text: str) -> Atom: ...
45
45
  def __init__(
@@ -100,7 +100,7 @@ class Atom:
100
100
 
101
101
  class TemplateAtom:
102
102
  @classmethod
103
- def load(cls, file: Union[str, bytes, os.PathLike[Any], TextIO]) -> Atom: ...
103
+ def load(cls, file: Union[TextIO, str, os.PathLike[str]]) -> Atom: ...
104
104
  @classmethod
105
105
  def loads(cls, text: str) -> TemplateAtom: ...
106
106
  def __init__(
@@ -188,14 +188,13 @@ class Hit(Generic[_T]):
188
188
  @property
189
189
  def template(self) -> _T: ...
190
190
  @property
191
- def molecule(self) -> Molecule: ...
192
- @property
193
191
  def determinant(self) -> float: ...
194
192
  @property
195
193
  def log_evalue(self) -> float: ...
196
194
  @property
197
195
  def evalue(self) -> float: ...
198
196
  def atoms(self, transform: bool = True) -> List[Atom]: ...
197
+ def molecule(self, transform: bool = False) -> Molecule: ...
199
198
 
200
199
  class Jess(Generic[_T], Sequence[_T]):
201
200
  def __init__(self, templates: Iterable[_T] = ()): ...
pyjess/_jess.pyx CHANGED
@@ -461,7 +461,7 @@ cdef class Atom:
461
461
  return NotImplemented
462
462
  other_ = other
463
463
  # FIXME: it should be possible to do a memcmp here.
464
- return self._state() == other_._state()
464
+ return self._state() == other_._state()
465
465
 
466
466
  def __hash__(self):
467
467
  return hash(tuple(self._state().values()))
@@ -598,11 +598,16 @@ cdef class TemplateAtom:
598
598
  """Load a template atom from the given file.
599
599
 
600
600
  Arguments:
601
- file (file-like object): A file-like object opened in
602
- text mode to read the template atom from.
601
+ file (str, os.PathLike or file-like object): A file-like object
602
+ opened in text or binary mode to read the template atom from.
603
603
 
604
604
  """
605
- return cls.loads(file.read())
605
+ try:
606
+ handle = open(file)
607
+ except TypeError:
608
+ handle = nullcontext(file)
609
+ with handle as f:
610
+ return cls.loads(f.read())
606
611
 
607
612
  @classmethod
608
613
  def loads(cls, text):
@@ -849,7 +854,7 @@ cdef class TemplateAtom:
849
854
 
850
855
  .. versionchanged:: 0.4.1
851
856
  Property now returns a `tuple` rather than a `list`.
852
-
857
+
853
858
  """
854
859
  assert self._atom is not NULL
855
860
 
@@ -871,11 +876,11 @@ cdef class TemplateAtom:
871
876
  """Create a copy of this template atom.
872
877
 
873
878
  Returns:
874
- `~pyjess.TemplateAtom`: A new template atom object with
879
+ `~pyjess.TemplateAtom`: A new template atom object with
875
880
  identical attributes.
876
-
881
+
877
882
  .. versionadded:: 0.4.0
878
-
883
+
879
884
  """
880
885
  return type(self)(**self._state())
881
886
 
@@ -894,10 +899,42 @@ cdef class Template:
894
899
 
895
900
  @classmethod
896
901
  def loads(cls, text, str id = None):
902
+ """Load a template from a string.
903
+
904
+ Arguments:
905
+ file (`str`, `os.PathLike`, or file-like object): Either the path
906
+ to a file, or a file-like object opened in **text mode**
907
+ containing the template.
908
+ id (`str`, optional): The identifier of the template. By default,
909
+ the parser will take the one from the ``PDB_ID`` remark if
910
+ found in the header.
911
+
912
+ Returns:
913
+ `~pyjess.Template`: The template parsed from the given string.
914
+
915
+ See Also:
916
+ `Template.load` to load a template from a file-like object or
917
+ from a path.
918
+
919
+ """
897
920
  return cls.load(io.StringIO(text), id=id)
898
921
 
899
922
  @classmethod
900
923
  def load(cls, file, str id = None):
924
+ """Load a template from the given file.
925
+
926
+ Arguments:
927
+ file (`str`, `os.PathLike` or file-like object): Either the
928
+ path to a file, or a file-like object opened in **text mode**
929
+ to read the template from.
930
+ id (`str`, optional): The identifier of the template. By default,
931
+ the parser will take the one from the ``PDB_ID`` remark if
932
+ found in the header.
933
+
934
+ Returns:
935
+ `~pyjess.Template`: The template parsed from the given file.
936
+
937
+ """
901
938
  try:
902
939
  handle = open(file)
903
940
  except TypeError:
@@ -1181,7 +1218,7 @@ cdef class Query:
1181
1218
  hit._sup = NULL
1182
1219
  hit._atoms = NULL
1183
1220
  hit.rmsd = INFINITY
1184
- hit.molecule = self.molecule
1221
+ hit._molecule = self.molecule
1185
1222
  hit_tpl = NULL
1186
1223
 
1187
1224
  # search the next hit without the GIL to allow parallel queries.
@@ -1261,7 +1298,7 @@ cdef class Hit:
1261
1298
 
1262
1299
  cdef readonly double rmsd
1263
1300
  cdef readonly Template template
1264
- cdef readonly Molecule molecule
1301
+ cdef Molecule _molecule
1265
1302
 
1266
1303
  def __dealloc__(self):
1267
1304
  jess.super.Superposition_free(self._sup)
@@ -1292,7 +1329,7 @@ cdef class Hit:
1292
1329
  cdef double e
1293
1330
 
1294
1331
  with nogil:
1295
- n = jess.molecule.Molecule_count(self.molecule._mol)
1332
+ n = jess.molecule.Molecule_count(self._molecule._mol)
1296
1333
  e = self.template._tpl.logE(self.template._tpl, self.rmsd, n)
1297
1334
  return e
1298
1335
 
@@ -1304,7 +1341,7 @@ cdef class Hit:
1304
1341
  cdef double e
1305
1342
 
1306
1343
  with nogil:
1307
- n = jess.molecule.Molecule_count(self.molecule._mol)
1344
+ n = jess.molecule.Molecule_count(self._molecule._mol)
1308
1345
  e = exp(self.template._tpl.logE(self.template._tpl, self.rmsd, n))
1309
1346
  return e
1310
1347
 
@@ -1349,6 +1386,45 @@ cdef class Hit:
1349
1386
 
1350
1387
  return atoms
1351
1388
 
1389
+ cpdef Molecule molecule(self, bint transform=False):
1390
+ """Get the molecule matching the template.
1391
+
1392
+ Arguments:
1393
+ transform (`bool`): Whether or not to transform coordinates
1394
+ of the molecule atoms into template frame.
1395
+
1396
+ Returns:
1397
+ `~pyjess.Molecule`: The matching molecule, optionally
1398
+ rotated to match the template coordinate.
1399
+
1400
+ .. versionadded:: 0.5.0
1401
+
1402
+ """
1403
+ assert self.template._tpl is not NULL
1404
+ assert self._sup is not NULL
1405
+
1406
+ cdef _Atom* atom
1407
+ cdef Molecule mol
1408
+ cdef size_t i
1409
+ cdef size_t j
1410
+ cdef size_t k
1411
+ cdef const double* M = jess.super.Superposition_rotation(self._sup)
1412
+ cdef const double* c = jess.super.Superposition_centroid(self._sup, 0)
1413
+ cdef const double* v = jess.super.Superposition_centroid(self._sup, 1)
1414
+
1415
+ if not transform:
1416
+ return self._molecule
1417
+
1418
+ mol = self._molecule.copy()
1419
+ for k in range(mol._mol.count):
1420
+ atom = mol._mol.atom[i]
1421
+ for i in range(3):
1422
+ atom.x[i] = v[i]
1423
+ for j in range(3):
1424
+ atom.x[i] += M[3*i + j] * (self._molecule._mol.atom[k].x[j] - c[j])
1425
+
1426
+ return mol
1427
+
1352
1428
 
1353
1429
  cdef class Jess:
1354
1430
  """A handle to run Jess over a list of templates.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyjess
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: Cython bindings and Python interface to JESS, a 3D template matching software.
5
5
  Keywords: bioinformatics,structure,template,matching
6
6
  Author-Email: Martin Larralde <martin.larralde@embl.de>
7
7
  License: MIT License
8
8
 
9
- Copyright (c) 2024 Martin Larralde <martin.larralde@embl.de>
9
+ Copyright (c) 2024-2025 Martin Larralde <martin.larralde@embl.de>
10
10
 
11
11
  Permission is hereby granted, free of charge, to any person obtaining a copy
12
12
  of this software and associated documentation files (the "Software"), to deal
@@ -51,6 +51,7 @@ Project-URL: Changelog, https://github.com/althonos/pyjess/blob/master/CHANGELOG
51
51
  Project-URL: Coverage, https://codecov.io/gh/althonos/pyjess/
52
52
  Project-URL: Builds, https://github.com/althonos/pyjess/actions
53
53
  Project-URL: Pypi, https://pypi.org/project/pyjess
54
+ Project-URL: Piwheels, https://piwheels.org/project/pyjess/
54
55
  Requires-Python: >=3.7
55
56
  Provides-Extra: test
56
57
  Requires-Dist: importlib-resources; python_version < "3.9" and extra == "test"
@@ -83,8 +84,8 @@ Jess is an algorithm for constraint-based structural template matching
83
84
  proposed by Jonathan Barker *et al.*[\[1\]](#ref1). It can be used to identify
84
85
  catalytic residues from a known template inside a protein structure. Jess
85
86
  is an evolution of TESS, a geometric hashing algorithm developed by
86
- Andrew Wallace *et al.*[\[2\]](#ref2), removing some pre-computation and
87
- structural requirements from the original algorithm. Jess was further
87
+ Andrew Wallace *et al.*[\[2\]](#ref2), removing some pre-computation and
88
+ structural requirements from the original algorithm. Jess was further
88
89
  updated and maintained by [Ioannis Riziotis](https://github.com/iriziotis)
89
90
  during his PhD in the [Thornton group](https://www.ebi.ac.uk/research/thornton/).
90
91
 
@@ -105,34 +106,44 @@ as well as the code required to compile from source with Cython:
105
106
  $ pip install pyjess
106
107
  ```
107
108
 
108
- <!-- Otherwise, PyJess is also available as a [Bioconda](https://bioconda.github.io/)
109
+ Otherwise, PyJess is also available as a [Bioconda](https://bioconda.github.io/)
109
110
  package:
110
111
  ```console
111
112
  $ conda install -c bioconda pyjess
112
- ``` -->
113
+ ```
113
114
 
114
115
  Check the [*install* page](https://pyjess.readthedocs.io/en/stable/install.html)
115
116
  of the documentation for other ways to install PyJess on your machine.
116
117
 
118
+
119
+ ## 🔖 Citation
120
+
121
+ PyJess is scientific software, and builds on top of Jess. Please cite
122
+ Jess if you are using it in an academic work, for instance as:
123
+
124
+ > PyJess, a Python library binding to Jess (Barker *et al.*, 2003).
125
+
126
+
117
127
  ## 💡 Example
118
128
 
119
129
  Load templates to be used as references from different template files:
120
130
 
121
131
  ```python
122
- import glob
132
+ import pathlib
123
133
  import pyjess
124
134
 
125
135
  templates = []
126
- for path in sorted(glob.iglob("vendor/jess/examples/template_*.qry")):
127
- templates.append(Template.load(path, id=os.path.basename(path)))
136
+ for path in sorted(pathlib.Path("vendor/jess/examples").glob("template_*.qry")):
137
+ with path.open() as file:
138
+ templates.append(pyjess.Template.load(file, id=path.stem))
128
139
  ```
129
140
 
130
141
  Create a `Jess` instance and use it to query a molecule (a PDB structure)
131
142
  against the stored templates:
132
143
 
133
144
  ```python
134
- jess = Jess(templates)
135
- mol = Molecule("vendor/jess/examples/test_pdbs/pdb1a0p.ent")
145
+ jess = pyjess.Jess(templates)
146
+ mol = pyjess.Molecule.load("vendor/jess/examples/test_pdbs/pdb1a0p.ent")
136
147
  query = jess.query(mol, rmsd_threshold=2.0, distance_cutoff=3.0, max_dynamic_distance=3.0)
137
148
  ```
138
149
 
@@ -162,7 +173,7 @@ with multiprocessing.ThreadPool() as pool:
162
173
  hits = pool.map(jess.query, molecules)
163
174
  ```
164
175
 
165
- *⚠️ Prior to PyJess `v0.2.1`, the Jess code was running some thread-unsafe operations which have now been patched.
176
+ *⚠️ Prior to PyJess `v0.2.1`, the Jess code was running some thread-unsafe operations which have now been patched.
166
177
  If running Jess in parallel, make sure to use `v0.2.1` or later to use the code patched with re-entrant functions*.
167
178
 
168
179
  <!-- ## ⏱️ Benchmarks -->
@@ -1,25 +1,25 @@
1
- pyjess/_jess.cpython-37m-aarch64-linux-gnu.so,sha256=Z7_H7UfMIJzic2nE8vFxJ6BPKj6zp9urygq0PN46Akg,415336
1
+ pyjess-0.5.0.dist-info/METADATA,sha256=qsP6LSYDn0V3i8bpx2KZw3w8pmH5zad6gIAnjfL053o,11121
2
+ pyjess-0.5.0.dist-info/WHEEL,sha256=3pwvh1oM8-y4943HioszAJjngUGY7ols47C1CujoGoM,156
3
+ pyjess-0.5.0.dist-info/RECORD,,
4
+ pyjess-0.5.0.dist-info/licenses/COPYING,sha256=gLCfHtBLTrghVX7GkpmZqoozWMNN46502m_OUiYy01Y,1103
2
5
  pyjess/.gitignore,sha256=uQBOufp4v50qn0aZKv6zbSo00cjfB-v9KySog7rlmIU,19
6
+ pyjess/_jess.cpython-37m-aarch64-linux-gnu.so,sha256=APodGqmToz5l8BJX1-8dZ9dlOIVm12dqJlmjydyuEuQ,416944
7
+ pyjess/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ pyjess/_jess.pyi,sha256=OjbEcgr16eFEnAFbT_zp-jqjd4XME2V_gxuKZJBXVoc,6896
3
9
  pyjess/__init__.py,sha256=h4XXLdS4FnyVa-MBs_k3eZMG1jWxeiOJnwfBaJA9gyQ,745
4
- pyjess/_jess.pyi,sha256=QIQSeQgNG-w0QZTuvacHjnv3IlEfV-3AOll9To3ZdM4,6899
5
10
  pyjess/CMakeLists.txt,sha256=Oa0pniEQx9jXyFCJGyrswn9ahWSSVuW1madyeP6StoI,35
6
- pyjess/_jess.pyx,sha256=E7D4tvgjnGo9q-YdWGdO-r472NdJanUEs8hYbB6rBaM,47303
7
- pyjess/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ pyjess/_jess.pyx,sha256=tRPxQyvCBxvVbIjAb8iuCLtIpPAP0w_P_42Uy1wv8oc,49965
8
12
  pyjess/tests/utils.py,sha256=dsaphex7qomJCvSHWnVy79iYDPGiL59xqGAtRoVAeWc,196
9
- pyjess/tests/test_atom.py,sha256=omNznNbRXMDt2j1plAUlfWPGCfmtkYpj2jysEX1zQuY,4631
10
- pyjess/tests/test_molecule.py,sha256=RHBE0yL_j71nQOwXJ6t_PzkZi4BaFPY5Q0VwKWM6elk,5311
13
+ pyjess/tests/test_template.py,sha256=XMLELYRB4j7xavziZ-ntq15PjhNHNfJJkctUq9BkvEI,4541
11
14
  pyjess/tests/__init__.py,sha256=MdHWtr6A8S4TBWlkoj4olFK2FXAGc5uJdbWtgFrDLpk,528
15
+ pyjess/tests/test_molecule.py,sha256=RHBE0yL_j71nQOwXJ6t_PzkZi4BaFPY5Q0VwKWM6elk,5311
12
16
  pyjess/tests/test_jess.py,sha256=mgHx6kDW5yzdvZiiybAVrd1J4k3Li3r-t4le6RFEE5o,9757
13
- pyjess/tests/test_template.py,sha256=XMLELYRB4j7xavziZ-ntq15PjhNHNfJJkctUq9BkvEI,4541
17
+ pyjess/tests/test_atom.py,sha256=omNznNbRXMDt2j1plAUlfWPGCfmtkYpj2jysEX1zQuY,4631
14
18
  pyjess/tests/test_template_atom.py,sha256=s9tJ_SAgvKeGwbVjaTWY-EtsUeQp3eu4NF5ja3oO_84,3405
15
- pyjess/tests/data/1.3.3.tpl,sha256=mg3STlRiNESM0chuOQ8CodW3Ohnxbt1_nx4PId63iOI,988
16
- pyjess/tests/data/template_02.qry,sha256=IAI6eiDA-Qji7cFYW9S8e0XYNTlHb8XtJibP3PVGuHw,607
19
+ pyjess/tests/data/template_01.qry,sha256=y3jTNf-WH2wL7OizKGJEPvLIlF3qHDAyR3LdKqWjy60,605
20
+ pyjess/tests/data/1AMY+1.3.3.txt,sha256=41R3aa6jozzSSfzboxhyK5xfX8e47aiq2U4W7aCzRm8,103584
17
21
  pyjess/tests/data/1AMY.pdb,sha256=t2CaGLdOyPrhyeMpe1TbwZ8u7QmfxCIG1Pit8-vzvgo,319221
22
+ pyjess/tests/data/template_02.qry,sha256=IAI6eiDA-Qji7cFYW9S8e0XYNTlHb8XtJibP3PVGuHw,607
23
+ pyjess/tests/data/1.3.3.tpl,sha256=mg3STlRiNESM0chuOQ8CodW3Ohnxbt1_nx4PId63iOI,988
18
24
  pyjess/tests/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- pyjess/tests/data/1AMY+1.3.3.txt,sha256=41R3aa6jozzSSfzboxhyK5xfX8e47aiq2U4W7aCzRm8,103584
20
- pyjess/tests/data/template_01.qry,sha256=y3jTNf-WH2wL7OizKGJEPvLIlF3qHDAyR3LdKqWjy60,605
21
25
  pyjess/tests/data/pdb1lnb.pdb,sha256=E9Jjy4qQ75O1UKIXcVyVJHE1XDNx1Rb7ENPVrehW6N8,270054
22
- pyjess-0.4.1.dist-info/RECORD,,
23
- pyjess-0.4.1.dist-info/METADATA,sha256=iHTTiJz29i7uRreAEeB_ow4-DArxSGb5Nz2Y9N4RblQ,10785
24
- pyjess-0.4.1.dist-info/WHEEL,sha256=3pwvh1oM8-y4943HioszAJjngUGY7ols47C1CujoGoM,156
25
- pyjess-0.4.1.dist-info/licenses/COPYING,sha256=W3hXwpT6UtiSFrO8yeDddZLU5tKIAX238e0N5slPQGA,1098
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Martin Larralde <martin.larralde@embl.de>
3
+ Copyright (c) 2024-2025 Martin Larralde <martin.larralde@embl.de>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
File without changes