Repository

class Repository(*, predictions_path: Path, positives_path: Path, negatives_path: Path, unsure_path: Path, mapping_set: MappingSet | None = None, purl_base: str | None = None, basename: str | None = None, ndex_uuid: str | None = None, web_title: str | None = None, web_disabled_message: str | None = None, web_footer: str | None = None, merge_standardize_bioregistry: bool | None = None)[source]

Bases: BaseModel

A data structure containing information about a SSSOM repository.

There are two ways to configure a repository:

  1. Parse from a JSON file representing a configuration

  2. Configure using Python

Configuring a Repository with JSON

Since the Repository class inherits from pydantic.BaseModel, you can define the data externally in a JSON file and parse it. Given the following example configuration (corresponding to the Biomappings project), the following Python code can be used to load the repository and run the CLI.

{
  "predictions_path": "predictions.sssom.tsv",
  "positives_path": "positive.sssom.tsv",
  "negatives_path": "negative.sssom.tsv",
  "unsure_path": "unsure.sssom.tsv",
  "purl_base": "https://w3id.org/biopragmatics/biomappings/sssom",
  "mapping_set": {
    "mapping_set_id": "https://w3id.org/biopragmatics/biomappings/sssom/biomappings.sssom.tsv",
    "mapping_set_description": "Biomappings is a repository of community curated and predicted equivalences and related mappings between named biological entities that are not available from primary sources. It's also a place where anyone can contribute curations of predicted mappings or their own novel mappings.",
    "mapping_set_title": "Biomappings",
    "license": "https://creativecommons.org/publicdomain/zero/1.0/",
    "creator_id": ["orcid:0000-0003-4423-4370"]
  }
}
from pathlib import Path
from sssom_curator import Repository

path = Path("sssom-curator.json")
repository = Repository.model_validate_json(path.read_text())

if __name__ == "__main__":
    repository.run_cli()

Configuring a Repository with Python

You can configure your repository using the sssom_curator.Repository object directly from within Python, which offers the full flexibility of a general purpose programming language. Again using Biomappings as an example, here’s how the Python file would look:

from sssom_pydantic import MappingSet
from sssom_curator import Repository
from pathlib import Path

# Assume files are all in the same folder
HERE = Path(__file__).parent.resolve()

repository = Repository(
    positives_path=HERE.joinpath("positive.sssom.tsv"),
    negatives_path=HERE.joinpath("negative.sssom.tsv"),
    unsure_path=HERE.joinpath("unsure.sssom.tsv"),
    predictions_path=HERE.joinpath("predictions.sssom.tsv"),
    mapping_set=MappingSet(
        title="Biomappings",
        id="https://w3id.org/biopragmatics/biomappings/sssom/biomappings.sssom.tsv",
    ),
    # Add the beginning part of the PURL used to
    # construct exports.
    purl_base="https://w3id.org/biopragmatics/biomappings/sssom/",
)

if __name__ == "__main__":
    repository.run_cli()

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Attributes Summary

call_to_path

Get a dictionary from calls to paths.

curated_paths

Get curated paths.

export_paths

Get export paths.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

paths

Get all paths.

Methods Summary

append_lexical_predictions(prefix, ...[, ...])

Append lexical predictions.

append_negative_mappings(mappings, *[, ...])

Append new lines to the negative mappings document.

append_positive_mappings(mappings, *[, ...])

Append new lines to the positive mappings document.

append_predicted_mappings(mappings, *[, ...])

Append new lines to the predicted mappings document.

from_directory(directory)

Load an implicit configuration from a directory.

from_path(path)

Load a configuration at a path.

get_cli(*[, enable_web, get_user, ...])

Get a CLI.

get_converter()

Get a converter chained from all files.

get_test_class([converter_strategy])

Get a test case class.

lexical_prediction_cli(prefix, target, /, *)

Run the lexical predictions CLI.

read_negative_mappings()

Load the negative mappings.

read_positive_mappings()

Load the positive mappings.

read_predicted_mappings()

Load the predicted mappings.

read_unsure_mappings()

Load the unsure mappings.

run_cli(*args, **kwargs)

Run the CLI.

update_relative_paths(directory)

Update paths relative to the directory.

Attributes Documentation

call_to_path

Get a dictionary from calls to paths.

curated_paths

Get curated paths.

export_paths

Get export paths.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

paths

Get all paths.

Methods Documentation

append_lexical_predictions(prefix: str, target_prefixes: str | Iterable[str], *, mapping_tool: str | MappingTool | None = None, force: bool = False, force_process: bool = False, cache: bool = True, converter: curies.Converter | None = None, **kwargs: Any) None[source]

Append lexical predictions.

append_negative_mappings(mappings: Iterable[SemanticMapping], *, converter: curies.Converter | None = None) None[source]

Append new lines to the negative mappings document.

append_positive_mappings(mappings: Iterable[SemanticMapping], *, converter: curies.Converter | None = None, sort: bool = True, **kwargs: Any) None[source]

Append new lines to the positive mappings document.

append_predicted_mappings(mappings: Iterable[SemanticMapping], *, converter: curies.Converter | None = None) None[source]

Append new lines to the predicted mappings document.

classmethod from_directory(directory: str | Path) Self[source]

Load an implicit configuration from a directory.

classmethod from_path(path: str | Path) Self[source]

Load a configuration at a path.

get_cli(*, enable_web: bool = True, get_user: Callable[[], Reference] | None = None, output_directory: Path | None = None, sssom_directory: Path | None = None, image_directory: Path | None = None, get_orcid_to_name: Callable[[], dict[str, str]] | None = None) Group[source]

Get a CLI.

get_converter() Converter[source]

Get a converter chained from all files.

get_test_class(converter_strategy: ConverterStrategy | None = None) type[IntegrityTestCase][source]

Get a test case class.

lexical_prediction_cli(prefix: str, target: str | list[str], /, *, mapping_tool: str | MappingTool | None = None, **kwargs: Any) None[source]

Run the lexical predictions CLI.

read_negative_mappings() list[SemanticMapping][source]

Load the negative mappings.

read_positive_mappings() list[SemanticMapping][source]

Load the positive mappings.

read_predicted_mappings() list[SemanticMapping][source]

Load the predicted mappings.

read_unsure_mappings() list[SemanticMapping][source]

Load the unsure mappings.

run_cli(*args: Any, **kwargs: Any) None[source]

Run the CLI.

update_relative_paths(directory: Path) None[source]

Update paths relative to the directory.