ssslm 0.0.1__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.
ssslm-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Charles Tapley Hoyt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ssslm-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,440 @@
1
+ Metadata-Version: 2.4
2
+ Name: ssslm
3
+ Version: 0.0.1
4
+ Summary: A simple standard for sharing literal mappings
5
+ Keywords: snekpack,cookiecutter
6
+ Author: Charles Tapley Hoyt
7
+ Author-email: Charles Tapley Hoyt <cthoyt@gmail.com>
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 1 - Planning
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Framework :: Pytest
15
+ Classifier: Framework :: tox
16
+ Classifier: Framework :: Sphinx
17
+ Classifier: Natural Language :: English
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3 :: Only
24
+ Classifier: Typing :: Typed
25
+ Requires-Dist: curies
26
+ Requires-Dist: pydantic
27
+ Requires-Dist: pydantic-extra-types[pycountry]
28
+ Requires-Dist: tqdm
29
+ Requires-Dist: click
30
+ Requires-Dist: sphinx>=8 ; extra == 'docs'
31
+ Requires-Dist: sphinx-rtd-theme>=3.0 ; extra == 'docs'
32
+ Requires-Dist: sphinx-click ; extra == 'docs'
33
+ Requires-Dist: sphinx-automodapi ; extra == 'docs'
34
+ Requires-Dist: gilda ; extra == 'gilda'
35
+ Requires-Dist: nltk ; extra == 'gilda'
36
+ Requires-Dist: pystow ; extra == 'gilda'
37
+ Requires-Dist: gilda-slim ; extra == 'gilda-slim'
38
+ Requires-Dist: nltk ; extra == 'gilda-slim'
39
+ Requires-Dist: pystow ; extra == 'gilda-slim'
40
+ Requires-Dist: pytest ; extra == 'tests'
41
+ Requires-Dist: coverage[toml] ; extra == 'tests'
42
+ Requires-Dist: responses ; extra == 'tests'
43
+ Requires-Dist: pandas ; extra == 'tests'
44
+ Maintainer: Charles Tapley Hoyt
45
+ Maintainer-email: Charles Tapley Hoyt <cthoyt@gmail.com>
46
+ Requires-Python: >=3.10
47
+ Project-URL: Bug Tracker, https://github.com/cthoyt/ssslm/issues
48
+ Project-URL: Documentation, https://ssslm.readthedocs.io
49
+ Project-URL: Funding, https://github.com/sponsors/cthoyt
50
+ Project-URL: Homepage, https://github.com/cthoyt/ssslm
51
+ Project-URL: Repository, https://github.com/cthoyt/ssslm.git
52
+ Provides-Extra: docs
53
+ Provides-Extra: gilda
54
+ Provides-Extra: gilda-slim
55
+ Provides-Extra: tests
56
+ Description-Content-Type: text/markdown
57
+
58
+ <!--
59
+ <p align="center">
60
+ <img src="https://github.com/cthoyt/ssslm/raw/main/docs/source/logo.png" height="150">
61
+ </p>
62
+ -->
63
+
64
+ <h1 align="center">
65
+ Simple Standard for Sharing Literal Mappings
66
+ </h1>
67
+
68
+ <p align="center">
69
+ <a href="https://github.com/cthoyt/ssslm/actions/workflows/tests.yml">
70
+ <img alt="Tests" src="https://github.com/cthoyt/ssslm/actions/workflows/tests.yml/badge.svg" /></a>
71
+ <a href="https://pypi.org/project/ssslm">
72
+ <img alt="PyPI" src="https://img.shields.io/pypi/v/ssslm" /></a>
73
+ <a href="https://pypi.org/project/ssslm">
74
+ <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/ssslm" /></a>
75
+ <a href="https://github.com/cthoyt/ssslm/blob/main/LICENSE">
76
+ <img alt="PyPI - License" src="https://img.shields.io/pypi/l/ssslm" /></a>
77
+ <a href='https://ssslm.readthedocs.io/en/latest/?badge=latest'>
78
+ <img src='https://readthedocs.org/projects/ssslm/badge/?version=latest' alt='Documentation Status' /></a>
79
+ <a href="https://codecov.io/gh/cthoyt/ssslm/branch/main">
80
+ <img src="https://codecov.io/gh/cthoyt/ssslm/branch/main/graph/badge.svg" alt="Codecov status" /></a>
81
+ <a href="https://github.com/cthoyt/cookiecutter-python-package">
82
+ <img alt="Cookiecutter template from @cthoyt" src="https://img.shields.io/badge/Cookiecutter-snekpack-blue" /></a>
83
+ <a href="https://github.com/astral-sh/ruff">
84
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff" style="max-width:100%;"></a>
85
+ <a href="https://github.com/cthoyt/ssslm/blob/main/.github/CODE_OF_CONDUCT.md">
86
+ <img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg" alt="Contributor Covenant"/></a>
87
+ <!-- uncomment if you archive on zenodo
88
+ <a href="https://zenodo.org/badge/latestdoi/XXXXXX">
89
+ <img src="https://zenodo.org/badge/XXXXXX.svg" alt="DOI"></a>
90
+ -->
91
+ </p>
92
+
93
+ A simple standard for sharing literal mappings (SSSLM).
94
+
95
+ This repository implements a data model for literal mappings that supports
96
+ encoding labels, synonyms, synonym types, internationalization, and other
97
+ important information for curation, construction of lexica, and population of
98
+ NER/NEN tools.
99
+
100
+ ## 💪 Getting Started
101
+
102
+ ```python
103
+ import ssslm
104
+ from ssslm import LiteralMapping
105
+ from curies import NamedReference
106
+
107
+ # Construct a mapping using Pydantic objects
108
+ m1 = LiteralMapping(
109
+ reference=NamedReference(prefix="NCBITaxon", identifier="9606", name="Homo sapiens"),
110
+ text="human",
111
+ )
112
+
113
+ # get a pandas dataframe
114
+ df = ssslm.literal_mappings_to_df([m1])
115
+
116
+ # Write mappings to TSV
117
+ ssslm.write_literal_mappings([m1], "literal_mappings.tsv")
118
+
119
+ # Read mappings from TSV
120
+ mappings = ssslm.read_literal_mappings("literal_mappings.tsv")
121
+ ```
122
+
123
+ Note that references are standardized using the
124
+ [`curies`](https://github.com/biopragmatics/curies) package. It's up to you to
125
+ use a meaningful set of prefixes, so consider adopting
126
+ [the Bioregistry](https://github.com/biopragmatics/bioregistry) as a standard.
127
+
128
+ ## Data Model
129
+
130
+ The SSSLM data model is defined using Pydantic, and corresponds to the following
131
+ columns in a TSV file:
132
+
133
+ 1. `text` the label/synonym text itself
134
+ 2. `curie` the compact uniform resource identifier (CURIE) for a biomedical
135
+ entity or concept
136
+ 3. `name` the standard name for the concept
137
+ 4. `predicate` the predicate which encodes the synonym scope, written as a CURIE
138
+ from the [OBO in OWL (`oboInOWL`)](https://bioregistry.io/oio) or RDFS
139
+ controlled vocabularies, e.g., one of:
140
+ - `rdfs:label`
141
+ - `oboInOwl:hasExactSynonym`
142
+ - `oboInOwl:hasNarrowSynonym` (i.e., the synonym represents a narrower term)
143
+ - `oboInOwl:hasBroadSynonym` (i.e., the synonym represents a broader term)
144
+ - `oboInOwl:hasRelatedSynonym` (use this if the scope is unknown)
145
+ 5. `type` the (optional) synonym property type, written as a CURIE from the
146
+ [OBO Metadata Ontology (`omo`)](https://bioregistry.io/omo) controlled
147
+ vocabulary, e.g., one of:
148
+ - `OMO:0003000` (abbreviation)
149
+ - `OMO:0003001` (ambiguous synonym)
150
+ - `OMO:0003002` (dubious synonym)
151
+ - `OMO:0003003` (layperson synonym)
152
+ - `OMO:0003004` (plural form)
153
+ - ...
154
+ 6. `provenance` a comma-delimited list of CURIEs corresponding to publications
155
+ that use the given synonym (ideally using highly actionable identifiers from
156
+ semantic spaces like [`pubmed`](https://bioregistry.io/pubmed),
157
+ [`pmc`](https://bioregistry.io/pmc), [`doi`](https://bioregistry.io/doi))
158
+ 7. `contributor` a CURIE with the ORCID identifier of the contributor
159
+ 8. `date` the optional date when the row was curated in YYYY-MM-DD format
160
+ 9. `language` the (optional) ISO 2-letter language code. If missing, assumed to
161
+ be American English.
162
+ 10. `comment` an optional comment
163
+ 11. `source` the source of the synonyms, usually `biosynonyms` unless imported
164
+ from elsewhere
165
+ 12. `taxon` the optional NCBITaxon CURIE, if the term is taxon-specific, like
166
+ `NCBITaxon:9606` for humans
167
+
168
+ Here's an example of some rows in the synonyms table (with linkified CURIEs):
169
+
170
+ | text | curie | predicate | provenance | contributor | language |
171
+ | --------------- | --------------------------------------------------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | -------- |
172
+ | alsterpaullone | [CHEBI:138488](https://bioregistry.io/CHEBI:138488) | [rdfs:label](https://bioregistry.io/rdfs:label) | [pubmed:30655881](https://bioregistry.io/pubmed:30655881) | [orcid:0000-0003-4423-4370](https://bioregistry.io/orcid:0000-0003-4423-4370) | en |
173
+ | 9-nitropaullone | [CHEBI:138488](https://bioregistry.io/CHEBI:138488) | [oboInOwl:hasExactSynonym](https://bioregistry.io/oboInOwl:hasExactSynonym) | [pubmed:11597333](https://bioregistry.io/pubmed:11597333), [pubmed:10911915](https://bioregistry.io/pubmed:10911915) | [orcid:0000-0003-4423-4370](https://bioregistry.io/orcid:0000-0003-4423-4370) | en |
174
+
175
+ **Limitations**
176
+
177
+ - It's hard to know which exact matches between different vocabularies could be
178
+ used to deduplicate synonyms. Right now, this isn't covered but some partial
179
+ solutions already exist that could be adopted.
180
+ - This doesn't keep track of NER annotations, such as when you want to keep
181
+ track of the start and end position in a full sentence or paragraph
182
+ - This doesn't keep track of transformations done to make mappings. It's more
183
+ oriented towards curation.
184
+
185
+ ## 🚀 Installation
186
+
187
+ <!-- Uncomment this section after your first ``tox -e finish``
188
+ The most recent release can be installed from
189
+ [PyPI](https://pypi.org/project/ssslm/) with uv:
190
+
191
+ ```console
192
+ $ uv pip install ssslm
193
+ ```
194
+
195
+ or with pip:
196
+
197
+ ```console
198
+ $ python3 -m pip install ssslm
199
+ ```
200
+ -->
201
+
202
+ The most recent code and data can be installed directly from GitHub with uv:
203
+
204
+ ```console
205
+ $ uv --preview pip install git+https://github.com/cthoyt/ssslm.git
206
+ ```
207
+
208
+ or with pip:
209
+
210
+ ```console
211
+ $ UV_PREVIEW=1 python3 -m pip install git+https://github.com/cthoyt/ssslm.git
212
+ ```
213
+
214
+ Note that this requires setting `UV_PREVIEW` mode enabled until the uv build
215
+ backend becomes a stable feature.
216
+
217
+ ## 👐 Contributing
218
+
219
+ Contributions, whether filing an issue, making a pull request, or forking, are
220
+ appreciated. See
221
+ [CONTRIBUTING.md](https://github.com/cthoyt/ssslm/blob/master/.github/CONTRIBUTING.md)
222
+ for more information on getting involved.
223
+
224
+ ## 👋 Attribution
225
+
226
+ ### ⚖️ License
227
+
228
+ The code in this package is licensed under the MIT License.
229
+
230
+ <!--
231
+ ### 📖 Citation
232
+
233
+ Citation goes here!
234
+ -->
235
+
236
+ <!--
237
+ ### 🎁 Support
238
+
239
+ This project has been supported by the following organizations (in alphabetical order):
240
+
241
+ - [Biopragmatics Lab](https://biopragmatics.github.io)
242
+
243
+ -->
244
+
245
+ <!--
246
+ ### 💰 Funding
247
+
248
+ This project has been supported by the following grants:
249
+
250
+ | Funding Body | Program | Grant Number |
251
+ |---------------|--------------------------------------------------------------|--------------|
252
+ | Funder | [Grant Name (GRANT-ACRONYM)](https://example.com/grant-link) | ABCXYZ |
253
+ -->
254
+
255
+ ### 🍪 Cookiecutter
256
+
257
+ This package was created with
258
+ [@audreyfeldroy](https://github.com/audreyfeldroy)'s
259
+ [cookiecutter](https://github.com/cookiecutter/cookiecutter) package using
260
+ [@cthoyt](https://github.com/cthoyt)'s
261
+ [cookiecutter-snekpack](https://github.com/cthoyt/cookiecutter-snekpack)
262
+ template.
263
+
264
+ ## 🛠️ For Developers
265
+
266
+ <details>
267
+ <summary>See developer instructions</summary>
268
+
269
+ The final section of the README is for if you want to get involved by making a
270
+ code contribution.
271
+
272
+ ### Development Installation
273
+
274
+ To install in development mode, use the following:
275
+
276
+ ```console
277
+ $ git clone git+https://github.com/cthoyt/ssslm.git
278
+ $ cd ssslm
279
+ $ uv --preview pip install -e .
280
+ ```
281
+
282
+ Alternatively, install using pip:
283
+
284
+ ```console
285
+ $ UV_PREVIEW=1 python3 -m pip install -e .
286
+ ```
287
+
288
+ Note that this requires setting `UV_PREVIEW` mode enabled until the uv build
289
+ backend becomes a stable feature.
290
+
291
+ ### Updating Package Boilerplate
292
+
293
+ This project uses `cruft` to keep boilerplate (i.e., configuration, contribution
294
+ guidelines, documentation configuration) up-to-date with the upstream
295
+ cookiecutter package. Install cruft with either `uv tool install cruft` or
296
+ `python3 -m pip install cruft` then run:
297
+
298
+ ```console
299
+ $ cruft update
300
+ ```
301
+
302
+ More info on Cruft's update command is available
303
+ [here](https://github.com/cruft/cruft?tab=readme-ov-file#updating-a-project).
304
+
305
+ ### 🥼 Testing
306
+
307
+ After cloning the repository and installing `tox` with
308
+ `uv tool install tox --with tox-uv` or `python3 -m pip install tox tox-uv`, the
309
+ unit tests in the `tests/` folder can be run reproducibly with:
310
+
311
+ ```console
312
+ $ tox -e py
313
+ ```
314
+
315
+ Additionally, these tests are automatically re-run with each commit in a
316
+ [GitHub Action](https://github.com/cthoyt/ssslm/actions?query=workflow%3ATests).
317
+
318
+ ### 📖 Building the Documentation
319
+
320
+ The documentation can be built locally using the following:
321
+
322
+ ```console
323
+ $ git clone git+https://github.com/cthoyt/ssslm.git
324
+ $ cd ssslm
325
+ $ tox -e docs
326
+ $ open docs/build/html/index.html
327
+ ```
328
+
329
+ The documentation automatically installs the package as well as the `docs` extra
330
+ specified in the [`pyproject.toml`](pyproject.toml). `sphinx` plugins like
331
+ `texext` can be added there. Additionally, they need to be added to the
332
+ `extensions` list in [`docs/source/conf.py`](docs/source/conf.py).
333
+
334
+ The documentation can be deployed to [ReadTheDocs](https://readthedocs.io) using
335
+ [this guide](https://docs.readthedocs.io/en/stable/intro/import-guide.html). The
336
+ [`.readthedocs.yml`](.readthedocs.yml) YAML file contains all the configuration
337
+ you'll need. You can also set up continuous integration on GitHub to check not
338
+ only that Sphinx can build the documentation in an isolated environment (i.e.,
339
+ with `tox -e docs-test`) but also that
340
+ [ReadTheDocs can build it too](https://docs.readthedocs.io/en/stable/pull-requests.html).
341
+
342
+ #### Configuring ReadTheDocs
343
+
344
+ 1. Log in to ReadTheDocs with your GitHub account to install the integration at
345
+ https://readthedocs.org/accounts/login/?next=/dashboard/
346
+ 2. Import your project by navigating to https://readthedocs.org/dashboard/import
347
+ then clicking the plus icon next to your repository
348
+ 3. You can rename the repository on the next screen using a more stylized name
349
+ (i.e., with spaces and capital letters)
350
+ 4. Click next, and you're good to go!
351
+
352
+ ### 📦 Making a Release
353
+
354
+ #### Configuring Zenodo
355
+
356
+ [Zenodo](https://zenodo.org) is a long-term archival system that assigns a DOI
357
+ to each release of your package.
358
+
359
+ 1. Log in to Zenodo via GitHub with this link:
360
+ https://zenodo.org/oauth/login/github/?next=%2F. This brings you to a page
361
+ that lists all of your organizations and asks you to approve installing the
362
+ Zenodo app on GitHub. Click "grant" next to any organizations you want to
363
+ enable the integration for, then click the big green "approve" button. This
364
+ step only needs to be done once.
365
+ 2. Navigate to https://zenodo.org/account/settings/github/, which lists all of
366
+ your GitHub repositories (both in your username and any organizations you
367
+ enabled). Click the on/off toggle for any relevant repositories. When you
368
+ make a new repository, you'll have to come back to this
369
+
370
+ After these steps, you're ready to go! After you make "release" on GitHub (steps
371
+ for this are below), you can navigate to
372
+ https://zenodo.org/account/settings/github/repository/cthoyt/ssslm to see the
373
+ DOI for the release and link to the Zenodo record for it.
374
+
375
+ #### Registering with the Python Package Index (PyPI)
376
+
377
+ You only have to do the following steps once.
378
+
379
+ 1. Register for an account on the
380
+ [Python Package Index (PyPI)](https://pypi.org/account/register)
381
+ 2. Navigate to https://pypi.org/manage/account and make sure you have verified
382
+ your email address. A verification email might not have been sent by default,
383
+ so you might have to click the "options" dropdown next to your address to get
384
+ to the "re-send verification email" button
385
+ 3. 2-Factor authentication is required for PyPI since the end of 2023 (see this
386
+ [blog post from PyPI](https://blog.pypi.org/posts/2023-05-25-securing-pypi-with-2fa/)).
387
+ This means you have to first issue account recovery codes, then set up
388
+ 2-factor authentication
389
+ 4. Issue an API token from https://pypi.org/manage/account/token
390
+
391
+ #### Configuring your machine's connection to PyPI
392
+
393
+ You have to do the following steps once per machine.
394
+
395
+ ```console
396
+ $ uv tool install keyring
397
+ $ keyring set https://upload.pypi.org/legacy/ __token__
398
+ $ keyring set https://test.pypi.org/legacy/ __token__
399
+ ```
400
+
401
+ Note that this deprecates previous workflows using `.pypirc`.
402
+
403
+ #### Uploading to PyPI
404
+
405
+ After installing the package in development mode and installing `tox` with
406
+ `uv tool install tox --with tox-uv` or `python3 -m pip install tox tox-uv`, run
407
+ the following from the console:
408
+
409
+ ```console
410
+ $ tox -e finish
411
+ ```
412
+
413
+ This script does the following:
414
+
415
+ 1. Uses [bump-my-version](https://github.com/callowayproject/bump-my-version) to
416
+ switch the version number in the `pyproject.toml`, `CITATION.cff`,
417
+ `src/ssslm/version.py`, and [`docs/source/conf.py`](docs/source/conf.py) to
418
+ not have the `-dev` suffix
419
+ 2. Packages the code in both a tar archive and a wheel using
420
+ [`uv build`](https://docs.astral.sh/uv/guides/publish/#building-your-package)
421
+ 3. Uploads to PyPI using
422
+ [`uv publish`](https://docs.astral.sh/uv/guides/publish/#publishing-your-package).
423
+ 4. Push to GitHub. You'll need to make a release going with the commit where the
424
+ version was bumped.
425
+ 5. Bump the version to the next patch. If you made big changes and want to bump
426
+ the version by minor, you can use `tox -e bumpversion -- minor` after.
427
+
428
+ #### Releasing on GitHub
429
+
430
+ 1. Navigate to https://github.com/cthoyt/ssslm/releases/new to draft a new
431
+ release
432
+ 2. Click the "Choose a Tag" dropdown and select the tag corresponding to the
433
+ release you just made
434
+ 3. Click the "Generate Release Notes" button to get a quick outline of recent
435
+ changes. Modify the title and description as you see fit
436
+ 4. Click the big green "Publish Release" button
437
+
438
+ This will trigger Zenodo to assign a DOI to your release as well.
439
+
440
+ </details>