Skip to content

Commit

Permalink
added -v option to --remove-axioms-about to invert choice
Browse files Browse the repository at this point in the history
preserve replaced-by when removing annotation assertions if deprecated preserved
added docs for module option
  • Loading branch information
cmungall committed Dec 13, 2017
1 parent f90176d commit 178e1f9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
10 changes: 7 additions & 3 deletions OWLTools-Core/src/main/java/owltools/mooncat/Mooncat.java
Original file line number Diff line number Diff line change
Expand Up @@ -736,16 +736,20 @@ public void removeClassesNotInIDSpace(String idspace, boolean removeDangling) {
}

public void removeAxiomsAboutIdSpace(String idspace, boolean removeDangling) {
removeAxiomsAboutIdSpace(idspace, removeDangling, true);
removeAxiomsAboutIdSpace(idspace, removeDangling, true, false);
}
public void removeAxiomsAboutIdSpace(String idspace, boolean removeDangling, boolean removeAnnotations) {
public void removeAxiomsAboutIdSpace(String idspace, boolean removeDangling, boolean removeAnnotations, boolean isInvert) {
LOG.info("Removing classes not in: "+idspace);
idspace = idspace.toLowerCase()+":";
Set<OWLAxiom> rmAxioms = new HashSet<>();
int n=0;
for (OWLClass c : graph.getSourceOntology().getClassesInSignature()) {
String id = graph.getIdentifier(c).toLowerCase();
if (id.startsWith(idspace)) {
boolean isRm = id.startsWith(idspace);
if (isInvert) {
isRm = !isRm;
}
if (isRm) {
n++;
rmAxioms.addAll(graph.getSourceOntology().getAxioms(c));
if (removeAnnotations) {
Expand Down
19 changes: 16 additions & 3 deletions OWLTools-Runner/src/main/java/owltools/cli/CommandRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,7 @@ else if (opts.nextEq("--remove-annotation-assertions")) {
boolean isPreserveSynonyms = false;
boolean isPreserveRelations = false;
boolean isPreserveDeprecations = true;
boolean isPreserveDeprecationAxioms = true;
Set<IRI> preserveAnnotationPropertyIRIs = new HashSet<IRI>();
while (opts.hasOpts()) {
if (opts.nextEq("-l|--preserve-labels")) {
Expand Down Expand Up @@ -1170,6 +1171,12 @@ else if (opts.nextEq("-p|--preserve-property")) {
if (aaa.getProperty().isDeprecated()) {
keepAxioms.add(aaa);
}
if (isPreserveDeprecationAxioms) {
if (piri.equals(Obo2OWLVocabulary.IRI_OIO_consider.getIRI()) ||
piri.equals(Obo2OWLVocabulary.IRI_IAO_0100001.getIRI())) {
keepAxioms.add(aaa);
}
}
}
if (isPreserveDefinitions) {
if (piri.equals(Obo2OWLVocabulary.IRI_IAO_0000115.getIRI())) {
Expand Down Expand Up @@ -2788,7 +2795,7 @@ else if (opts.nextEq("--reason-subontologies")) {
}
}
else if (opts.nextEq("--run-reasoner")) {
opts.info("[-r reasonername] [--assert-implied] [--indirect] [-u]", "infer new relationships");
opts.info("[-r reasonername] [--assert-implied] [--indirect] [-u] [-m UNSATMODFILE]", "infer new relationships");
boolean isAssertImplied = false;
boolean isDirect = true;
boolean isShowUnsatisfiable = false;
Expand Down Expand Up @@ -3691,20 +3698,26 @@ else if (opts.nextEq("--remove-subset")) {
m.removeSubsetClasses(cset, isRemoveDangling);
}
else if (opts.nextEq("--remove-axioms-about")) {
opts.info("[-d] IDSPACES", "Removes axioms that are about the specified ID space");
opts.info("[-v] [-d] IDSPACES", "Removes axioms that are about the specified ID space");
boolean isRemoveDangling = true;
boolean isInvert = false;
while (opts.hasOpts()) {
if (opts.nextEq("-d|--keep-dangling")) {
opts.info("",
"if specified, dangling axioms (ie pointing to removed classes) are preserved");
isRemoveDangling = false;
}
else if (opts.nextEq("-v|--invert")) {
opts.info("",
"invert - remove axioms NOT about");
isInvert = true;
}
else
break;
}
String idspace = opts.nextOpt();
Mooncat m = new Mooncat(g);
m.removeAxiomsAboutIdSpace(idspace, isRemoveDangling);
m.removeAxiomsAboutIdSpace(idspace, isRemoveDangling, true, isInvert);
}
else if (opts.nextEq("--remove-classes-in-idspace")) {
opts.info("[-d] [-s IDSPACE]", "Removes classes in an ID space from ontology");
Expand Down

0 comments on commit 178e1f9

Please sign in to comment.