From c56f1e2d6c069d69d561d04d037aa9bf01b06348 Mon Sep 17 00:00:00 2001 From: IgorRodchenkov Date: Mon, 9 Oct 2023 19:17:30 -0400 Subject: [PATCH] Upgraded Jena dependency; improved the enum typeOf methods (allows any capitalization and both '-' and '_' in the values). --- json-converter/pom.xml | 48 +------------------ .../io/jsonld/JsonldBiopaxConverterTest.java | 3 +- .../paxtools/pattern/miner/SIFEnum.java | 10 ++-- .../paxtools/query/algorithm/Direction.java | 18 ++++++- .../paxtools/query/algorithm/LimitType.java | 19 +++++++- 5 files changed, 44 insertions(+), 54 deletions(-) diff --git a/json-converter/pom.xml b/json-converter/pom.xml index 882767328..58a99ff3b 100644 --- a/json-converter/pom.xml +++ b/json-converter/pom.xml @@ -15,58 +15,12 @@ HEAD - - - - maven-assembly-plugin - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - - org.apache.jena apache-jena-libs + 4.9.0 pom - 3.2.0 - - - log4j - log4j - - - org.slf4j - slf4j-log4j12 - - - - - com.hp.hpl.jena - jena - - - log4j - log4j - - - org.slf4j - slf4j-log4j12 - - org.biopax.paxtools diff --git a/json-converter/src/test/java/org/biopax/paxtools/io/jsonld/JsonldBiopaxConverterTest.java b/json-converter/src/test/java/org/biopax/paxtools/io/jsonld/JsonldBiopaxConverterTest.java index c8cfcb2fc..d6496fd7d 100644 --- a/json-converter/src/test/java/org/biopax/paxtools/io/jsonld/JsonldBiopaxConverterTest.java +++ b/json-converter/src/test/java/org/biopax/paxtools/io/jsonld/JsonldBiopaxConverterTest.java @@ -19,8 +19,7 @@ public final void test() throws IOException { JsonldConverter intf = new JsonldBiopaxConverter(); // convert owl test file in resource directory to jsonld format - InputStream in = getClass().getResourceAsStream( - "/PC2v5test-Signaling-By-BMP-Pathway-REACT_12034.2.owl"); + InputStream in = getClass().getResourceAsStream("/PC2v5test-Signaling-By-BMP-Pathway-REACT_12034.2.owl"); intf.convertToJsonld(in, new FileOutputStream(jsonldTestFileName)); // convert jsonld test file back to rdf format diff --git a/pattern/src/main/java/org/biopax/paxtools/pattern/miner/SIFEnum.java b/pattern/src/main/java/org/biopax/paxtools/pattern/miner/SIFEnum.java index dc0ba74b2..9e1407e76 100644 --- a/pattern/src/main/java/org/biopax/paxtools/pattern/miner/SIFEnum.java +++ b/pattern/src/main/java/org/biopax/paxtools/pattern/miner/SIFEnum.java @@ -1,5 +1,7 @@ package org.biopax.paxtools.pattern.miner; +import org.apache.commons.lang3.StringUtils; + import java.util.Arrays; import java.util.List; @@ -107,10 +109,12 @@ public List> getMiners() public static SIFEnum typeOf(String tag) { - tag = tag.toUpperCase().replaceAll("-", "_"); + if(StringUtils.isBlank(tag)) + return null; + SIFEnum type = null; - try - { + try { + tag = tag.toUpperCase().replaceAll("-", "_"); type = valueOf(tag); } catch (IllegalArgumentException e){} diff --git a/paxtools-query/src/main/java/org/biopax/paxtools/query/algorithm/Direction.java b/paxtools-query/src/main/java/org/biopax/paxtools/query/algorithm/Direction.java index 051092263..e01269547 100644 --- a/paxtools-query/src/main/java/org/biopax/paxtools/query/algorithm/Direction.java +++ b/paxtools-query/src/main/java/org/biopax/paxtools/query/algorithm/Direction.java @@ -1,5 +1,7 @@ package org.biopax.paxtools.query.algorithm; +import org.apache.commons.lang3.StringUtils; + /** * Direction is used for specifying upstream, downstream or both. Neighborhood and CommonStream * queries use this enum as parameter. @@ -28,7 +30,7 @@ public enum Direction * Constructor with description. * @param description Description */ - private Direction(String description) + Direction(String description) { this.description = description; } @@ -41,4 +43,18 @@ public String getDescription() { return description; } + + public static Direction typeOf(String tag) + { + if(StringUtils.isBlank(tag)) + return null; + + Direction type = null; + try { + type = valueOf(tag.toUpperCase()); + } + catch (IllegalArgumentException e){} + + return type; + } } diff --git a/paxtools-query/src/main/java/org/biopax/paxtools/query/algorithm/LimitType.java b/paxtools-query/src/main/java/org/biopax/paxtools/query/algorithm/LimitType.java index 8d62bd461..cde938949 100644 --- a/paxtools-query/src/main/java/org/biopax/paxtools/query/algorithm/LimitType.java +++ b/paxtools-query/src/main/java/org/biopax/paxtools/query/algorithm/LimitType.java @@ -1,5 +1,7 @@ package org.biopax.paxtools.query.algorithm; +import org.apache.commons.lang3.StringUtils; + /** * Specifies whether the length limit is a normal limit or shortest_plus_k limit. PathsFromToQuery * use this as a parameter. @@ -9,5 +11,20 @@ public enum LimitType { NORMAL, - SHORTEST_PLUS_K + SHORTEST_PLUS_K; + + public static LimitType typeOf(String tag) + { + if(StringUtils.isBlank(tag)) + return null; + + LimitType type = null; + try { + tag = tag.toUpperCase().replaceAll("-", "_"); + type = valueOf(tag); + } + catch (IllegalArgumentException e){} + + return type; + } }