Skip to content

Commit

Permalink
Fix bug in finding character attribute for quality. Update SBT.
Browse files Browse the repository at this point in the history
  • Loading branch information
balhoff committed Dec 2, 2019
1 parent c416b98 commit 8940fa0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/dist
.DS_Store
target
/.idea
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ organization := "org.phenoscape"

name := "Phenex"

version := "1.21.0"
version := "1.21.1"

mainClass in Compile := Some("org.phenoscape.main.Phenex")

Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.15
sbt.version=1.3.4
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.5")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.5.1")
11 changes: 11 additions & 0 deletions src/main/java/org/obo/annotation/base/OBOUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,17 @@ public static OBOClass getIsaParentForTerm(OBOClass term) {
return null;
}

public static Set<OBOClass> getIsaParentsForTerm(OBOClass term) {
final Collection<Link> parents = term.getParents();
final Set<OBOClass> isaParents = new HashSet<>();
for (Link link : parents) {
if (link.getType().getName().equals("is_a")) {
isaParents.add((OBOClass) (link.getParent()));
}
}
return isaParents;
}

// if (ObjectUtils.equals(this.validName, validName)) return;
// final OBOClass oldValue = this.validName;
// this.validName = validName;
Expand Down
21 changes: 16 additions & 5 deletions src/main/java/org/phenoscape/io/TabDelimitedWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ private String getCharacterHeader() {
}

private OBOClass getCharacterAttributeForValue(OBOClass valueTerm) {
OBOClass attribute = getCharacterAttributeForValueRecurse(valueTerm);
if (attribute != null) {
return attribute;
} else {
return valueTerm;
}
}

private OBOClass getCharacterAttributeForValueRecurse(OBOClass valueTerm) {
@SuppressWarnings("unchecked")
final Set<TermSubset> categories = valueTerm.getSubsets() != null ? valueTerm.getSubsets() : Collections.EMPTY_SET;
final Set<String> categoryNames = new HashSet<String>();
Expand All @@ -204,12 +213,14 @@ private OBOClass getCharacterAttributeForValue(OBOClass valueTerm) {
if (categoryNames.contains("character_slim")) {
return valueTerm;
} else {
final OBOClass parent = OBOUtil.getIsaParentForTerm(valueTerm);
if (parent != null) {
return getCharacterAttributeForValue(parent);
} else {
return valueTerm;
final Set<OBOClass> parents = OBOUtil.getIsaParentsForTerm(valueTerm);
final Set<OBOClass> attributes = new HashSet<>();
for (OBOClass parent : parents) {
final OBOClass attribute = getCharacterAttributeForValueRecurse(parent);
if (attribute != null) attributes.add(attribute);
}
if (parents.isEmpty()) return null;
else return parents.iterator().next();
}
}

Expand Down

0 comments on commit 8940fa0

Please sign in to comment.