SHEPHARD 0.2.3__tar.gz → 0.2.4__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 (123) hide show
  1. {shephard-0.2.3 → shephard-0.2.4}/CHANGELOG.md +26 -1
  2. {shephard-0.2.3 → shephard-0.2.4}/PKG-INFO +2 -2
  3. {shephard-0.2.3 → shephard-0.2.4}/README.md +1 -1
  4. {shephard-0.2.3 → shephard-0.2.4}/SHEPHARD.egg-info/PKG-INFO +2 -2
  5. {shephard-0.2.3 → shephard-0.2.4}/SHEPHARD.egg-info/SOURCES.txt +1 -0
  6. {shephard-0.2.3 → shephard-0.2.4}/pyproject.toml +26 -0
  7. shephard-0.2.4/shephard/_version.py +1 -0
  8. {shephard-0.2.3 → shephard-0.2.4}/shephard/apis/metapredict_api.py +26 -32
  9. {shephard-0.2.3 → shephard-0.2.4}/shephard/domain.py +4 -4
  10. {shephard-0.2.3 → shephard-0.2.4}/shephard/interfaces/si_domains.py +8 -5
  11. {shephard-0.2.3 → shephard-0.2.4}/shephard/interfaces/si_protein_attributes.py +27 -22
  12. {shephard-0.2.3 → shephard-0.2.4}/shephard/interfaces/si_sites.py +12 -1
  13. {shephard-0.2.3 → shephard-0.2.4}/shephard/protein.py +103 -46
  14. {shephard-0.2.3 → shephard-0.2.4}/shephard/proteome.py +42 -17
  15. {shephard-0.2.3 → shephard-0.2.4}/shephard/sequence_utilities.py +0 -1
  16. {shephard-0.2.3 → shephard-0.2.4}/shephard/site.py +25 -16
  17. shephard-0.2.4/shephard/tests/output_test/all_values_test.tsv +9 -0
  18. shephard-0.2.4/shephard/tests/output_test/test_domains.tsv +27 -0
  19. shephard-0.2.4/shephard/tests/output_test/test_domains_types.tsv +18 -0
  20. shephard-0.2.4/shephard/tests/output_test/track_random_vals.tsv +1 -0
  21. shephard-0.2.4/shephard/tests/test_bugfix_regressions_0_2_4.py +272 -0
  22. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_comprehensive_proteome.py +18 -2
  23. {shephard-0.2.3 → shephard-0.2.4}/shephard/tools/domain_tools.py +2 -3
  24. {shephard-0.2.3 → shephard-0.2.4}/shephard/track.py +16 -6
  25. shephard-0.2.3/shephard/_version.py +0 -1
  26. shephard-0.2.3/shephard/tests/output_test/all_values_test.tsv +0 -9
  27. shephard-0.2.3/shephard/tests/output_test/test_domains.tsv +0 -27
  28. shephard-0.2.3/shephard/tests/output_test/test_domains_types.tsv +0 -18
  29. shephard-0.2.3/shephard/tests/output_test/track_random_vals.tsv +0 -1
  30. {shephard-0.2.3 → shephard-0.2.4}/CITATION.cff +0 -0
  31. {shephard-0.2.3 → shephard-0.2.4}/LICENSE +0 -0
  32. {shephard-0.2.3 → shephard-0.2.4}/MANIFEST.in +0 -0
  33. {shephard-0.2.3 → shephard-0.2.4}/SHEPHARD.egg-info/dependency_links.txt +0 -0
  34. {shephard-0.2.3 → shephard-0.2.4}/SHEPHARD.egg-info/not-zip-safe +0 -0
  35. {shephard-0.2.3 → shephard-0.2.4}/SHEPHARD.egg-info/requires.txt +0 -0
  36. {shephard-0.2.3 → shephard-0.2.4}/SHEPHARD.egg-info/top_level.txt +0 -0
  37. {shephard-0.2.3 → shephard-0.2.4}/setup.cfg +0 -0
  38. {shephard-0.2.3 → shephard-0.2.4}/shephard/.DS_Store +0 -0
  39. {shephard-0.2.3 → shephard-0.2.4}/shephard/__init__.py +0 -0
  40. {shephard-0.2.3 → shephard-0.2.4}/shephard/apis/__init__.py +0 -0
  41. {shephard-0.2.3 → shephard-0.2.4}/shephard/apis/albatross_api.py +0 -0
  42. {shephard-0.2.3 → shephard-0.2.4}/shephard/apis/fasta.py +0 -0
  43. {shephard-0.2.3 → shephard-0.2.4}/shephard/apis/uniprot.py +0 -0
  44. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/README.md +0 -0
  45. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/look_and_say.dat +0 -0
  46. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/TS1_domains_idr.tsv +0 -0
  47. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/TS1_domains_idr_and_others.tsv +0 -0
  48. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/TS1_domains_pscore.tsv +0 -0
  49. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/TS1_protein_attributes.tsv +0 -0
  50. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/TS1_protein_attributes_several.tsv +0 -0
  51. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/TS1_sites.tsv +0 -0
  52. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/TS1_small_proteins.tsv +0 -0
  53. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/TS1_tracks_pscore.tsv +0 -0
  54. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/names.txt +0 -0
  55. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/seqs.fasta +0 -0
  56. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/testset_1.fasta +0 -0
  57. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/testset_1.fasta.fai +0 -0
  58. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/testset_1_ptms.tsv +0 -0
  59. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/ts1_bonus_sites.tsv +0 -0
  60. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/ts1_bonus_sites_bad.tsv +0 -0
  61. {shephard-0.2.3 → shephard-0.2.4}/shephard/data/test_data/ts1_bonus_sites_bad2.tsv +0 -0
  62. {shephard-0.2.3 → shephard-0.2.4}/shephard/exceptions.py +0 -0
  63. {shephard-0.2.3 → shephard-0.2.4}/shephard/general_utilities.py +0 -0
  64. {shephard-0.2.3 → shephard-0.2.4}/shephard/interfaces/__init__.py +0 -0
  65. {shephard-0.2.3 → shephard-0.2.4}/shephard/interfaces/interface_tools.py +0 -0
  66. {shephard-0.2.3 → shephard-0.2.4}/shephard/interfaces/si_proteins.py +0 -0
  67. {shephard-0.2.3 → shephard-0.2.4}/shephard/interfaces/si_tracks.py +0 -0
  68. {shephard-0.2.3 → shephard-0.2.4}/shephard/py.typed +0 -0
  69. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/.ipynb_checkpoints/test_scratchpad-checkpoint.ipynb +0 -0
  70. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/__init__.py +0 -0
  71. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/conftest.py +0 -0
  72. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/example_test_function.py +0 -0
  73. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/output_test/all_symbols_test.tsv +0 -0
  74. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/output_test/all_values_test_from_list.tsv +0 -0
  75. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/output_test/out_tracks.tsv +0 -0
  76. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/output_test/readme.md +0 -0
  77. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/output_test/shephard_track_phosres.tsv +0 -0
  78. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/output_test/shephard_track_pscore.tsv +0 -0
  79. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/output_test/test_sites.tsv +0 -0
  80. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/output_test/track_phospho_track.tsv +0 -0
  81. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_DomainInterface.py +0 -0
  82. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_ProteinAttributesInterface.py +0 -0
  83. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_ProteinInterface.py +0 -0
  84. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_SiteInterface.py +0 -0
  85. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_TrackInterface.py +0 -0
  86. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_add_remove_annotations.py +0 -0
  87. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_api_albatross.py +0 -0
  88. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_api_metapredict.py +0 -0
  89. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_api_uniprot_annotation.py +0 -0
  90. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_api_uniprot_live.py +0 -0
  91. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_apis_fasta.py +0 -0
  92. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_attribute_tools.py +0 -0
  93. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_bugfix_regressions.py +0 -0
  94. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_bugfix_regressions_0_2_3.py +0 -0
  95. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_comprehensive_apis.py +0 -0
  96. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_comprehensive_domain.py +0 -0
  97. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_comprehensive_interfaces.py +0 -0
  98. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_comprehensive_protein.py +0 -0
  99. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_comprehensive_site.py +0 -0
  100. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_comprehensive_tools.py +0 -0
  101. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_comprehensive_track.py +0 -0
  102. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_domain_tools.py +0 -0
  103. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_domains.py +0 -0
  104. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_interfaces.py +0 -0
  105. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_protein.py +0 -0
  106. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_protein_site_functions.py +0 -0
  107. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_proteome.py +0 -0
  108. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_scratchpad.ipynb +0 -0
  109. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_sequence_tools.py +0 -0
  110. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_shephard.py +0 -0
  111. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_si_domains.py +0 -0
  112. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_si_sites.py +0 -0
  113. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_si_tracks.py +0 -0
  114. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_sites.py +0 -0
  115. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_track_tools.py +0 -0
  116. {shephard-0.2.3 → shephard-0.2.4}/shephard/tests/test_tracks.py +0 -0
  117. {shephard-0.2.3 → shephard-0.2.4}/shephard/tools/__init__.py +0 -0
  118. {shephard-0.2.3 → shephard-0.2.4}/shephard/tools/attribute_tools.py +0 -0
  119. {shephard-0.2.3 → shephard-0.2.4}/shephard/tools/attribute_tools.py~ +0 -0
  120. {shephard-0.2.3 → shephard-0.2.4}/shephard/tools/experimental.py +0 -0
  121. {shephard-0.2.3 → shephard-0.2.4}/shephard/tools/sequence_tools.py +0 -0
  122. {shephard-0.2.3 → shephard-0.2.4}/shephard/tools/site_tools.py +0 -0
  123. {shephard-0.2.3 → shephard-0.2.4}/shephard/tools/track_tools.py +0 -0
