Package org.incenp.obofoundry.sssom.util
Class ExtendedPrefixMap
java.lang.Object
org.incenp.obofoundry.sssom.util.ExtendedPrefixMap
A basic implementation of the “Extended Prefix Map” concept promoted by the
Bioregistry.
The implementation is basic because it is never intended to actually be used to manage prefixes. The only purpose here is to be able to perform a single “reconciliation” operation, to force a mapping set to use the “canonical” prefixes set forth in a given extended prefix map.
This is another case of “the usual bioinformatics paradigm of ignoring the specs and inferring a format from a few examples”, but then again, the entire “spec” is nothing more than a single example, so we don’t have much choice.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionExtendedPrefixMap
(File file) Creates a new extended prefix map from the specified file.ExtendedPrefixMap
(InputStream stream) Creates a new extended prefix map from the specified stream.ExtendedPrefixMap
(String filename) Creates a new extended prefix map from the specified filename. -
Method Summary
Modifier and TypeMethodDescriptioncanonicalise
(String iri) Canonicalises an IRI.canonicalise
(List<String> iris, boolean inPlace) Canonicalises a list of IRIs.void
canonicalise
(List<Mapping> mappings) Canonicalises a list of mappings.void
canonicalise
(MappingSet set) Canonicalises a mapping set.Gets the full prefix map, associating every known prefix names to the canonical URL prefix.Gets a simple prefix map associating the canonical prefix name to the canonical URL prefix.
-
Constructor Details
-
ExtendedPrefixMap
Creates a new extended prefix map from the specified file.- Parameters:
file
- The file to read the map from.- Throws:
IOException
- If any error occurs when reading the file (including a format error).
-
ExtendedPrefixMap
Creates a new extended prefix map from the specified filename.- Parameters:
filename
- The name of the file to read the map from.- Throws:
IOException
- If any error occurs when reading the file (including a format error).
-
ExtendedPrefixMap
Creates a new extended prefix map from the specified stream.- Parameters:
stream
- The stream to read the map from.- Throws:
IOException
- If any error occurs when reading the file (including a format error).
-
-
Method Details
-
getSimplePrefixMap
Gets a simple prefix map associating the canonical prefix name to the canonical URL prefix.- Returns:
- The simple, canonical prefix map.
-
getFullPrefixMap
Gets the full prefix map, associating every known prefix names to the canonical URL prefix.- Returns:
- The full prefix map.
-
canonicalise
Canonicalises an IRI. This method checks whether the specified IRI uses a prefix that is a synonym of a canonical prefix, and returns a new IRI using the corresponding canonical prefix.- Parameters:
iri
- The IRI to canonicalise.- Returns:
- The canonical form of the IRI; may be identical to the original IRI if (1) that URI was already using the canonical prefix, or (2) no matching prefix was found in the extended map.
-
canonicalise
Canonicalises a list of IRIs.- Parameters:
iris
- The IRIs to canonicalise.inPlace
- Iftrue
, the original list will be modified and returned; otherwise a new list with canonicalised IRIs will be returned.- Returns:
- A list with canonicalised IRIs.
-
canonicalise
Canonicalises a list of mappings. This method performs a canonicalisation on the values of all slots of type EntityReference.- Parameters:
mappings
- The mappings of canonicalise.
-
canonicalise
Canonicalises a mapping set. This performs a canonicalisation on the values of all slots of type EntityReference in the set itself, then in the individual mappings. The original prefix map of the set is updated with the canonical prefix map.- Parameters:
set
- The mapping set to canonicalise.
-