FAIRLinked.InterfaceMDS package

Submodules

FAIRLinked.InterfaceMDS.add_ontology_term module

Script to interactively add a new term to an existing ontology in Turtle (TTL) format.

Prompts the user for term metadata (label, parent class, value type, unit) and appends RDF triples to a new file (original name suffixed with _rxl895) to preserve the original.

FAIRLinked.InterfaceMDS.add_ontology_term.add_term_to_ontology(ontology_path)[source]

Add a new term to a TTL ontology file and write to a new versioned file.

Parameters:

ontology_path (str) – Path to the TTL ontology file.

Returns:

True if added successfully, else False.

Return type:

bool

FAIRLinked.InterfaceMDS.add_ontology_term.format_term(term_details)[source]

Format term details into RDF/Turtle syntax.

Parameters:

term_details (dict) – Metadata for the new term.

Returns:

RDF Turtle triples to be appended.

Return type:

str

FAIRLinked.InterfaceMDS.add_ontology_term.get_term_details()[source]

Prompt the user to input details for a new ontology term.

Returns:

A dictionary with term_name, label, parent_class, definition, value_type, and unit.

Return type:

dict

FAIRLinked.InterfaceMDS.convert_ttl_to_drawio module

FAIRLinked.InterfaceMDS.convert_ttl_to_drawio.convert_ttl_to_cemento(ttl_input_path, drawio_output_path)[source]

This function uses the CEMENTO package to generate a draw.io diagram from a turtle file, allowing for better visualization of ontologies.

Parameters:
  • ttl_input_path – Path to turtle file

  • drawio_output_path – Path to store draw.io diagram

Returns:

None

FAIRLinked.InterfaceMDS.domain_subdomain_viewer module

FAIRLinked.InterfaceMDS.domain_subdomain_viewer.domain_subdomain_viewer()[source]

Display all unique domain and subdomain values from an RDF ontology file.

This function parses the RDF graph from the given file path and prints the unique values of the predicates mds:hasDomain and mds:hasSubDomain. Uniqueness is determined in a case-insensitive manner.

Prints:
  • A list of unique domain values.

  • A list of unique subdomain values.

FAIRLinked.InterfaceMDS.load_mds_ontology module

FAIRLinked.InterfaceMDS.load_mds_ontology.load_mds_ontology_graph()[source]

Attempts to load the MDS ontology RDF graph by following redirects and using content negotiation to request different RDF serialization formats.

Tries to fetch the ontology in the following formats (in order of preference):
  1. Turtle (“text/turtle”)

  2. JSON-LD (“application/ld+json”)

  3. RDF/XML (“application/rdf+xml”)

If a request is successful, the RDF data is parsed into an rdflib Graph. It also prints the owl:versionInfo if available, to indicate the version of the ontology that was loaded.

Returns:

The parsed RDF graph of the MDS ontology, or None if all attempts fail.

Return type:

rdflib.Graph

Raises:

None explicitly. All exceptions are caught and printed.

FAIRLinked.InterfaceMDS.rdf_subject_extractor module

FAIRLinked.InterfaceMDS.rdf_subject_extractor.extract_subject_details(graph)[source]

Extract all subjects from an RDF graph, including preferred labels and predicate-object details.

Parameters:

graph (rdflib.Graph) – The parsed RDF graph.

Returns:

DataFrame with ‘subject_id’, ‘label’, and ‘info’.

Return type:

pd.DataFrame

FAIRLinked.InterfaceMDS.rdf_subject_extractor.fuzzy_filter_subjects_strict(df, keywords, column='label', max_l_dist=1)[source]

Perform strict fuzzy word-level matching using Levenshtein distance.

Parameters:
  • df (pd.DataFrame) – DataFrame to filter.

  • keywords (list of str) – Keywords to search for.

  • column (str) – Column to search.

  • max_l_dist (int) – Max Levenshtein distance.

Returns:

Filtered DataFrame of matches.

Return type:

pd.DataFrame

FAIRLinked.InterfaceMDS.rdf_subject_extractor.main()[source]

Example usage for local testing. Not included in the package version.

FAIRLinked.InterfaceMDS.term_search_general module

FAIRLinked.InterfaceMDS.term_search_general.term_search_general(query_term=None, search_types=None)[source]

Search an RDF ontology for subjects with a specified predicate and optional query term.

Parameters:
  • query_term (str or None) – Optional term to match against the object of the predicate. If None, all values will be returned for the given search types.

  • search_types (list[str]) – List of search types: “Domain”, “SubDomain”, or “Study Stage”.

Prints:
  • A list of labels for matching subjects, grouped by search type.

Module contents