@@ -9,7 +9,32 @@ SHEPHARD uses [semantic versioning](https://semver.org/) loosely: patch releases
9
9
  bug fixes, minor releases add functionality, and any change that breaks backwards
10
10
  compatibility is called out explicitly at the top of the relevant entry.
11
11
 
12
- #### Version 0.2.3 (May 2026)
12
+ #### Version 0.2.4 (July 2024)
13
+ * **BUG FIXES**:
14
+ * `Proteome[i]` could not be indexed from the end: a negative index raised a `KeyError` and a slice with any negative bound (e.g. `P[-2:]`) raised a `ValueError` from `islice`. Indexing now follows the standard Python conventions, so negative indices count back from the last protein, and an out-of-range integer index raises an `IndexError` rather than a `KeyError`.
15
+ * Over-writing an existing Track (`add_track(..., safe=False)`, `build_track_values_from_sequence()`, `build_track_symbols_from_sequence()`, `build_track()`) left the replaced Track counted in the Proteome's book-keeping, so a track name could linger in `Proteome.unique_track_names` (and `track_names_to_track_type`) after every Track with that name had been removed. The same was true of `Protein.add_domain()` and `Proteome.unique_domain_types`. Note that the replacement annotation is now built *before* the old one is discarded, so a failed overwrite leaves the pre-existing annotation intact.
16
+ * `Protein.build_domain()` accepted and documented `safe` and `autoname` but forwarded neither, so `autoname=True` still raised on a duplicate domain and `safe=False` could not be used to over-write one.
17
+ * Track attributes were silently dropped when Proteins were copied into a new Proteome (`Proteome(list_of_Protein_objects)` or `add_proteins()`), because `Protein.add_track()` had no way to set them. `add_track()` now takes an `attributes` dictionary (matching `add_domain()` and `add_site()`), and Track attributes are deep-copied alongside Domain and Site attributes.
18
+ * `Protein.sites` is documented as returning Sites sorted N- to C-terminal but returned them in the order they happened to be added, so `protein.sites` (and therefore `Proteome.sites`, and the order in which Sites were written to file) was unordered whenever Sites were added out of sequence.
19
+ * Three internal book-keeping exceptions in `proteome.py` were missing their `f` prefix, so a genuine book-keeping failure reported a literal `{track_name}`/`{domain_type}`/`{site_type}` placeholder rather than the offending name.
20
+ * `Site.get_track_values()` on a symbols track (and `Site.get_track_symbols()` on a values track) raised a raw `TypeError` (`None` is not subscriptable) rather than an informative `SiteException`. The same was true of `Track.values_region()` and `Track.symbols_region()`, which now raise a `TrackException`. The equivalent `Domain` functions already reported this properly and continue to raise a `DomainException`.
21
+ * A Site with no symbol was written out as the literal string `None` (as an unset value always has been) but read back in as the *string* `'None'` rather than `None`, so Sites did not round-trip cleanly through a Sites file. Symbols are now handled exactly as values are.
22
+ * **PERFORMANCE UPGRADES**:
23
+ * `si_protein_attributes.add_protein_attributes_from_dictionary()` now iterates the (typically small) attributes dictionary and uses O(1) protein look-ups rather than scanning every protein in the Proteome, matching the equivalent change made to the domains, sites and tracks interfaces in 0.2.3.
24
+ * **PACKAGING / INSTALL & CI**:
25
+ * Added a [tox](https://tox.wiki/) configuration so the full test suite can be run against every supported Python (3.10 - 3.14) with a single `tox` command, mirroring the CI matrix. Individual versions can be run with `tox -e py312`, pytest arguments can be passed through after a `--`, and `tox -e coverage` reproduces the coverage run CI does. The configuration lives in `pyproject.toml` (tox's native TOML format, so it requires tox 4.21 or later) rather than in a separate `tox.ini`, keeping project configuration in one place.
26
+ * **DOCUMENTATION**:
27
+ * Corrected the stated Python requirement in the installation docs (3.8 -> 3.10, matching `pyproject.toml`), the release date in the README (May -> July 2026), and the copyright range in the Sphinx config.
28
+ * Documented Proteome indexing/slicing semantics, Track attributes (including the fact that they are in-memory only and are not written to Tracks files), and the `None` symbol/value round-trip convention in Sites files.
29
+ * `si_protein_attributes.write_protein_attributes_from_dictionary()` is a public function but was missing from the interfaces documentation; also fixed the `si_proteins` section, which named the wrong module.
30
+ * Fixed the parameter name in the `metapredict_api.annotate_proteome_with_disorder_track()` docstring (`track_name` -> `name`) and removed a stale claim from `Site.update_site_symbol()` that it updated the Proteome's site book-keeping.
31
+ * **TESTS**:
32
+ * Added `test_bugfix_regressions_0_2_4.py`, an explicit regression test for each of the bugs listed above.
33
+ * Documented how to run the suite across Python versions with tox in the code convention documentation.
34
+ * **REFACTOR**:
35
+ * Removed unused imports (`numpy` in `protein.py`, `re` in `sequence_utilities.py`, `ProteinException` in `site.py`, and `random`/`site_tools` in `domain_tools.py`).
36
+
37
+ #### Version 0.2.3 (July 2026)
13
38
  * **BUG FIXES**:
14
39
  * Fixed a typo in `proteome.py` (`s.position. s.site_type`) that raised an `AttributeError` when copying any `Protein` containing sites into a new `Proteome` (e.g. `Proteome(list_of_Protein_objects)` or `add_proteins()` with `Protein` objects).
15
40
  * Fixed a broken type check in `track.py` (`elif(symbols, str):`, an always-true tuple) so symbols tracks are validated correctly and the invalid-input error path is reachable.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SHEPHARD
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Python package for organizing large sets of protein data
5
5
  Author: Garrett M. Ginell
6
6
  Author-email: Alex Holehouse <alex.holehouse@wustl.edu>
@@ -39,7 +39,7 @@ SHEPHARD
39
39
  ==============================
40
40
  #### Sequence-based Hierarchical and Extendable Platform for High-throughput Analysis of Region of Disorder
41
41
 
42
- ### Current major version: 0.2.3 (May 2026)
42
+ ### Current major version: 0.2.3 (July 2026)
43
43
 
44
44
  [//]: # (Badges)
45
45
  [![CI](https://github.com/holehouse-lab/shephard/actions/workflows/ci.yml/badge.svg)](https://github.com/holehouse-lab/shephard/actions/workflows/ci.yml)
@@ -2,7 +2,7 @@ SHEPHARD
2
2
  ==============================
3
3
  #### Sequence-based Hierarchical and Extendable Platform for High-throughput Analysis of Region of Disorder
4
4
 
5
- ### Current major version: 0.2.3 (May 2026)
5
+ ### Current major version: 0.2.3 (July 2026)
6
6
 
7
7
  [//]: # (Badges)
8
8
  [![CI](https://github.com/holehouse-lab/shephard/actions/workflows/ci.yml/badge.svg)](https://github.com/holehouse-lab/shephard/actions/workflows/ci.yml)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SHEPHARD
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Python package for organizing large sets of protein data
5
5
  Author: Garrett M. Ginell
6
6
  Author-email: Alex Holehouse <alex.holehouse@wustl.edu>
@@ -39,7 +39,7 @@ SHEPHARD
39
39
  ==============================
40
40
  #### Sequence-based Hierarchical and Extendable Platform for High-throughput Analysis of Region of Disorder
41
41
 
42
- ### Current major version: 0.2.3 (May 2026)
42
+ ### Current major version: 0.2.3 (July 2026)
43
43
 
44
44
  [//]: # (Badges)
45
45
  [![CI](https://github.com/holehouse-lab/shephard/actions/workflows/ci.yml/badge.svg)](https://github.com/holehouse-lab/shephard/actions/workflows/ci.yml)
@@ -70,6 +70,7 @@ shephard/tests/test_apis_fasta.py
70
70
  shephard/tests/test_attribute_tools.py
71
71
  shephard/tests/test_bugfix_regressions.py
72
72
  shephard/tests/test_bugfix_regressions_0_2_3.py
73
+ shephard/tests/test_bugfix_regressions_0_2_4.py
73
74
  shephard/tests/test_comprehensive_apis.py
74
75
  shephard/tests/test_comprehensive_domain.py
75
76
  shephard/tests/test_comprehensive_interfaces.py
@@ -87,6 +87,32 @@ omit = [
87
87
  "shephard/_version.py",
88
88
  ]
89
89
 
90
+ # tox configuration - lets the full test suite be run against every supported
91
+ # Python with a single command, mirroring what CI does. This uses tox's native
92
+ # TOML configuration so all project config stays in pyproject.toml, which
93
+ # requires tox 4.21 or later.
94
+ #
95
+ # tox # test against every supported Python
96
+ # tox -e py312 # test against a single Python
97
+ # tox -e py312 -- -k uniprot # anything after -- goes to pytest
98
+ # tox -e coverage # run with coverage, as CI does
99
+ #
100
+ # Note that tox skips (and reports) any interpreter that is not installed
101
+ # locally rather than failing the run, so a missing 3.14 is not an error.
102
+ [tool.tox]
103
+ requires = ["tox>=4.21"]
104
+ env_list = ["py310", "py311", "py312", "py313", "py314"]
105
+
106
+ [tool.tox.env_run_base]
107
+ description = "run the test suite under {base_python}"
108
+ extras = ["test"]
109
+ commands = [["pytest", {replace = "posargs", extend = true, default = []}]]
110
+
111
+ [tool.tox.env.coverage]
112
+ description = "run the test suite with coverage, as CI does"
113
+ extras = ["test"]
114
+ commands = [["pytest", "--cov=shephard", "--cov-report=term-missing", "--cov-report=xml", {replace = "posargs", extend = true, default = []}]]
115
+
90
116
  [tool.versioningit]
91
117
  default-version = "1+unknown"
92
118
 
@@ -0,0 +1 @@
1
+ __version__ = "0.2.4"
@@ -59,19 +59,19 @@ def annotate_proteome_with_disorder_track(proteome,
59
59
  for every protein.
60
60
 
61
61
  By default, disorder Tracks are named 'disorder', although
62
- this can be changed by setting the `track_name` parameter.
62
+ this can be changed by setting the `name` parameter.
63
63
 
64
- Disorder prediction uses the batch mode in metapredict, which
64
+ Disorder prediction uses the batch mode in metapredict, which
65
65
  leverages parallel predictions automatically on GPUs or CPUs.
66
66
  However, if a specific device is requested, this can be passed
67
67
 
68
68
  Parameters
69
69
  -----------------
70
- proteome : shephard.proteome.Proteome
70
+ proteome : shephard.proteome.Proteome
71
71
  Proteome object to be annotated.
72
72
 
73
- track_name : str
74
- Name of the Track added to each Protein.
73
+ name : str
74
+ Name of the Track added to each Protein.
75
75
  Default = 'disorder'
76
76
 
77
77
  device : int or str
@@ -81,15 +81,13 @@ def annotate_proteome_with_disorder_track(proteome,
81
81
  cuda.is_available() returns False, instead of falling back to CPU,
82
82
  metapredict will raise an Exception so you know that you are not
83
83
  using CUDA as you were expecting.
84
- Default: None
85
- When set to None, we will check if there is a cuda-enabled
86
- GPU. If there is, we will try to use that GPU.
87
- If you set the value to be an int, we will use cuda:int as the device
88
- where int is the int you specify. The GPU numbering is 0 indexed, so 0
89
- corresponds to the first GPU, and so on. Only specify this if you
90
- know which GPU you want to use.
91
- * Note: MPS is only supported in Pytorch 2.1 or later.
92
- MPS is still fairly new, so use it at your own risk.
84
+ The default is None, which means we check if there is a
85
+ cuda-enabled GPU and, if there is, try to use it. If an int is
86
+ passed we use cuda:<int> as the device, where the GPU numbering is
87
+ 0-indexed (so 0 corresponds to the first GPU). Only set this if you
88
+ know which GPU you want to use. Note that MPS is only supported in
89
+ PyTorch 2.1 or later, and is still fairly new, so use it at your own
90
+ risk.
93
91
 
94
92
  version : int
95
93
  Defines the metapredict version to use (must be one of 1, 2
@@ -187,15 +185,13 @@ def annotate_proteome_with_disordered_domains(proteome,
187
185
  cuda.is_available() returns False, instead of falling back to CPU,
188
186
  metapredict will raise an Exception so you know that you are not
189
187
  using CUDA as you were expecting.
190
- Default: None
191
- When set to None, we will check if there is a cuda-enabled
192
- GPU. If there is, we will try to use that GPU.
193
- If you set the value to be an int, we will use cuda:int as the device
194
- where int is the int you specify. The GPU numbering is 0 indexed, so 0
195
- corresponds to the first GPU and so on. Only specify this if you
196
- know which GPU you want to use.
197
- * Note: MPS is only supported in Pytorch 2.1 or later.
198
- MPS is still fairly new, so use it at your own risk.
188
+ The default is None, which means we check if there is a
189
+ cuda-enabled GPU and, if there is, try to use it. If an int is
190
+ passed we use cuda:<int> as the device, where the GPU numbering is
191
+ 0-indexed (so 0 corresponds to the first GPU). Only set this if you
192
+ know which GPU you want to use. Note that MPS is only supported in
193
+ PyTorch 2.1 or later, and is still fairly new, so use it at your own
194
+ risk.
199
195
 
200
196
  version : int
201
197
  Defines the metapredict version to use (must be one of 1, 2
@@ -311,15 +307,13 @@ def annotate_proteome_with_disorder_tracks_and_disordered_domains(proteome,
311
307
  cuda.is_available() returns False, instead of falling back to CPU,
312
308
  metapredict will raise an Exception so you know that you are not
313
309
  using CUDA as you were expecting.
314
- Default: None
315
- When set to None, we will check if there is a cuda-enabled
316
- GPU. If there is, we will try to use that GPU.
317
- If you set the value to be an int, we will use cuda:int as the device
318
- where int is the int you specify. The GPU numbering is 0 indexed, so 0
319
- corresponds to the first GPU and so on. Only specify this if you
320
- know which GPU you want to use.
321
- * Note: MPS is only supported in Pytorch 2.1 or later.
322
- MPS is still fairly new, so use it at your own risk.
310
+ The default is None, which means we check if there is a
311
+ cuda-enabled GPU and, if there is, try to use it. If an int is
312
+ passed we use cuda:<int> as the device, where the GPU numbering is
313
+ 0-indexed (so 0 corresponds to the first GPU). Only set this if you
314
+ know which GPU you want to use. Note that MPS is only supported in
315
+ PyTorch 2.1 or later, and is still fairly new, so use it at your own
316
+ risk.
323
317
 
324
318
  version : int
325
319
  Defines the metapredict version to use (must be one of 1, 2
@@ -11,7 +11,7 @@ Holehouse Lab - Washington University in St. Louis
11
11
  """
12
12
 
13
13
  from . import sequence_utilities
14
- from .exceptions import DomainException
14
+ from .exceptions import DomainException, TrackException
15
15
  from . import general_utilities
16
16
  from .tools import domain_tools
17
17
 
@@ -123,7 +123,7 @@ class Domain:
123
123
  ----------------
124
124
  name : str
125
125
  The attribute name. A list of valid names can be found by
126
- calling the ``<domain>.attributes()`` (which returns a list
126
+ calling the ``<Domain>.attributes`` (which returns a list
127
127
  of the valid names)
128
128
 
129
129
  safe : bool (default = True)
@@ -531,7 +531,7 @@ class Domain:
531
531
  if t is not None:
532
532
  try:
533
533
  return t.values_region(self._start, self._end)
534
- except TypeError:
534
+ except (TypeError, TrackException):
535
535
  if t.values is None:
536
536
  raise DomainException('Passed associated track has no values - try get_track_symbols')
537
537
  else:
@@ -574,7 +574,7 @@ class Domain:
574
574
  if t is not None:
575
575
  try:
576
576
  return t.symbols_region(self._start, self._end)
577
- except TypeError:
577
+ except (TypeError, TrackException):
578
578
  if t.symbols is None:
579
579
  raise DomainException('Passed associated track has no symbols - try get_track_values')
580
580
  else:
@@ -217,11 +217,14 @@ def add_domains_from_file(proteome, filename, delimiter='\t', autoname=False, re
217
217
  verbose=True.
218
218
 
219
219
  skip_bad : bool (default = True)
220
- Flag that means if bad lines (lines that trigger an exception) are
221
- encountered the code will just skip them. By default this is true,
222
- which adds a certain robustness to file parsing, but could also
223
- hide errors. Note that if lines are skipped a warning will be
224
- printed (regardless of verbose flag).
220
+ Flag that means if bad lines (lines that trigger an exception) are
221
+ encountered the code will just skip them. By default this is true,
222
+ which adds a certain robustness to file parsing, but could also
223
+ hide errors. Note that if lines are skipped a warning will be
224
+ printed (regardless of verbose flag). Note also that no more than
225
+ MAX_BAD_COUNT (10) bad lines will be skipped - if more than this
226
+ many bad lines are found an InterfaceException is raised even
227
+ when skip_bad is True.
225
228
 
226
229
  verbose : bool (default = True)
227
230
  Flag that defines how 'loud' output is. Will warn about errors on
@@ -292,28 +292,33 @@ def add_protein_attributes_from_dictionary(proteome, protein_attribute_dictionar
292
292
  # check first argument is a Proteome
293
293
  interface_tools.check_proteome(proteome, 'add_protein_attributes (si_protein_attributes)')
294
294
 
295
- for protein in proteome:
296
- if protein.unique_ID in protein_attribute_dictionary:
297
-
298
- # note here each AD is its own dictionary
299
- for AD in protein_attribute_dictionary[protein.unique_ID]:
300
-
301
- # for each attribute-key
302
- for k in AD:
303
-
304
- # get the value
305
- v = AD[k]
306
-
307
- try:
308
- protein.add_attribute(k, v, safe=safe)
309
- except ProteinException as e:
310
- msg=f'- skipping attribute entry on protein {protein.unique_ID} (key: {k}) '
311
- if safe:
312
- shephard_exceptions.print_and_raise_error(msg, e)
313
- else:
314
- if verbose:
315
- shephard_exceptions.print_warning(msg)
316
- continue
295
+ # iterate the (typically smaller) dictionary rather than every protein
296
+ # in the proteome; protein() is an O(1) dict lookup
297
+ for unique_ID in protein_attribute_dictionary:
298
+
299
+ protein = proteome.protein(unique_ID, safe=False)
300
+ if protein is None:
301
+ continue
302
+
303
+ # note here each AD is its own dictionary
304
+ for AD in protein_attribute_dictionary[unique_ID]:
305
+
306
+ # for each attribute-key
307
+ for k in AD:
308
+
309
+ # get the value
310
+ v = AD[k]
311
+
312
+ try:
313
+ protein.add_attribute(k, v, safe=safe)
314
+ except ProteinException as e:
315
+ msg=f'- skipping attribute entry on protein {protein.unique_ID} (key: {k}) '
316
+ if safe:
317
+ shephard_exceptions.print_and_raise_error(msg, e)
318
+ else:
319
+ if verbose:
320
+ shephard_exceptions.print_warning(msg)
321
+ continue
317
322
 
318
323
 
319
324
 
@@ -95,7 +95,18 @@ class _SitesInterface:
95
95
 
96
96
  position = int(sline[1].strip())
97
97
  site_type = sline[2].strip()
98
- symbol = sline[3].strip()
98
+
99
+ # this enables the symbol to be None if there is no symbolic
100
+ # information associated with a site. Note the writer emits
101
+ # 'None' for an unset symbol, so without this a Site written
102
+ # out and read back in gained the literal string 'None' as its
103
+ # symbol (the value field, below, has always been handled this
104
+ # way - the two are now consistent)
105
+ tmp = sline[3].strip()
106
+ if tmp == 'None':
107
+ symbol = None
108
+ else:
109
+ symbol = tmp
99
110
 
100
111
  # this enables the value to be None if you
101
112
  # write a symbol where there's no value associated
@@ -8,7 +8,6 @@ Contact: (alex.holehouse@wustl.edu, g.ginell@wustl.edu)
8
8
  Holehouse Lab - Washington University in St. Louis
9
9
  """
10
10
 
11
- import numpy as np
12
11
  from . import exceptions
13
12
  from . import sequence_utilities
14
13
  from .domain import Domain
@@ -491,7 +490,7 @@ class Protein:
491
490
  ----------------
492
491
  name : str
493
492
  The attribute name. A list of valid names can be found by
494
- calling the ``<Protein>.attributes()`` (which returns a
493
+ calling the ``<Protein>.attributes`` (which returns a
495
494
  list of the valid names).
496
495
 
497
496
 
@@ -663,8 +662,8 @@ class Protein:
663
662
  Parameters
664
663
  ----------------
665
664
  name : str
666
- The track name. A list of valid names can be found by calling
667
- the ``<Protein>.tracks()`` (which returns a list of the valid
665
+ The track name. A list of valid names can be found using
666
+ ``<Protein>.track_names`` (which returns a list of the valid
668
667
  track names).
669
668
 
670
669
  Returns
@@ -700,9 +699,9 @@ class Protein:
700
699
  Parameters
701
700
  ----------------
702
701
  name : string
703
- The track name. A list of valid names can be found by calling
704
- the <Protein>.tracks (which returns a list of the valid track
705
- names).
702
+ The track name. A list of valid names can be found using
703
+ ``<Protein>.track_names`` (which returns a list of the valid
704
+ track names).
706
705
 
707
706
  start : int (default None)
708
707
  If provided defines the start position along the track. If not
@@ -748,9 +747,9 @@ class Protein:
748
747
  Parameters
749
748
  ----------------
750
749
  name : string
751
- The track name. A list of valid names can be found by calling
752
- the <Protein>.tracks (which returns a list of the valid track
753
- names).
750
+ The track name. A list of valid names can be found using
751
+ ``<Protein>.track_names`` (which returns a list of the valid
752
+ track names).
754
753
 
755
754
  start : int (default = None)
756
755
  If provided defines the start position along the track. If not
@@ -887,7 +886,7 @@ class Protein:
887
886
 
888
887
  ## ------------------------------------------------------------------------
889
888
  ##
890
- def add_track(self, name, values=None, symbols=None, safe=True):
889
+ def add_track(self, name, values=None, symbols=None, safe=True, attributes=None):
891
890
  """
892
891
  Function that adds a track to this protein. For more information
893
892
  on Tracks see the relevant documentation. However, some general
@@ -917,9 +916,14 @@ class Protein:
917
916
  to a specific residue in the sequence.
918
917
 
919
918
  safe : bool (default = True)
920
- If set to True over-writing tracks will raise an exception,
919
+ If set to True over-writing tracks will raise an exception,
921
920
  otherwise overwriting a track will simply over-write it.
922
-
921
+
922
+ attributes : dict (default = None)
923
+ Optional dictionary which allows an arbitrary set of attributes to
924
+ be associated with the Track, in much the same way that they can be
925
+ associated with a Protein. Note that Track attributes cannot
926
+ currently be written to (or read from) SHEPHARD Tracks files.
923
927
 
924
928
  Returns
925
929
  ----------
@@ -931,8 +935,8 @@ class Protein:
931
935
  if name in self.track_names:
932
936
  if safe is True:
933
937
  raise exceptions.ProteinException(f'Trying to add Track [{name}] in protein [{self.name}] but Track already exists')
934
-
935
- self._tracks[name] = Track(name, self, values, symbols)
938
+
939
+ self.__assign_track(name, Track(name, self, values, symbols, attributes))
936
940
 
937
941
 
938
942
  ## ------------------------------------------------------------------------
@@ -1079,7 +1083,7 @@ class Protein:
1079
1083
  built_track = trackfunction(self.sequence, input_dictionary)
1080
1084
 
1081
1085
  # finally add the track
1082
- self._tracks[name] = Track(name, self, values=built_track, symbols=None)
1086
+ self.__assign_track(name, Track(name, self, values=built_track, symbols=None))
1083
1087
 
1084
1088
 
1085
1089
 
@@ -1222,7 +1226,7 @@ class Protein:
1222
1226
  built_track = trackfunction(self.sequence, input_dictionary)
1223
1227
 
1224
1228
  # finally add the track
1225
- self._tracks[name] = Track(name, self, values=None, symbols=built_track)
1229
+ self.__assign_track(name, Track(name, self, values=None, symbols=built_track))
1226
1230
 
1227
1231
 
1228
1232
 
@@ -1274,7 +1278,48 @@ class Protein:
1274
1278
  values = track_out['values']
1275
1279
  symbols = track_out['symbols']
1276
1280
 
1277
- self._tracks[name] = Track(name, self, values=values, symbols=symbols)
1281
+ self.__assign_track(name, Track(name, self, values=values, symbols=symbols))
1282
+
1283
+
1284
+
1285
+ ## ------------------------------------------------------------------------
1286
+ ##
1287
+ def __assign_track(self, name, new_track):
1288
+ """
1289
+ INTERNAL FUNCTION (not for public API use)
1290
+
1291
+ Function that assigns an already-constructed Track to this Protein,
1292
+ taking care of the case where an existing Track of the same name is
1293
+ being over-written.
1294
+
1295
+ This matters because the Proteome keeps a count of how many Tracks
1296
+ carry each name (which is what unique_track_names reports). Simply
1297
+ writing over the entry in self._tracks leaves the replaced Track
1298
+ counted forever, so a Track name could linger in the Proteome after
1299
+ every Track with that name had been removed.
1300
+
1301
+ Note the new Track is built by the caller BEFORE we get here, so if
1302
+ construction fails the pre-existing Track is left untouched.
1303
+
1304
+ Parameters
1305
+ ---------------
1306
+ name : str
1307
+ Name the Track will be stored under.
1308
+
1309
+ new_track : shephard.track.Track
1310
+ The newly-constructed Track object.
1311
+
1312
+ Returns
1313
+ ---------------
1314
+ None
1315
+ No return type, but assigns the Track to the Protein.
1316
+
1317
+ """
1318
+
1319
+ if name in self._tracks:
1320
+ self.remove_track(self._tracks[name])
1321
+
1322
+ self._tracks[name] = new_track
1278
1323
 
1279
1324
 
1280
1325
 
@@ -1314,7 +1359,7 @@ class Protein:
1314
1359
  if safe is False:
1315
1360
  return
1316
1361
  else:
1317
- raise ProteinException(f'track_object was not a Track, but Safe=True')
1362
+ raise ProteinException('track_object was not a Track, but safe=True')
1318
1363
 
1319
1364
  # failsafe to ensure we can only delete tracks that truly come from the protein we're passing
1320
1365
  # into
@@ -1401,9 +1446,9 @@ class Protein:
1401
1446
  Parameters
1402
1447
  ----------------
1403
1448
  name : string
1404
- The Domain name. A list of valid names can be found by calling
1405
- the <Protein>.domains (which returns a list of the valid track
1406
- names).
1449
+ The Domain name. A list of valid names can be found using
1450
+ ``<Protein>.domain_names`` (which returns a list of the valid
1451
+ domain names).
1407
1452
 
1408
1453
  safe : bool (default = True)
1409
1454
  Flag which if true with throw an exception if no domain exists
@@ -1566,8 +1611,19 @@ class Protein:
1566
1611
  full_name = newname
1567
1612
  elif safe:
1568
1613
  raise exceptions.ProteinException(f'Domain [{full_name}] already found in proteins {self.name}')
1569
-
1570
- self._domains[full_name] = Domain(start, end, self, domain_type, full_name, attributes=attributes)
1614
+
1615
+ new_domain = Domain(start, end, self, domain_type, full_name, attributes=attributes)
1616
+
1617
+ # if we are over-writing an existing Domain, remove the old one properly
1618
+ # rather than just writing over it - remove_domain() also decrements the
1619
+ # Proteome's domain-type book-keeping, which would otherwise keep
1620
+ # counting the Domain we just discarded. Note we only do this once the
1621
+ # new Domain has been built, so a failed construction leaves the
1622
+ # pre-existing Domain untouched
1623
+ if full_name in self._domains:
1624
+ self.remove_domain(self._domains[full_name])
1625
+
1626
+ self._domains[full_name] = new_domain
1571
1627
 
1572
1628
 
1573
1629
 
@@ -1587,26 +1643,22 @@ class Protein:
1587
1643
  Any input that makes sense when passed to the
1588
1644
  domain_definition_function().
1589
1645
 
1590
- domain_definition_function : function that takes a single argument
1591
- (input_data) and returns a list of 0 or more dictionaries. Each
1592
- dictionary within the list has a key-value pair that
1593
-
1594
- defines the following info:
1595
-
1596
- start : domain start position
1597
- end : domain end position
1646
+ domain_definition_function : function
1647
+ A function that takes a single argument (input_data) and returns
1648
+ a list of zero or more domain dictionaries. Each dictionary within
1649
+ the list defines the following info ::
1650
+
1651
+ start : domain start position
1652
+ end : domain end position
1598
1653
  domain_type : type of the domain
1599
- attributes : a dictionary of attributes to associated with
1600
- the domain (optional)
1601
-
1654
+ attributes : a dictionary of attributes to associate with
1655
+ the domain (optional)
1656
+
1602
1657
  Note that in principle only start and end are required, although
1603
- we highly recommend one/both of domain name and domain type.
1604
-
1605
- Some important requirements to consider:
1658
+ we highly recommend one/both of domain name and domain type. Note
1659
+ also that the domain_definition_function MUST return a list of
1660
+ zero or more dictionaries.
1606
1661
 
1607
- (1) domain_definition_function must return a list of zero or more
1608
- dictionaries.
1609
-
1610
1662
  safe : bool (default = True)
1611
1663
  Flag which if true with throw an exception of a domain with the
1612
1664
  same name already exists.
@@ -1625,7 +1677,9 @@ class Protein:
1625
1677
  # domain_definitions is a list
1626
1678
  domain_definitions = domain_definition_function(input_data)
1627
1679
 
1628
- self.add_domains(domain_definitions)
1680
+ # note we pass safe and autoname through - previously these were
1681
+ # accepted, documented, and then silently dropped
1682
+ self.add_domains(domain_definitions, safe=safe, autoname=autoname)
1629
1683
 
1630
1684
  ## ------------------------------------------------------------------------
1631
1685
  ##
@@ -1914,13 +1968,16 @@ class Protein:
1914
1968
  @property
1915
1969
  def sites(self):
1916
1970
  """
1917
- Provides a list of the sites associated with
1971
+ Provides a list of the sites associated with
1918
1972
  every site on the protein. Sorted N to C terminal.
1919
1973
  """
1920
1974
 
1921
- # this means we will always
1975
+ # note we walk the positions in sorted order rather than in the order
1976
+ # sites happened to be added, so the returned list really is sorted
1977
+ # N to C terminal, as documented. Sites that share a position are
1978
+ # returned in the order they were added
1922
1979
  all_sites = []
1923
- for k in self._sites:
1980
+ for k in self.site_positions:
1924
1981
  for s in self._sites[k]:
1925
1982
  all_sites.append(s)
1926
1983
 
@@ -2090,7 +2147,7 @@ class Protein:
2090
2147
  if safe is False:
2091
2148
  return
2092
2149
  else:
2093
- raise ProteinException(f'site_object was not a Site, but safe=True.')
2150
+ raise ProteinException('site_object was not a Site, but safe=True.')
2094
2151
 
2095
2152
 
2096
2153
  # excise the site positions