diff --git a/ondex-knet-builder/modules/neo4j-export/src/test/resources/text_mining_cytests/10_concept.cypher b/ondex-knet-builder/modules/neo4j-export/src/test/resources/text_mining_cytests/10_concept.cypher index 5013ab7d1..560cdd655 100644 --- a/ondex-knet-builder/modules/neo4j-export/src/test/resources/text_mining_cytests/10_concept.cypher +++ b/ondex-knet-builder/modules/neo4j-export/src/test/resources/text_mining_cytests/10_concept.cypher @@ -1,6 +1,5 @@ MATCH - (toterm:TO { - iri: bkr + "to_0000233", + (toterm:TO { prefName: "root volume", altName: "RTVOL", comment: "Is an indirect measure of root mass or density. Quantified in terms of cubic centimeters by water displacement method. ( Reference: GR:pj GR_REF:6917 )" @@ -8,6 +7,8 @@ MATCH (toterm) - [:identifier] -> (:Accession{ identifier: "TO:0000233" } ) - [:dataSource] -> ({ iri: bk + "TO" }) + +WHERE toterm.iri =~ bkr + "to_0000233.+" RETURN COUNT ( toterm ) = 1 diff --git a/ondex-knet-builder/modules/rdf-common/src/main/java/net/sourceforge/ondex/rdf/OndexRDFUtils.java b/ondex-knet-builder/modules/rdf-common/src/main/java/net/sourceforge/ondex/rdf/OndexRDFUtils.java index 2ff95214f..b7a20ded2 100644 --- a/ondex-knet-builder/modules/rdf-common/src/main/java/net/sourceforge/ondex/rdf/OndexRDFUtils.java +++ b/ondex-knet-builder/modules/rdf-common/src/main/java/net/sourceforge/ondex/rdf/OndexRDFUtils.java @@ -66,12 +66,14 @@ public static String iri ( String ns, String classPart, String acc, int id, bool .map ( StringUtils::trimToNull ) .map ( String::toLowerCase ) // To prevent cases like GO_GO:1234 - .filter ( a -> !a.startsWith ( classPartNew ) ) .map ( OndexRDFUtils::idEncode ) .map ( a -> forceIdAddition ? a + "_" + id : a ) .orElse ( "" + id ); - - return ns + classPartNew + "_" + idPart; + + return ns + // To prevent cases like GO_GO:1234 + + (idPart.startsWith ( classPartNew ) ? "" : classPartNew + "_" ) + + idPart; } /** @@ -84,6 +86,7 @@ public static String iri ( String ns, String classPart, String acc, int id ) /** * Don't use an ID, assuming the acc parameter is non empty. + * @throws NullPointerException when acc is null * @throws IllegalArgumentException when acc is empty. * * This is a wrapper of {@link #iri(String, String, String, int, boolean)}. diff --git a/ondex-knet-builder/modules/rdf-common/src/test/java/net/sourceforge/ondex/rdf/OndexRDFUtilsTest.java b/ondex-knet-builder/modules/rdf-common/src/test/java/net/sourceforge/ondex/rdf/OndexRDFUtilsTest.java new file mode 100644 index 000000000..1ba09363c --- /dev/null +++ b/ondex-knet-builder/modules/rdf-common/src/test/java/net/sourceforge/ondex/rdf/OndexRDFUtilsTest.java @@ -0,0 +1,78 @@ +package net.sourceforge.ondex.rdf; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +/** + * TODO: comment me! + * + * @author Marco Brandizi + *