Class XrefExtractor

java.lang.Object
org.incenp.obofoundry.sssom.owl.XrefExtractor

public class XrefExtractor extends Object
Extract mappings from cross-references (oboInOwl:hasDbXref annotations) in a ontology.
  • Constructor Details

    • XrefExtractor

      public XrefExtractor()
  • Method Details

    • setPrefixMap

      public void setPrefixMap(Map<String,String> map)
      Sets the prefix map to be used when processing cross-reference annotations. By default, only cross-references using a known prefix name will be derived into mappings.
      Parameters:
      map - A map of prefix names to URL prefixes.
    • addPrefixToPredicateMapping

      public void addPrefixToPredicateMapping(String prefixName, String predicate)
      Maps a prefix name to a predicate. By default, mappings derived from cross-references have a oboInOwl:hasDbXref predicate. Use this method to force the use of another predicate for cross-references that use a specific prefix name.
      Parameters:
      prefixName - The prefix name, as used in cross-references.
      predicate - The mapping predicate to use.
    • fillPrefixToPredicateMap

      public void fillPrefixToPredicateMap(org.semanticweb.owlapi.model.OWLOntology ontology)
      Gets the mappings between prefix names and predicates from annotations in the given ontology.

      This method recognises the following annotations:

      • oboInOwl#treat-xrefs-as-equivalent: map a prefix name to the skos:exactMatch predicate;
      • oboInOwl#treat-xrefs-as-is_a: map a prefix name to the skos:broadMatch predicate;
      • oboInOwl#treat-xrefs-as-has-subclass: map a prefix name to the skos:narrowMatch predicate;
      • oboInOwl#treat-xrefs-as-genus-differentia: map a prefix name to the semapv:crossSpeciesExactMatch predicate;
      • oboInOwl#treat-xrefs-as-reverse-genus-differentia: likewise.
      Parameters:
      ontology - The ontology to extract the prefix-to-predicate mappings from.
    • includeObsoletes

      public void includeObsoletes(boolean value)
      Indicates whether cross-references on obsoleted terms should be extracted. The default behaviour is to ignore obsoleted terms.
      Parameters:
      value - true to extract cross-references on obsoleted terms.
    • extract

      public MappingSet extract(org.semanticweb.owlapi.model.OWLOntology ontology)
      Extract mappings from cross-references in the specified ontology. Only cross-references with prefixes that are (1) known, and (2) associated with a predicate (through either addPrefixToPredicateMapping(String, String) or fillPrefixToPredicateMap(OWLOntology)) are taken into account.
      Parameters:
      ontology - The ontology to extract mappings from.
      Returns:
      The set of mappings extracted from the ontology.
    • extract

      public MappingSet extract(org.semanticweb.owlapi.model.OWLOntology ontology, boolean permissive, boolean includeGeneric)
      Extract mappings from cross-references in the specified ontology.
      Parameters:
      ontology - The ontology to extract mappings from.
      permissive - If true, cross-references using an non-resolvable prefix name will not be ignored.
      includeGeneric - If true, cross-references using a prefix name that has not been associated to a mapping predicate will not be ignored, and will yield mappings with the oboInOwl:hasDbXref predicate.
      Returns:
      The set of mappings extracted from the ontology.
    • getUnknownPrefixNames

      public Set<String> getUnknownPrefixNames()
      Gets any prefix names encountered in cross-references that could not be resolved.
      Returns:
      The list of unknown prefix names.