Skip to content

Commit 744a36d

Browse files
authored
Cleanup public interface (#589)
1 parent c99be4d commit 744a36d

File tree

10 files changed

+261
-151
lines changed

10 files changed

+261
-151
lines changed

README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,33 @@
2121

2222
<img src="https://github.com/tis-lab/closed-illustrations/raw/master/logos/sssom-logos/sssom_logo_black_banner.png" />
2323

24-
SSSOM (Simple Standard for Sharing Ontology Mappings) is a TSV and RDF/OWL standard for ontology mappings
24+
A Python library and command line interface (CLI) for working with
25+
[SSSOM (Simple Standard for Sharing Ontology Mappings)](https://github.com/mapping-commons/sssom).
2526

26-
```
27-
WARNING:
28-
The export formats (json, rdf) of sssom-py are not yet finalised!
29-
Please expect changes in future releases!
30-
```
27+
## Getting Started
28+
29+
A SSSOM TSV can be parsed with
30+
31+
```python
32+
import sssom
3133

32-
See https://github.com/OBOFoundry/SSSOM
34+
# other SSSOM files can be found on https://mapping-commons.github.io
35+
url = "https://raw.githubusercontent.com/mapping-commons/mh_mapping_initiative/master/mappings/mp_hp_eye_impc.sssom.tsv"
36+
37+
# TSV can be parsed into a mapping set dataframe object,
38+
# which includes a pandas DataFrame, a curies.Converter,
39+
# and metadata
40+
msdf = sssom.parse_tsv(url)
41+
42+
# SSSOM comes with several "write" functions
43+
sssom.write_tsv(msdf, "test.tsv")
44+
sssom.write_json(msdf, "test.json")
45+
sssom.write_owl(msdf, "test.owl")
46+
sssom.write_rdf(msdf, "test.ttl")
47+
```
3348

34-
This is a python library and command line toolkit for working with SSSOM. It also defines a schema for SSSOM.
49+
> [!WARNING]
50+
> The export formats (json, rdf) of sssom-py are not yet finalised! Expect changes in future releases.
3551
3652
## Documentation
3753

src/sssom/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
dataframe_to_ptable,
2020
filter_redundant_rows,
2121
group_mappings,
22-
parse,
2322
reconcile_prefix_and_data,
2423
)
2524

2625
from .constants import generate_mapping_set_id, get_default_metadata # noqa:401
26+
from .parsers import parse_csv, parse_sssom_table, parse_tsv # noqa:401
27+
from .writers import write_json, write_owl, write_rdf, write_tsv # noqa:401

src/sssom/constants.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import uuid
55
from enum import Enum
66
from functools import cached_property, lru_cache
7-
from typing import Any, Dict, List, Literal, Set
7+
from typing import Any, Dict, List, Literal, Set, TextIO, Union
88

99
import importlib_resources
1010
import yaml
@@ -316,3 +316,7 @@ def get_default_metadata() -> MetadataType:
316316
"mapping_set_id": generate_mapping_set_id(),
317317
"license": DEFAULT_LICENSE,
318318
}
319+
320+
321+
#: A hint for functions that can take a path or an IO
322+
PathOrIO = Union[str, pathlib.Path, TextIO]

0 commit comments

Comments
 (0)