-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support old match_term_type metadata slot.
Initial versions of SSSOM used a single slot called 'match_term_type' to indicate what was being mapped. This slot has been replaced in SSSOM 0.9.1 by two slots called 'subject_type' and 'object_type'. If a 'match_term_type' slot is found in a mapping set (and that set does not contain 'subject_type' and 'object_type' slots), we convert it to its modern equivalents.
- Loading branch information
Showing
5 changed files
with
96 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#curie_map: | ||
# FBbt: "http://purl.obolibrary.org/obo/FBbt_" | ||
# UBERON: "http://purl.obolibrary.org/obo/UBERON_" | ||
subject_id subject_label predicate_id object_id mapping_justification | ||
FBbt:00000001 organism semapv:crossSpeciesExactMatch UBERON:0000468 semapv:LexicalMatching | ||
FBbt:00000002 tagma semapv:crossSpeciesExactMatch UBERON:6000002 | ||
subject_id subject_label predicate_id object_id mapping_justification subject_type object_type | ||
FBbt:00000001 organism semapv:crossSpeciesExactMatch UBERON:0000468 semapv:LexicalMatching | ||
FBbt:00000002 tagma semapv:crossSpeciesExactMatch UBERON:6000002 owl class owl class |
78 changes: 78 additions & 0 deletions
78
core/src/main/java/org/incenp/obofoundry/sssom/MatchTermTypeConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* SSSOM-Java - SSSOM library for Java | ||
* Copyright © 2023 Damien Goutte-Gattat | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the Gnu General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.incenp.obofoundry.sssom; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* A YAML preprocessor to convert a dictionary containing a | ||
* {@code match_term_type} metadata slot into its standardised equivalents. | ||
* <p> | ||
* Initial versions of the SSSOM specification described a | ||
* {@code match_term_type} metadata slot which accepted values from a specific | ||
* enumeration and was intended to describe what was being matched (e.g., it | ||
* indicated that a given mapping was between two OWL classes, or between two | ||
* SKOS concepts, etc.). In SSSOM 0.9.1, this slot was replaced by two distinct | ||
* slots called {@code subject_type} and {@code object_type}. | ||
*/ | ||
public class MatchTermTypeConverter implements IYAMLPreprocessor { | ||
|
||
@Override | ||
public void process(Map<String, Object> rawMap) throws SSSOMFormatException { | ||
if ( rawMap.containsKey("match_term_type") && !rawMap.containsKey("subject_type") | ||
&& !rawMap.containsKey("object_type") ) { | ||
Object rawValue = rawMap.get("match_term_type"); | ||
String value = null; | ||
if ( rawValue != null ) { | ||
if ( String.class.isInstance(rawValue) ) { | ||
switch ( String.class.cast(rawValue) ) { | ||
case "ConceptMatch": | ||
value = "skos concept"; | ||
break; | ||
case "ClassMatch": | ||
value = "owl class"; | ||
break; | ||
case "ObjectPropertyMatch": | ||
value = "owl object property"; | ||
break; | ||
case "IndividualMatch": | ||
value = "owl named indivdual"; | ||
break; | ||
case "DataPropertyMatch": | ||
value = "owl data property"; | ||
break; | ||
case "TermMatch": | ||
// FIXME: It's unclear what is the equivalent of TermMatch in the new enum. | ||
value = "rdf literal"; | ||
break; | ||
} | ||
} | ||
|
||
if ( value == null ) { | ||
throw new SSSOMFormatException("Typing error when parsing 'match_term_type'"); | ||
} | ||
} | ||
|
||
rawMap.remove("match_term_type"); | ||
rawMap.put("subject_type", value); | ||
rawMap.put("object_type", value); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#curie_map: | ||
# FBbt: "http://purl.obolibrary.org/obo/FBbt_" | ||
# UBERON: "http://purl.obolibrary.org/obo/UBERON_" | ||
subject_id subject_label predicate_id object_id match_type | ||
FBbt:00000001 organism semapv:crossSpeciesExactMatch UBERON:0000468 Lexical | ||
FBbt:00000002 tagma semapv:crossSpeciesExactMatch UBERON:6000002 | ||
subject_id subject_label predicate_id object_id match_type match_term_type | ||
FBbt:00000001 organism semapv:crossSpeciesExactMatch UBERON:0000468 Lexical | ||
FBbt:00000002 tagma semapv:crossSpeciesExactMatch UBERON:6000002 ClassMatch |