biotoolsIDList) throws IOException {
JSONArray bioToolAnnotations = new JSONArray();
- for (int i = 0; i < toolListJson.length(); i++) {
- String currTool = toolListJson.getString(i);
- Request request = new Request.Builder().url("https://bio.tools/api/" + currTool + "?format=json").build();
- try (Response response = client.newCall(request).execute()) {
- if (!response.isSuccessful())
- throw new IOException("Unexpected code when trying to fetch" + response);
- // Get response body
- JSONObject responseJson = new JSONObject(response.body().string());
- bioToolAnnotations.put(i, responseJson);
- }
+ for (String biotoolsID : biotoolsIDList) {
+ JSONObject toolJson = fetchToolFromBioTools(biotoolsID);
+ bioToolAnnotations.put(toolJson);
}
log.debug("The list of tools successfully fetched from bio.tools.");
return bioToolAnnotations;
}
+ /**
+ * Send Get request to get tool annotations for a given tool from bio.tools API.
+ *
+ * @param biotoolsID The ID of the tool.
+ * @return The JSONObject with the tool annotations as provided by bio.tools
+ * API.
+ * @throws IOException If an error occurs while fetching the tool.
+ * @throws JSONException If the JSON returned by the bio.tools API is not well
+ * formatted.
+ */
+ public static JSONObject fetchToolFromBioTools(String biotoolsID) throws IOException, JSONException {
+
+ Request request = new Request.Builder().url("https://bio.tools/api/" + biotoolsID + "?format=json").build();
+ try (Response response = client.newCall(request).execute()) {
+ if (!response.isSuccessful()) {
+ log.error("The tool " + biotoolsID + " could not be fetched from bio.tools.");
+ }
+ // Get response body
+ return new JSONObject(response.body().string());
+ }
+ }
+
/**
* Send Get request to get tool annotations Saves JSONArray with all the tool
* annotations (in tool list)
@@ -132,6 +179,7 @@ private static JSONArray fetchToolListFromBioTools(JSONArray toolListJson) throw
*/
private static JSONArray fetchToolsFromURI(String url) throws JSONException, IOException {
JSONArray bioToolAnnotations = new JSONArray();
+ log.info("Fetching tools from bio.tools: " + url);
String next = "";
int i = 1;
while (next != null) {
@@ -152,106 +200,186 @@ private static JSONArray fetchToolsFromURI(String url) throws JSONException, IOE
next = null;
}
}
- log.trace("bio.tools: page " + i + " fetched.");
+ log.info("bio.tools: page " + i++ + " fetched.");
}
- log.debug("All tools fetched from a given URL.");
+ log.info("All tools fetched from a given URL.");
return bioToolAnnotations;
}
/**
* Method converts tools annotated using 'bio.tools' standard (see bio.tools
- * API), into standard supported by the APE library.
+ * API), into standard supported by the APE library. It is a strict
+ * conversion, where only tools that have inputs and outputs types and formats
+ * are accepted.
*
* In practice, the method takes a {@link JSONArray} as an argument, where each
* {@link JSONObject} in the array represents a tool annotated using 'bio.tools'
* standard, and returns a {@link JSONObject} that represents tool annotations
* that can be used by the APE library.
*
- * @param bioToolsAnnotation A {@link JSONArray} object, that contains list of
- * annotated tools ({@link JSONObject}s) according the
- * bio.tools specification (see bio.tools
- * API)
+ * @param bioToolsAnnotation A {@link JSONArray} object, that contains list of
+ * annotated tools ({@link JSONObject}s) according
+ * the
+ * bio.tools specification (see bio.tools
+ * API)
+ * @param excludeBadAnnotation If set to {@code true}, the method will exclude
+ * tools
+ * that do not have both the input and the output
+ * fully specified, i.e., with data and format types
+ * and formats specified. If set to {@code false},
+ * the method will return annotations that have at
+ * least one of the two fully specified (at least
+ * one input or or output).
* @return {@link JSONObject} that represents the tool annotation supported by
* the APE library.
* @throws JSONException the json exception
*/
- public static JSONObject convertBioTools2Ape(JSONArray bioToolsAnnotation) throws JSONException {
+ public static JSONObject convertBioTools2Ape(JSONArray bioToolsAnnotation, boolean excludeBadAnnotation)
+ throws JSONException {
+
+ int notAcceptedOperations = 0;
+
+ int bioToolFunctions = 0;
+
JSONArray apeToolsAnnotations = new JSONArray();
- for (int i = 0; i < bioToolsAnnotation.length(); i++) {
- JSONObject bioJsonTool = bioToolsAnnotation.getJSONObject(i);
- List functions = APEUtils.getListFromJson(bioJsonTool, "function", JSONObject.class);
+ for (JSONObject bioJsonTool : APEUtils.getJSONListFromJSONArray(bioToolsAnnotation)) {
+
+ String toolName = bioJsonTool.getString("name");
+ String biotoolsID = bioJsonTool.getString("biotoolsID");
+
+ List functions = APEUtils.getJSONListFromJson(bioJsonTool, "function");
+ if (functions.isEmpty()) {
+ continue;
+ }
int functionNo = 1;
- for (JSONObject function : functions) {
- JSONObject apeJsonTool = new JSONObject();
- apeJsonTool.put(ToolAnnotationTag.LABEL.toString(), bioJsonTool.getString("name"));
- apeJsonTool.put(ToolAnnotationTag.ID.toString(), bioJsonTool.getString("biotoolsID") + functionNo++);
- JSONArray apeTaxonomyTerms = new JSONArray();
+ for (JSONObject function : functions) {
+ String toolID = biotoolsID +
+ (functions.size() > 1 ? "_op" + (functionNo) : "");
- JSONArray operations = function.getJSONArray("operation");
- for (int j = 0; j < operations.length(); j++) {
- JSONObject bioOperation = operations.getJSONObject(j);
- apeTaxonomyTerms.put(bioOperation.get("uri"));
- }
- apeJsonTool.put(ToolAnnotationTag.TAXONOMY_OPERATIONS.toString(), apeTaxonomyTerms);
- // reading inputs
- JSONArray apeInputs = new JSONArray();
- JSONArray bioInputs = function.getJSONArray("input");
- // for each input
- for (int j = 0; j < bioInputs.length(); j++) {
- JSONObject bioInput = bioInputs.getJSONObject(j);
- JSONObject apeInput = new JSONObject();
- JSONArray apeInputTypes = new JSONArray();
- JSONArray apeInputFormats = new JSONArray();
- // add all data types
- for (JSONObject bioType : APEUtils.getListFromJson(bioInput, "data", JSONObject.class)) {
- apeInputTypes.put(bioType.getString("uri"));
- }
- apeInput.put("data_0006", apeInputTypes);
- // add all data formats (or just the first one)
- for (JSONObject bioType : APEUtils.getListFromJson(bioInput, "format", JSONObject.class)) {
- apeInputFormats.put(bioType.getString("uri"));
- }
- apeInput.put("format_1915", apeInputFormats);
-
- apeInputs.put(apeInput);
- }
- apeJsonTool.put(ToolAnnotationTag.INPUTS.toString(), apeInputs);
-
- // reading outputs
- JSONArray apeOutputs = new JSONArray();
- JSONArray bioOutputs = function.getJSONArray("output");
- // for each output
- for (int j = 0; j < bioOutputs.length(); j++) {
-
- JSONObject bioOutput = bioOutputs.getJSONObject(j);
- JSONObject apeOutput = new JSONObject();
- JSONArray apeOutputTypes = new JSONArray();
- JSONArray apeOutputFormats = new JSONArray();
- // add all data types
- for (JSONObject bioType : APEUtils.getListFromJson(bioOutput, "data", JSONObject.class)) {
- apeOutputTypes.put(bioType.getString("uri"));
- }
- apeOutput.put("data_0006", apeOutputTypes);
- // add all data formats
- for (JSONObject bioType : APEUtils.getListFromJson(bioOutput, "format", JSONObject.class)) {
- apeOutputFormats.put(bioType.getString("uri"));
- }
- apeOutput.put("format_1915", apeOutputFormats);
-
- apeOutputs.put(apeOutput);
+ Optional apeToolJson = convertSingleBioTool2Ape(toolName, toolID, biotoolsID, function,
+ excludeBadAnnotation);
+ if (apeToolJson.isPresent()) {
+ JSONObject implementation = new JSONObject().put("cwl_reference", "PATH_TO_CWL_FILE.cwl");
+ apeToolJson.get().put("implementation", implementation);
+ apeToolsAnnotations.put(apeToolJson.get());
+ bioToolFunctions++;
+ functionNo++;
+ } else {
+ notAcceptedOperations++;
}
- apeJsonTool.put(ToolAnnotationTag.OUTPUTS.toString(), apeOutputs);
-
- apeToolsAnnotations.put(apeJsonTool);
}
}
+ log.info("Provided bio.tools: " + bioToolsAnnotation.length());
+ log.info("Total bio.tools functions: " + bioToolFunctions);
+ log.info("Errored bio.tools functions: " + notAcceptedOperations);
+ log.info("Created APE annotations: " + apeToolsAnnotations.length());
return new JSONObject().put("functions", apeToolsAnnotations);
}
+ /**
+ * Convert a single function from bio.tools schema to an APE tool.
+ *
+ * @param toolName The name of the tool.
+ * @param biotoolsID The ID of the tool.
+ * @param function The function (see `function` under bio.tools
+ * schema) in JSON format.
+ * @param excludeBadAnnotation If set to {@code true}, the method will exclude
+ * tools that do not have both the input and the
+ * output fully specified, i.e., with data and
+ * format types and formats specified.
+ * @return The JSONObject with the tool annotations for a single tool according
+ * to the APE tool annotation format.
+ * @throws JSONException If the JSON is not well formatted.
+ */
+ public static Optional convertSingleBioTool2Ape(String toolName, String toolID, String biotoolsID,
+ JSONObject function, boolean excludeBadAnnotation)
+ throws JSONException {
+ JSONObject apeJsonTool = new JSONObject();
+ apeJsonTool.put("label", toolName);
+ apeJsonTool.put("id", toolID);
+ apeJsonTool.put("biotoolsID", biotoolsID);
+
+ JSONArray apeTaxonomyTerms = new JSONArray();
+
+ JSONArray operations = function.getJSONArray("operation");
+ for (JSONObject bioOperation : APEUtils.getJSONListFromJSONArray(operations)) {
+ apeTaxonomyTerms.put(bioOperation.get("uri"));
+ }
+ apeJsonTool.put("taxonomyOperations", apeTaxonomyTerms);
+ // reading inputs
+ JSONArray apeInputs = new JSONArray();
+ try {
+ apeInputs = calculateBioToolsInputOutput(function.getJSONArray("input"),
+ toolName);
+ apeJsonTool.put("inputs", apeInputs);
+ } catch (BioToolsAnnotationException e) {
+ if (excludeBadAnnotation) {
+ return Optional.empty();
+ }
+ }
+ JSONArray apeOutputs = new JSONArray();
+ try {
+ apeOutputs = calculateBioToolsInputOutput(function.getJSONArray("output"),
+ toolName);
+ apeJsonTool.put("outputs", apeOutputs);
+ } catch (BioToolsAnnotationException e) {
+ if (excludeBadAnnotation) {
+ return Optional.empty();
+ }
+ }
+ if (!excludeBadAnnotation ||
+ (apeInputs.length() > 0 && apeOutputs.length() > 0)) {
+ return Optional.of(apeJsonTool);
+ }
+ return Optional.empty();
+ }
+
+ /**
+ * Method converts input and output tool annotations, following bio.tools
+ * schema,
+ * into the APE library tool annotation format.
+ *
+ * @param bioInputs JSONArray with the bio.tools input/output annotations.
+ * @param toolID ID of the tool that is being converted.
+ *
+ * @return JSONArray with the APE library input/output annotations.
+ * @throws BioToolsAnnotationException If the input/output annotations are not
+ * well defined.
+ */
+ private static JSONArray calculateBioToolsInputOutput(JSONArray bioInputs, String toolID)
+ throws BioToolsAnnotationException {
+ JSONArray apeInputs = new JSONArray();
+ for (JSONObject bioInput : APEUtils.getJSONListFromJSONArray(bioInputs)) {
+ JSONObject apeInput = new JSONObject();
+ JSONArray apeInputTypes = new JSONArray();
+ JSONArray apeInputFormats = new JSONArray();
+ // add all data types
+ for (JSONObject bioType : APEUtils.getJSONListFromJson(bioInput, "data")) {
+ apeInputTypes.put(bioType.getString("uri"));
+ }
+ if (apeInputTypes.length() == 0) {
+ throw BioToolsAnnotationException.notExistingType(toolID);
+ }
+ apeInput.put("data_0006", apeInputTypes);
+ // add all data formats (or just the first one)
+ for (JSONObject bioType : APEUtils.getJSONListFromJson(bioInput, "format")) {
+ apeInputFormats.put(bioType.getString("uri"));
+ }
+ if (apeInputFormats.length() == 0) {
+ throw BioToolsAnnotationException.notExistingFormat(toolID);
+ }
+ apeInput.put("format_1915", apeInputFormats);
+
+ apeInputs.put(apeInput);
+
+ }
+ return apeInputs;
+ }
+
}
\ No newline at end of file
diff --git a/src/main/java/nl/uu/cs/ape/domain/BioToolsAnnotationException.java b/src/main/java/nl/uu/cs/ape/domain/BioToolsAnnotationException.java
new file mode 100644
index 00000000..d11a0a14
--- /dev/null
+++ b/src/main/java/nl/uu/cs/ape/domain/BioToolsAnnotationException.java
@@ -0,0 +1,42 @@
+/**
+ *
+ */
+package nl.uu.cs.ape.domain;
+
+/**
+ * The {@code BioToolsAnnotationException} exception will be thrown if the
+ * a tool in bio.tools is not annotated properly.
+ *
+ * @author Vedran Kasalica
+ *
+ */
+public class BioToolsAnnotationException extends RuntimeException {
+
+ /**
+ * Instantiates a new Ape exception.
+ *
+ * @param message The message that will be passed to the {@link Exception} super
+ * class.
+ */
+ private BioToolsAnnotationException(String message) {
+ super(message);
+ }
+
+ /**
+ * Exception is thrown when a tool that does not have a data type of data specified in the bio.tools annotations.
+ * @param toolID ID of the tool that does not have the data type specified.
+ * @return BioToolsAnnotationException with information that may help the user solve the problem.
+ */
+ public static BioToolsAnnotationException notExistingType(String toolID) {
+ return new BioToolsAnnotationException(String.format("The tool with ID %s does not have data type specified (for input or output).", toolID));
+ }
+
+ /**
+ * Exception is thrown when a tool that does not have a data format of data specified in the bio.tools annotations.
+ * @param toolID ID of the tool that does not have the format specified.
+ * @return BioToolsAnnotationException with information that may help the user solve the problem.
+ */
+ public static BioToolsAnnotationException notExistingFormat(String toolID) {
+ return new BioToolsAnnotationException(String.format("The tool with ID %s does not have data format specified (for input or output).", toolID));
+ }
+}
diff --git a/src/main/java/nl/uu/cs/ape/models/AllPredicates.java b/src/main/java/nl/uu/cs/ape/models/AllPredicates.java
index 0a00e6c6..324789ca 100644
--- a/src/main/java/nl/uu/cs/ape/models/AllPredicates.java
+++ b/src/main/java/nl/uu/cs/ape/models/AllPredicates.java
@@ -83,7 +83,9 @@ public boolean trimTaxonomy() {
List toRemove = new ArrayList<>();
for (TaxonomyPredicate subClass : APEUtils.safe(root.getSubPredicates())) {
if (subClass == null) {
- } else if (subClass.getIsRelevant()) {
+ continue;
+ }
+ if (subClass.getIsRelevant()) {
trimSubTaxonomy(subClass);
} else {
toRemove.add(subClass);
@@ -169,7 +171,7 @@ public SortedSet getElementsFromSubTaxonomy(TaxonomyPredicate
/**
* Check whether the string occurs as one of the roots in the taxonomy.
*
- * @param curRootIRI - curr root IRI
+ * @param curRootIRI curr root IRI
* @return true if the root exists
*/
public boolean existsRoot(String curRootIRI) {
@@ -179,8 +181,8 @@ public boolean existsRoot(String curRootIRI) {
/**
* Put a new TaxonomyPredicate to the mapping.
*
- * @param key - ID of the TaxonomyPredicate
- * @param value - TaxonomyPredicate to be added
+ * @param key ID of the TaxonomyPredicate
+ * @param value TaxonomyPredicate to be added
*/
public void put(String key, TaxonomyPredicate value) {
mappedPredicates.put(key, value);
@@ -190,7 +192,7 @@ public void put(String key, TaxonomyPredicate value) {
/**
* Remove the TaxonomyPredicate from the mapping.
*
- * @param predicateID - ID of the TaxonomyPredicate to be removed
+ * @param predicateID ID of the TaxonomyPredicate to be removed
*/
public void remove(String predicateID) {
mappedPredicates.remove(predicateID);
diff --git a/src/main/java/nl/uu/cs/ape/models/AllTypes.java b/src/main/java/nl/uu/cs/ape/models/AllTypes.java
index e95d2124..3c055096 100644
--- a/src/main/java/nl/uu/cs/ape/models/AllTypes.java
+++ b/src/main/java/nl/uu/cs/ape/models/AllTypes.java
@@ -81,7 +81,7 @@ public AllTypes(List typeTaxonomyRoots) {
/**
* Helper method that sets the type to be relevant in the current domain
*
- * @param type - Type that should be relevant
+ * @param type Type that should be relevant
*/
private void setRelevant(Type type) {
type.setAsRelevantTaxonomyTerm(this);
@@ -234,17 +234,17 @@ public Class> getPredicateClass() {
* @return List of pairs of types.
*/
public List> getTypePairsForEachSubTaxonomy() {
- List> pairs = new ArrayList>();
+ List> pairs = new ArrayList<>();
/*
* Create a list for each subtree of the Data Taxonomy (e.g. TypeSubTaxonomy,
* FormatSubTaxonomy). Each of these lists represents a class of mutually
* exclusive types.
*/
- Map> subTreesMap = new HashMap>();
+ Map> subTreesMap = new HashMap<>();
// Add each of the dimension roots (type and format taxonomy) to the list
for (String subRoot : APEUtils.safe(getAllRootIDs())) {
- subTreesMap.put(subRoot, new ArrayList());
+ subTreesMap.put(subRoot, new ArrayList<>());
}
/*
@@ -272,7 +272,7 @@ public List> getTypePairsForEachSubTaxonomy() {
for (List iterator : subTreesMap.values()) {
for (int i = 0; i < iterator.size() - 1; i++) {
for (int j = i + 1; j < iterator.size(); j++) {
- pairs.add(new Pair(iterator.get(i), iterator.get(j)));
+ pairs.add(new Pair<>(iterator.get(i), iterator.get(j)));
}
}
}
diff --git a/src/main/java/nl/uu/cs/ape/models/AuxModulePredicate.java b/src/main/java/nl/uu/cs/ape/models/AuxModulePredicate.java
index 29d404a0..e4f5e075 100644
--- a/src/main/java/nl/uu/cs/ape/models/AuxModulePredicate.java
+++ b/src/main/java/nl/uu/cs/ape/models/AuxModulePredicate.java
@@ -37,19 +37,19 @@ public class AuxModulePredicate extends AbstractModule implements AuxiliaryPredi
* {@link AuxModulePredicate#generateAuxiliaryPredicate} to generate an
* auxiliary object.
*
- * @param moduleName - name of the auxiliary module predicate
- * @param moduleID - ID of the auxiliary module predicate
- * @param rootNode - module root node
- * @param containingPredicates - collection of module predicates that comprise
+ * @param moduleName name of the auxiliary module predicate
+ * @param moduleID ID of the auxiliary module predicate
+ * @param rootNode module root node
+ * @param containingPredicates collection of module predicates that comprise
* the auxiliary predicate
- * @param logicOp - logical operation that binds the comprised
+ * @param logicOp logical operation that binds the comprised
* predicates
*/
private AuxModulePredicate(String moduleName, String moduleID, String rootNode,
Collection containingPredicates, LogicOperation logicOp) {
super(moduleName, moduleID, rootNode, NodeType.ABSTRACT);
this.logicOp = logicOp;
- this.containingPredicates = new TreeSet();
+ this.containingPredicates = new TreeSet<>();
this.containingPredicates.addAll(containingPredicates);
}
@@ -68,7 +68,7 @@ private AuxModulePredicate(String moduleName, String moduleID, String rootNode,
* always the same due to its ordering).
* @param logicOp Logical operation that describes the relation
* between the types.
- * @param domainSetup - domain model
+ * @param domainSetup domain model
*
* @return An abstract predicate that provides abstraction over a
* disjunction/conjunction of the labels.
diff --git a/src/main/java/nl/uu/cs/ape/models/MappingsException.java b/src/main/java/nl/uu/cs/ape/models/MappingsException.java
index 79687cfd..a48a39fa 100644
--- a/src/main/java/nl/uu/cs/ape/models/MappingsException.java
+++ b/src/main/java/nl/uu/cs/ape/models/MappingsException.java
@@ -26,7 +26,7 @@ public MappingsException(String message) {
* Exception is thrown when two or more atoms share the same signature (ID +
* state)
*
- * @param message - Application specific message that may help the user solve
+ * @param message Application specific message that may help the user solve
* the problem.
* @return Dimensions exception with information that may help the user solve
* the problem.
@@ -39,7 +39,7 @@ public static MappingsException mappedAtomsSignaturesOverlap(String message) {
/**
* Exception is thrown when two or more predicates share the same signature.
*
- * @param message - Application specific message that may help the user solve
+ * @param message Application specific message that may help the user solve
* the problem.
* @return Dimensions exception with information that may help the user solve
* the problem.
diff --git a/src/main/java/nl/uu/cs/ape/models/Module.java b/src/main/java/nl/uu/cs/ape/models/Module.java
index 38916892..d5eb55b4 100644
--- a/src/main/java/nl/uu/cs/ape/models/Module.java
+++ b/src/main/java/nl/uu/cs/ape/models/Module.java
@@ -166,8 +166,8 @@ public void addModuleOutput(Type moduleOutput) {
/**
* Generate a taxonomy tool instance that is referenced in the json.
*
- * @param jsonParam
- * @param domainSetup
+ * @param jsonParam JSON object that contains the abstract module information.
+ * @param domainSetup APE domain information.
* @return A AbstractModule object that represent the data instance given as the
* parameter.
* @throws JSONException if the given JSON is not well formatted
@@ -176,7 +176,7 @@ public void addModuleOutput(Type moduleOutput) {
public static AbstractModule taxonomyInstanceFromJson(JSONObject jsonParam, APEDomainSetup domainSetup)
throws JSONException {
/* Set of predicates where each describes a type dimension */
- SortedSet parameterDimensions = new TreeSet();
+ SortedSet parameterDimensions = new TreeSet<>();
AllModules allModules = domainSetup.getAllModules();
/* Iterate through each of the dimensions */
for (String currRootLabel : jsonParam.keySet()) {
diff --git a/src/main/java/nl/uu/cs/ape/models/Type.java b/src/main/java/nl/uu/cs/ape/models/Type.java
index b9473bd5..5705418d 100644
--- a/src/main/java/nl/uu/cs/ape/models/Type.java
+++ b/src/main/java/nl/uu/cs/ape/models/Type.java
@@ -65,9 +65,9 @@ public String getType() {
}
/**
- * Set plain type type.
+ * Set plain type.
*
- * @param plainType - plain type that should be used
+ * @param plainType The plain type value.
*/
public void setPlainType(Type plainType) {
this.plainType = plainType;
@@ -88,9 +88,9 @@ public Type getPlainType() {
* Generate a taxonomy data instance that is defined based on one or more
* dimensions that describe it.
*
- * @param jsonParam - JSON representation of the data instance
- * @param domainSetup - setup of the domain
- * @param isOutputData - {@code true} if the data is used to be module output,
+ * @param jsonParam JSON representation of the data instance
+ * @param domainSetup setup of the domain
+ * @param isOutputData {@code true} if the data is used to be module output,
* {@code false} otherwise
* @return A type object that represent the data instance given as the
* parameter.
@@ -120,14 +120,17 @@ public static Type taxonomyInstanceFromJson(JSONObject jsonParam, APEDomainSetup
/* for each dimensions a disjoint array of types/tools is given */
for (String currTypeLabel : APEUtils.getListFromJson(jsonParam, currRootLabel, String.class)) {
String currTypeIRI = currTypeLabel;
- if (allTypes.get(currTypeIRI, curRootIRI) == null) {
+
+ Type currType = allTypes.get(currTypeIRI, curRootIRI);
+ if (currType == null) {
currTypeIRI = APEUtils.createClassIRI(currTypeLabel, domainSetup.getOntologyPrefixIRI());
+ currType = allTypes.get(currTypeIRI, curRootIRI);
}
if (currRootLabel.equals(allTypes.getLabelRootID())) {
labelDefined = true;
}
- Type currType = allTypes.get(currTypeIRI, curRootIRI);
+
if (currType != null) {
if (isOutputData) {
currType.setAsRelevantTaxonomyTerm(allTypes);
diff --git a/src/main/java/nl/uu/cs/ape/models/enums/AtomType.java b/src/main/java/nl/uu/cs/ape/models/enums/AtomType.java
index ead9e704..4e2229b5 100644
--- a/src/main/java/nl/uu/cs/ape/models/enums/AtomType.java
+++ b/src/main/java/nl/uu/cs/ape/models/enums/AtomType.java
@@ -84,9 +84,9 @@ public static String getStringShortcut(AtomType elem, Integer blockNumber, int s
if (elem == MODULE) {
return "Tool" + stateNumber;
} else if (elem == MEMORY_TYPE) {
- return "MemT" + blockNumber + "." + stateNumber;
+ return "Out" + blockNumber + "." + stateNumber;
} else if (elem == USED_TYPE) {
- return "UsedT" + blockNumber + "." + stateNumber;
+ return "In" + blockNumber + "." + stateNumber;
} else if (elem == null) {
return "nullMem";
}
diff --git a/src/main/java/nl/uu/cs/ape/models/logic/constructs/TaxonomyPredicate.java b/src/main/java/nl/uu/cs/ape/models/logic/constructs/TaxonomyPredicate.java
index a85a6335..129f918c 100644
--- a/src/main/java/nl/uu/cs/ape/models/logic/constructs/TaxonomyPredicate.java
+++ b/src/main/java/nl/uu/cs/ape/models/logic/constructs/TaxonomyPredicate.java
@@ -308,7 +308,7 @@ public String toShortString() {
* @param allPredicates Set of all the predicates.
*/
public void printTree(String str, AllPredicates allPredicates) {
- log.debug(str + toShortString() + "[" + getNodeType() + "]");
+ log.info(str + toShortString() + "[" + getNodeType() + "]");
for (TaxonomyPredicate predicate : APEUtils.safe(this.subPredicates)) {
predicate.printTree(str + ". ", allPredicates);
}
@@ -397,7 +397,7 @@ public Set getParentPredicates() {
* Returns true if the type is a simple/leaf type, otherwise returns false - the
* type is an abstract (non-leaf) type.
*
- * @param nodeType - node type
+ * @param nodeType NodeType that is checked against the current node.
*
* @return true (simple/primitive/leaf type) or false (abstract/non-leaf type).
*/
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/CNFClause.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/CNFClause.java
index a76aaecc..76c14b93 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/CNFClause.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/CNFClause.java
@@ -32,7 +32,7 @@ public CNFClause(List atoms) {
/**
* Create a clause that has only one element.
*
- * @param atom - integer that corresponds to the mapping of the atom
+ * @param atom integer that corresponds to the mapping of the atom
*/
public CNFClause(Integer atom) {
super();
@@ -45,7 +45,7 @@ public CNFClause(Integer atom) {
* collections of {@link CNFClause}s and combine them under the AND logic
* operator.
*
- * @param facts - collections of 'collections of clauses' that are conjunct
+ * @param facts collections of 'collections of clauses' that are conjunct
* @return Set of {@link CNFClause}s that represent conjunction of the given
* collections of clauses.
*/
@@ -61,7 +61,7 @@ public static Set conjunctClausesCollection(Set> facts) {
* collections of {@link CNFClause}s and combine them under the OR logic
* operator.
*
- * @param facts - collections of 'collections of clauses' that are disjoint.
+ * @param facts collections of 'collections of clauses' that are disjoint.
* @return Set of {@link CNFClause}s that represent disjunction of the given
* collections of clauses.
*/
@@ -96,8 +96,8 @@ public static Set disjoinClausesCollection(Set> facts) {
* Return a new clause that combines the two clauses. The method combines the 2
* strings, each comprising disjoint Atoms.
*
- * @param clause1 - 1st clause that should be combined
- * @param clause2 - 2nd clause that should be combined
+ * @param clause1 1st clause that should be combined
+ * @param clause2 2nd clause that should be combined
* @return String that represents the disjunction of the two clauses.
*/
public static String disjoin2Clauses(String clause1, String clause2) {
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtomVar.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtomVar.java
index 03531485..f36a03e5 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtomVar.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtomVar.java
@@ -45,9 +45,9 @@ public class SLTLxAtomVar extends SLTLxFormula {
* or a reference between an input type and the state in which it was
* generated..
*
- * @param elementType - Element that defines what the atom depicts.
- * @param firstArg - Predicate used or a variable that is the referenced.
- * @param secondArg - Variable representing state in the automaton it was
+ * @param elementType Element that defines what the atom depicts.
+ * @param firstArg Predicate used or a variable that is the referenced.
+ * @param secondArg Variable representing state in the automaton it was
* used/created in.
*/
public SLTLxAtomVar(AtomVarType elementType, PredicateLabel firstArg, SLTLxVariable secondArg) {
@@ -200,23 +200,23 @@ public Set getNegatedCNFEncoding(int stateNo, SLTLxVariableSubstitutionC
private void substituteVariables(SLTLxVariableSubstitutionCollection variableMapping,
SATSynthesisEngine synthesisEngine) {
if (this.elementType.isVarDataType()) {
- this.secondArg = variableMapping.getVarSabstitute(this.secondArg);
+ this.secondArg = variableMapping.getVarSubstitute(this.secondArg);
synthesisEngine.getVariableUsage().addDataType(firstArg, secondArg);
} else if (this.elementType.isVarMemReference()) {
- this.secondArg = variableMapping.getVarSabstitute(this.secondArg);
+ this.secondArg = variableMapping.getVarSubstitute(this.secondArg);
synthesisEngine.getVariableUsage().addMemoryReference((State) firstArg, secondArg);
}
else if (this.elementType.isBinaryRel() && !(this.elementType.equals(AtomVarType.VAR_VALUE))) {
- this.firstArg = variableMapping.getVarSabstitute((SLTLxVariable) this.firstArg);
- this.secondArg = variableMapping.getVarSabstitute(this.secondArg);
+ this.firstArg = variableMapping.getVarSubstitute((SLTLxVariable) this.firstArg);
+ this.secondArg = variableMapping.getVarSubstitute(this.secondArg);
synthesisEngine.getVariableUsage().addBinaryPred(
new Pair<>((SLTLxVariable) this.firstArg, this.secondArg), this.elementType);
}
else if (this.elementType.equals(AtomVarType.VAR_VALUE)) {
- this.secondArg = variableMapping.getVarSabstitute(this.secondArg);
+ this.secondArg = variableMapping.getVarSubstitute(this.secondArg);
/* These predicates are not added to the set. */
}
}
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxElem.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxElem.java
index b219dd9f..f4bd4a95 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxElem.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxElem.java
@@ -16,7 +16,7 @@ public interface SLTLxElem {
* Create the CNF encoding of the statement and return the string
* representation.
*
- * @param synthesisEngine - synthesis engine used to encode the problem.
+ * @param synthesisEngine synthesis engine used to encode the problem.
* @return The string that represent cnf clauses.
*/
public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection variableMapping,
@@ -26,7 +26,7 @@ public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollecti
* CreatE the CNF encoding of the negation of the statement and return the
* string representation.
*
- * @param synthesisEngine - synthesis engine used to encode the problem.
+ * @param synthesisEngine synthesis engine used to encode the problem.
* @return The string that represent the negated cnf clauses.
*/
public Set getNegatedCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection variableMapping,
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxFormula.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxFormula.java
index 27532a9e..3c9b5d55 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxFormula.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxFormula.java
@@ -24,16 +24,16 @@ protected SLTLxFormula() {
* Encode a collection of SLTLx formulas to CNF and append it to the existing
* CNF file. It adds the encoding at the end of the content of the file.
*
- * @param file - existing cnf file
+ * @param file existing cnf file
* @param synthesisEngine synthesis engine used for encoding
- * @param formulas - collection of formulas that should be encoded
+ * @param formulas collection of formulas that should be encoded
* @throws IOException Thrown in case of an I/O error.
*/
public static void appendCNFToFile(File file, SATSynthesisEngine synthesisEngine, Collection formulas)
throws IOException {
StringBuilder cnf = new StringBuilder();
createCNFEncoding(formulas, 0, synthesisEngine)
- .forEach(clause -> cnf.append(clause));
+ .forEach(cnf::append);
APEFiles.appendToFile(file, cnf.toString());
}
@@ -41,8 +41,8 @@ public static void appendCNFToFile(File file, SATSynthesisEngine synthesisEngine
* Create the CNF encoding of the facts and return the set of corresponding
* clauses in String format.
*
- * @param facts - all facts that should be encoded
- * @param synthesisEngine - synthesis engine used for encoding
+ * @param facts all facts that should be encoded
+ * @param synthesisEngine synthesis engine used for encoding
* @return Set of clauses in String format that encode the given collector of
* formulas.
*/
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxOperation.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxOperation.java
index 5c95d93a..0ff41a5d 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxOperation.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxOperation.java
@@ -53,8 +53,8 @@ public Set getNegatedCNFEncoding(int stateNo, SLTLxVariableSubstitutionC
* Create the SLTLx object that enforces usage of the operation and the
* corresponding inputs/outputs.
*
- * @param stateNo - current state number
- * @param synthesisEngine - synthesis engine
+ * @param stateNo current state number
+ * @param synthesisEngine synthesis engine
* @return Fact representing the existence of the operation.
*/
private SLTLxFormula enforceOperation(int stateNo, SATSynthesisEngine synthesisEngine) {
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxParsingAnnotationException.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxParsingAnnotationException.java
index 527debd8..fff7f498 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxParsingAnnotationException.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxParsingAnnotationException.java
@@ -24,7 +24,7 @@ private SLTLxParsingAnnotationException(String message) {
* Exception is thrown when the specified SLTLx formula contains a type not
* specified in the type taxonomy.
*
- * @param message - Application specific message that may help the user solve
+ * @param message Application specific message that may help the user solve
* the problem.
* @return SLTLx Parsing exception with information that may help the user solve
* the problem.
@@ -39,7 +39,7 @@ public static SLTLxParsingAnnotationException typeDoesNoExists(String message) {
* Exception is thrown when the specified SLTLx formula contains a module not
* specified in the type taxonomy.
*
- * @param message - Application specific message that may help the user solve
+ * @param message Application specific message that may help the user solve
* the problem.
* @return SLTLx Parsing exception with information that may help the user solve
* the problem.
@@ -54,7 +54,7 @@ public static SLTLxParsingAnnotationException moduleDoesNoExists(String message)
* Exception is thrown when the specified SLTLx formula contains a free
* variable.
*
- * @param message - Application specific message that may help the user solve
+ * @param message Application specific message that may help the user solve
* the problem.
* @return SLTLx Parsing exception with information that may help the user solve
* the problem.
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVarQuantification.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVarQuantification.java
index aee5382f..f20ee6b8 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVarQuantification.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVarQuantification.java
@@ -25,8 +25,8 @@ protected SLTLxVarQuantification(SLTLxVariable boundVariable, SLTLxFormula formu
@Override
public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection newVarMapping,
SATSynthesisEngine synthesisEngine) {
- Set clauses = new HashSet();
- SLTLxVariable flatBoundVariable = newVarMapping.getVarSabstitute(boundVariable);
+ Set clauses = new HashSet<>();
+ SLTLxVariable flatBoundVariable = newVarMapping.getVarSubstitute(boundVariable);
/** Encode the underlying formula. */
clauses.addAll(formula.getCNFEncoding(stateNo, newVarMapping, synthesisEngine));
/**
@@ -37,7 +37,7 @@ public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollecti
*/
clauses.addAll(flatBoundVariable.getVariableSubstitutionToPreserveProperties(stateNo, newVarMapping,
synthesisEngine));
- clauses.addAll(flatBoundVariable.getVariableMutualExclusion(stateNo, newVarMapping, synthesisEngine));
+ clauses.addAll(flatBoundVariable.getVariableUniqueSubstitution(stateNo, newVarMapping, synthesisEngine));
return clauses;
}
@@ -45,7 +45,7 @@ public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollecti
public Set getNegatedCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection newVarMapping,
SATSynthesisEngine synthesisEngine) {
Set clauses = new HashSet<>();
- SLTLxVariable flatBoundVariable = newVarMapping.getVarSabstitute(boundVariable);
+ SLTLxVariable flatBoundVariable = newVarMapping.getVarSubstitute(boundVariable);
/** Encode the underlying formula. */
clauses.addAll(formula.getNegatedCNFEncoding(stateNo, newVarMapping, synthesisEngine));
/**
@@ -56,7 +56,7 @@ public Set getNegatedCNFEncoding(int stateNo, SLTLxVariableSubstitutionC
*/
clauses.addAll(flatBoundVariable.getVariableSubstitutionToPreserveProperties(stateNo, newVarMapping,
synthesisEngine));
- clauses.addAll(flatBoundVariable.getVariableMutualExclusion(stateNo, newVarMapping, synthesisEngine));
+ clauses.addAll(flatBoundVariable.getVariableUniqueSubstitution(stateNo, newVarMapping, synthesisEngine));
return clauses;
}
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariable.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariable.java
index e1a78e1e..acb2fd95 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariable.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariable.java
@@ -31,7 +31,7 @@ public class SLTLxVariable implements StateInterface, PredicateLabel {
/**
* Create new type state variable.
*
- * @param variableName - Unique variable name
+ * @param variableName Unique variable name
*/
public SLTLxVariable(String variableName) {
super();
@@ -94,8 +94,8 @@ public String getPredicateLongLabel() {
* existential
* quantification for the given set of memory states.
*
- * @param stateNo - current state in the SLTLx model
- * @param synthesisEngine - synthesis engine
+ * @param stateNo current state in the SLTLx model
+ * @param synthesisEngine synthesis engine
* @return Set of clauses that encode the possible variable substitution.
*/
public Set getExistentialCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection variableSubstitutions,
@@ -126,8 +126,8 @@ public Set getExistentialCNFEncoding(int stateNo, SLTLxVariableSubstitut
* in order to ensure that all occurrences of the variable were taken into
* account.
*
- * @param stateNo - current state in the SLTLx model
- * @param synthesisEngine - synthesis engine
+ * @param stateNo current state in the SLTLx model
+ * @param synthesisEngine synthesis engine
* @return Set of clauses that encode the possible variable substitution.
*/
public Set getUniversalCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection variableSubstitutions,
@@ -158,8 +158,8 @@ public Set getUniversalCNFEncoding(int stateNo, SLTLxVariableSubstitutio
* in order to ensure that all the occurrences of the variable were taken into
* account.
*
- * @param stateNo - current state in the SLTLx model
- * @param synthesisEngine - synthesis engine
+ * @param stateNo current state in the SLTLx model
+ * @param synthesisEngine synthesis engine
* @return Set of clauses that encode the possible variable substitution.
*/
public Set getVariableSubstitutionToPreserveProperties(int stateNo,
@@ -191,9 +191,9 @@ public Set getVariableSubstitutionToPreserveProperties(int stateNo,
* Generate the rules that enforce substitution over the data properties.
* e.g., (VAL(?x,a) => (P(?x) <=> P(a))
*
- * @param variable - the variable that will be substituted
- * @param variableSubstitutions - collection of substitutions for each variable
- * @param varOccurrences - collection that tracks occurrences of
+ * @param variable the variable that will be substituted
+ * @param variableSubstitutions collection of substitutions for each variable
+ * @param varOccurrences collection that tracks occurrences of
* variables
* @return Set of formulas that represent the encoding of the rules
*/
@@ -251,9 +251,9 @@ private static Set generateDataPropertySubstitutionRules(SLTLxVari
* Generate the rules that enforce substitution over binary predicates.
* e.g., VAL(?x,a) & VAL(?y,b) => (R_v(x,y) <=> R(a,b))
*
- * @param pair - a pair of variables that will be substituted
- * @param variableSubstitutions - collection of substitutions for each variable
- * @param varOccurrences - collection that tracks occurrences of
+ * @param pair a pair of variables that will be substituted
+ * @param variableSubstitutions collection of substitutions for each variable
+ * @param varOccurrences collection that tracks occurrences of
* variables
* @return Set of formulas that represent the encoding of the rules
*/
@@ -311,7 +311,7 @@ private static Set generateBinarySubstitutionRules(Pair getVariableDomain(int stateNo, SATSynthesisEngine synth
return variableDomain;
}
- public Set getVariableMutualExclusion(int stateNo, SLTLxVariableSubstitutionCollection variableMapping,
+ /**
+ * Get the set of clauses that enforce that the a variable cannot reference two different data instances.
+ * @param stateNo current state in the SLTLx model
+ * @param variableMapping collection of substitutions for each variable
+ * @param synthesisEngine synthesis engine
+ * @return Set of clauses that encode the possible variable substitution.
+ */
+ public Set getVariableUniqueSubstitution(int stateNo, SLTLxVariableSubstitutionCollection variableMapping,
SATSynthesisEngine synthesisEngine) {
Set allClauses = new HashSet<>();
/**
@@ -357,10 +364,10 @@ public Set getVariableMutualExclusion(int stateNo, SLTLxVariableSubstitu
* and thus we use the next state to get the domain of the variable.
*/
int nextStateNo = stateNo + 1;
- Set> statePairs = APEUtils
+ Set> statePairs = APEUtils
.getUniquePairs(synthesisEngine.getTypeAutomaton().getAllMemoryStatesUntilBlockNo(nextStateNo));
- statePairs.forEach(statePair -> {
+ statePairs.forEach(statePair ->
allClauses.addAll(
new SLTLxNegatedConjunction(
new SLTLxAtomVar(
@@ -371,8 +378,8 @@ public Set getVariableMutualExclusion(int stateNo, SLTLxVariableSubstitu
AtomVarType.VAR_VALUE,
statePair.getSecond(),
this))
- .getCNFEncoding(stateNo, variableMapping, synthesisEngine));
- });
+ .getCNFEncoding(stateNo, variableMapping, synthesisEngine))
+ );
return allClauses;
}
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableOccurrenceCollection.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableOccurrenceCollection.java
index d2fe26e4..a99d406b 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableOccurrenceCollection.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableOccurrenceCollection.java
@@ -45,8 +45,8 @@ public SLTLxVariableOccurrenceCollection() {
/**
* Associate the data type to the corresponding variable.
*
- * @param dataType - state property
- * @param variableState - variable used
+ * @param dataType state property
+ * @param variableState variable used
* @return {@code true} if the property was associated with the variable,
* {@code false} otherwise.
*/
@@ -65,8 +65,8 @@ public boolean addDataType(PredicateLabel dataType, SLTLxVariable variableState)
/**
* Associate the tool input state to the corresponding variable.
*
- * @param usedState - state that represents data input
- * @param variableState - variable used
+ * @param usedState state that represents data input
+ * @param variableState variable used
* @return {@code true} if the state was associated with the variable,
* {@code false} otherwise.
*/
@@ -86,8 +86,8 @@ public boolean addMemoryReference(State usedState, SLTLxVariable variableState)
* Associate the pair of variables (the order of the variables matter) with the
* type of atom they are used in.
*
- * @param varPair - pair of the variables used
- * @param relType - Atom type that has the pair of variables as arguments
+ * @param varPair pair of the variables used
+ * @param relType Atom type that has the pair of variables as arguments
*/
public void addBinaryPred(Pair varPair, AtomVarType relType) {
if (relType.equals(AtomVarType.VAR_VALUE)) {
@@ -109,7 +109,7 @@ public void addBinaryPred(Pair varPair, AtomVarType relType) {
if (this.variablePairs.get(varPair.getSecond()) == null) {
// create the second element mapping as it did not occur earlier (and add the
// first element)
- Set> vars = new HashSet>();
+ Set> vars = new HashSet<>();
vars.add(varPair);
this.variablePairs.put(varPair.getSecond(), vars);
} else {
@@ -132,7 +132,7 @@ public void addBinaryPred(Pair varPair, AtomVarType relType) {
/**
* Get all data types that include the given variable.
*
- * @param satVariable - the given variable
+ * @param satVariable the given variable
* @return Set (possibly empty) of memory references that are mentioned in
* combination with the given variable.
*/
@@ -144,7 +144,7 @@ public Set getDataTypes(SLTLxVariable satVariable) {
/**
* Get all memory references that include the given variable.
*
- * @param satVariable - the given variable
+ * @param satVariable the given variable
* @return Set (possibly empty) of memory references that are mentioned in
* combination with the given variable.
*/
@@ -157,7 +157,7 @@ public Set getMemoryReferences(SLTLxVariable satVariable) {
* Get all binary relations that include the given variable pair as arguments
* (in the given order).
*
- * @param varPair - the given variable pair
+ * @param varPair the given variable pair
* @return Set (possibly empty) of binary predicates that were used over the
* variable pair.
*/
@@ -170,7 +170,7 @@ public Set getBinaryPredicates(Pair varPair) {
* Return the set of pairs that are used in the formulas, where the given
* variable is one of the two in pair.
*
- * @param variable - variable that is in the pairs
+ * @param variable variable that is in the pairs
* @return Set of Pair objects that are used in the formulas that contain the
* given variable.
*/
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableSubstitutionCollection.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableSubstitutionCollection.java
index 581e09ff..b20efc7f 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableSubstitutionCollection.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableSubstitutionCollection.java
@@ -34,7 +34,7 @@ public SLTLxVariableSubstitutionCollection() {
/**
* Create a new variable mapping, based on the existing one.
*
- * @param existing - existing variable mapping.
+ * @param existing existing variable mapping.
*/
public SLTLxVariableSubstitutionCollection(SLTLxVariableSubstitutionCollection existing) {
super();
@@ -55,7 +55,7 @@ public SLTLxVariableSubstitutionCollection(SLTLxVariableSubstitutionCollection e
* In case that the substitution for a variable with the same name exists, it
* will be overwritten.
*
- * @param existingVar - variable used in the formula
+ * @param existingVar variable used in the formula
* @return Unique variable that corresponds to the current variable binding.
*/
public SLTLxVariable addNewVariable(SLTLxVariable existingVar, Set varDomain) {
@@ -70,12 +70,12 @@ public SLTLxVariable addNewVariable(SLTLxVariable existingVar, Set varDom
* Get the unique variable used to substitute the current binding of the
* variable.
*
- * @param existingVar - variable used in the formula
+ * @param existingVar variable used in the formula
* @return Unique variable that corresponds to the current variable binding.
- * @throws SLTLxParsingAnnotationException - in case that the variable does not
+ * @throws SLTLxParsingAnnotationException in case that the variable does not
* exist.
*/
- public SLTLxVariable getVarSabstitute(SLTLxVariable existingVar) throws SLTLxParsingAnnotationException {
+ public SLTLxVariable getVarSubstitute(SLTLxVariable existingVar) throws SLTLxParsingAnnotationException {
SLTLxVariable variable = mappedVariables.get(existingVar);
if (variable == null) {
throw SLTLxParsingAnnotationException
@@ -87,7 +87,7 @@ public SLTLxVariable getVarSabstitute(SLTLxVariable existingVar) throws SLTLxPar
/**
* Get the domain for the given variable.
*
- * @param variable - variable in question
+ * @param variable variable in question
* @return Set of states that represent the domain of the variable.
*/
public Set getVariableDomain(SLTLxVariable variable) {
diff --git a/src/main/java/nl/uu/cs/ape/models/templateFormulas/SLTLxTemplateFormula.java b/src/main/java/nl/uu/cs/ape/models/templateFormulas/SLTLxTemplateFormula.java
index 108be1e7..50843898 100644
--- a/src/main/java/nl/uu/cs/ape/models/templateFormulas/SLTLxTemplateFormula.java
+++ b/src/main/java/nl/uu/cs/ape/models/templateFormulas/SLTLxTemplateFormula.java
@@ -509,11 +509,11 @@ public static String useModuleOutput(TaxonomyPredicate module, TaxonomyPredicate
* Creates a CNF representation of the Constraint:
* 1st operation should generate an output used by the 2nd operation.
*
- * @param firstPredicate - Module type that generates the data as output
- * @param secondPredicate - Module type that uses the generated data as input
- * @param moduleAutomaton - module automaton.
- * @param typeAutomaton - type automaton
- * @param mappings - Set of the mappings for the literals.
+ * @param firstPredicate Module type that generates the data as output
+ * @param secondPredicate Module type that uses the generated data as input
+ * @param moduleAutomaton module automaton.
+ * @param typeAutomaton type automaton
+ * @param mappings Set of the mappings for the literals.
* @return The String CNF representation of the SLTLx formula.
*/
public static String connectedModules(TaxonomyPredicate firstPredicate, TaxonomyPredicate secondPredicate,
@@ -525,22 +525,21 @@ public static String connectedModules(TaxonomyPredicate firstPredicate, Taxonomy
Map>> opOutInPairs = new HashMap<>();
int automatonSize = moduleAutomaton.getAllStates().size();
- for (int op1 = 0; op1 < automatonSize - 1; op1++) {
- for (int op2 = op1 + 1; op2 < automatonSize; op2++) {
-
- int currComb = mappings.getNextAuxNum();
- allCombinations.add(currComb);
+ for (Pair operations : APEUtils.generateDistinctPairs(automatonSize)) {
+ int op1 = operations.getFirst();
+ int op2 = operations.getSecond();
+ int currComb = mappings.getNextAuxNum();
+ allCombinations.add(currComb);
- opOrderStates.put(currComb, new Pair<>(moduleAutomaton.getAllStates().get(op1),
- moduleAutomaton.getAllStates().get(op2)));
+ opOrderStates.put(currComb, new Pair<>(moduleAutomaton.getAllStates().get(op1),
+ moduleAutomaton.getAllStates().get(op2)));
- List op1outputs = typeAutomaton.getMemoryTypesBlock(op1 + 1).getStates();
- List op2inputs = typeAutomaton.getUsedTypesBlock(op2).getStates();
+ List op1outputs = typeAutomaton.getMemoryTypesBlock(op1 + 1).getStates();
+ List op2inputs = typeAutomaton.getUsedTypesBlock(op2).getStates();
- Set> statePairs = APEUtils.getUniquePairs(op1outputs, op2inputs);
- opOutInPairs.put(currComb, statePairs);
+ Set> statePairs = APEUtils.getUniquePairs(op1outputs, op2inputs);
+ opOutInPairs.put(currComb, statePairs);
- }
}
// at least one of the combinations must be valid
for (Integer currComb : allCombinations) {
@@ -574,10 +573,10 @@ public static String connectedModules(TaxonomyPredicate firstPredicate, Taxonomy
* Creates a CNF representation of the Constraint:
* 1st operation should not generate an output used by the 2nd operation.
*
- * @param firstPredicate - Module type that generates the data as output
- * @param secondPredicate - Module type that uses the generated data as input
- * @param typeAutomaton - type automaton
- * @param mappings - Set of the mappings for the literals.
+ * @param firstPredicate Module type that generates the data as output
+ * @param secondPredicate Module type that uses the generated data as input
+ * @param typeAutomaton type automaton
+ * @param mappings Set of the mappings for the literals.
* @return The String CNF representation of the SLTLx formula.
*/
public static String notConnectedModules(TaxonomyPredicate firstPredicate, TaxonomyPredicate secondPredicate,
@@ -586,85 +585,162 @@ public static String notConnectedModules(TaxonomyPredicate firstPredicate, Taxon
StringBuilder constraints = new StringBuilder();
int automatonSize = moduleAutomaton.getAllStates().size();
- for (int op1 = 0; op1 < automatonSize - 1; op1++) {
- for (int op2 = op1 + 1; op2 < automatonSize; op2++) {
+ for (Pair operations : APEUtils.generateDistinctPairs(automatonSize)) {
+ int op1 = operations.getFirst();
+ int op2 = operations.getSecond();
- State firstModuleState = moduleAutomaton.get(op1);
- State secondModuleState = moduleAutomaton.get(op2);
+ State firstModuleState = moduleAutomaton.get(op1);
+ State secondModuleState = moduleAutomaton.get(op2);
- List op1outputs = typeAutomaton.getMemoryTypesBlock(op1 + 1).getStates();
- List op2inputs = typeAutomaton.getUsedTypesBlock(op2).getStates();
-
- // Ensure that either the 2 operations are not used consequently, or that they
- // are not connected
- Set> statePairs = APEUtils.getUniquePairs(op1outputs, op2inputs);
- for (Pair currIOpair : statePairs) {
- constraints.append("-").append(mappings.add(firstPredicate, firstModuleState, AtomType.MODULE))
- .append(" ");
- constraints.append("-"
- + mappings.add(currIOpair.getFirst(), currIOpair.getSecond(), AtomType.MEM_TYPE_REFERENCE)
- + " ");
- constraints.append("-"
- + mappings.add(secondPredicate, secondModuleState, AtomType.MODULE)
- + " 0\n");
- }
+ List op1outputs = typeAutomaton.getMemoryTypesBlock(op1 + 1).getStates();
+ List op2inputs = typeAutomaton.getUsedTypesBlock(op2).getStates();
+ // Ensure that either the 2 operations are not used consequently, or that they
+ // are not connected
+ Set> statePairs = APEUtils.getUniquePairs(op1outputs, op2inputs);
+ for (Pair currIOpair : statePairs) {
+ constraints.append("-").append(mappings.add(firstPredicate, firstModuleState, AtomType.MODULE))
+ .append(" ");
+ constraints.append("-"
+ + mappings.add(currIOpair.getFirst(), currIOpair.getSecond(), AtomType.MEM_TYPE_REFERENCE)
+ + " ");
+ constraints.append("-"
+ + mappings.add(secondPredicate, secondModuleState, AtomType.MODULE)
+ + " 0\n");
}
+
}
return constraints.toString();
+
}
+ /**
+ * Creates a CNF representation of the Constraint:
+ * Do not repeat using the same tool.
+ *
+ * @param predicate
+ * @param domainSetup
+ * @param moduleAutomaton
+ * @param typeAutomaton
+ * @param mappings
+ * @return
+ */
public static String notRepeatModules(TaxonomyPredicate predicate, APEDomainSetup domainSetup,
ModuleAutomaton moduleAutomaton,
TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
StringBuilder constraints = new StringBuilder();
int automatonSize = moduleAutomaton.getAllStates().size();
- for (int op1 = 0; op1 < automatonSize - 1; op1++) {
- for (int op2 = op1 + 1; op2 < automatonSize; op2++) {
-
- State firstModuleState = moduleAutomaton.get(op1);
- State secondModuleState = moduleAutomaton.get(op2);
-
- List op1outputs = typeAutomaton.getMemoryTypesBlock(op1 + 1).getStates();
- List op2inputs = typeAutomaton.getUsedTypesBlock(op2).getStates();
-
- // Ensure that either each operation is not used consequently, or that they are
- // not connected
- Set> statePairs = APEUtils.getUniquePairs(op1outputs, op2inputs);
- for (Pair currIOpair : statePairs) {
- // filter all operations
- domainSetup.getAllModules().getElementsFromSubTaxonomy(predicate).stream()
- .filter(x -> x.isSimplePredicate()).forEach(operation -> {
-
- constraints.append("-")
- .append(mappings.add(operation, firstModuleState, AtomType.MODULE)).append(" ");
- constraints.append("-"
- + mappings.add(currIOpair.getFirst(), currIOpair.getSecond(),
- AtomType.MEM_TYPE_REFERENCE)
- + " ");
- constraints.append("-"
- + mappings.add(operation, secondModuleState, AtomType.MODULE)
- + " 0\n");
- });
- }
+ for (Pair operations : APEUtils.generateDistinctPairs(automatonSize)) {
+ int op1 = operations.getFirst();
+ int op2 = operations.getSecond();
+
+ State firstModuleState = moduleAutomaton.get(op1);
+ State secondModuleState = moduleAutomaton.get(op2);
+ // filter all operations
+ domainSetup.getAllModules().getElementsFromSubTaxonomy(predicate).stream()
+ .filter(x -> x.isSimplePredicate()).forEach(operation -> {
+
+ constraints.append("-")
+ .append(mappings.add(operation, firstModuleState, AtomType.MODULE)).append(" ");
+ constraints.append("-"
+ + mappings.add(operation, secondModuleState, AtomType.MODULE)
+ + " 0\n");
+ });
+
+ }
+
+ return constraints.toString();
+ }
+
+ /**
+ * Creates a CNF representation of the Constraint:
+ * The same tools that belong to the sub-taxonomy should not be connected.
+ *
+ * @param predicate Root predicate of the sub-taxonomy.
+ * @param domainSetup Current domain setup.
+ * @param moduleAutomaton Current module automaton modeling the workflow control
+ * flow.
+ * @param typeAutomaton Current type automaton modeling the workflow data
+ * flow.
+ * @param mappings Set of the mappings for the literals.
+ * @return The String CNF representation of the SLTLx formula.
+ */
+ public static String notConnectModules(TaxonomyPredicate predicate, APEDomainSetup domainSetup,
+ ModuleAutomaton moduleAutomaton,
+ TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
+ StringBuilder constraints = new StringBuilder();
+ int automatonSize = moduleAutomaton.getAllStates().size();
+ for (Pair operations : APEUtils.generateDistinctPairs(automatonSize)) {
+ int op1 = operations.getFirst();
+ int op2 = operations.getSecond();
+
+ State firstModuleState = moduleAutomaton.get(op1);
+ State secondModuleState = moduleAutomaton.get(op2);
+
+ List op1outputs = typeAutomaton.getMemoryTypesBlock(op1 + 1).getStates();
+ List op2inputs = typeAutomaton.getUsedTypesBlock(op2).getStates();
+
+ // Ensure that either each operation is not used consequently, or that they are
+ // not connected
+ Set> statePairs = APEUtils.getUniquePairs(op1outputs, op2inputs);
+ for (Pair currIOpair : statePairs) {
+ // filter all operations
+ domainSetup.getAllModules().getElementsFromSubTaxonomy(predicate).stream()
+ .filter(x -> x.isSimplePredicate()).forEach(operation -> {
+
+ constraints.append("-")
+ .append(mappings.add(operation, firstModuleState, AtomType.MODULE)).append(" ");
+ constraints.append("-"
+ + mappings.add(currIOpair.getFirst(), currIOpair.getSecond(),
+ AtomType.MEM_TYPE_REFERENCE)
+ + " ");
+ constraints.append("-"
+ + mappings.add(operation, secondModuleState, AtomType.MODULE)
+ + " 0\n");
+ });
}
+
}
return constraints.toString();
}
/**
- * Simple method that combines a pair of integers into a unique String.
*
- * @param int1 - first integer
- * @param int2 - second integer
- * @return Unique combination of the pair, as String.
+ * Creates a CNF representation of the Constraint:
+ * Tools (that belong to the sub-taxonomy) should have all inputs unique.
+ *
+ * @param moduleAutomaton
+ * @param typeAutomaton
+ * @param mappings
+ * @return
*/
- private static String combine(int int1, int int2) {
- return int1 + "_" + int2;
+ public static String useUniqueInputs(
+ ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
+
+ StringBuilder constraints = new StringBuilder();
+ for (int blockNo = 0; blockNo < typeAutomaton.getLength(); blockNo++) {
+ Block inputs = typeAutomaton.getUsedTypesBlock(blockNo);
+ Set> inputPairs = new HashSet<>();
+ inputPairs.addAll(APEUtils.getUniquePairs(inputs.getStates()));
+ for (State memoryState : typeAutomaton.getAllMemoryStatesUntilBlockNo(blockNo)) {
+ for (Pair inputPair : inputPairs) {
+ constraints.append("-")
+ .append(mappings.add(memoryState, inputPair.getFirst(), AtomType.MEM_TYPE_REFERENCE))
+ .append(" ");
+ constraints.append("-")
+ .append(mappings.add(memoryState, inputPair.getSecond(), AtomType.MEM_TYPE_REFERENCE))
+ .append(" 0\n");
+ }
+ }
+
+ }
+ return constraints.toString();
}
}
+
+// pairs of inputs X1 X2 not ref(x1, O) or not ref(x2, O)
\ No newline at end of file
diff --git a/src/main/java/nl/uu/cs/ape/parserSLTLx/SLTLxSATVisitor.java b/src/main/java/nl/uu/cs/ape/parserSLTLx/SLTLxSATVisitor.java
index 8dc05741..9973c8ae 100644
--- a/src/main/java/nl/uu/cs/ape/parserSLTLx/SLTLxSATVisitor.java
+++ b/src/main/java/nl/uu/cs/ape/parserSLTLx/SLTLxSATVisitor.java
@@ -82,15 +82,15 @@ public SLTLxSATVisitor(SATSynthesisEngine synthesisEngine) {
* Parse the formulas, where each is separated by a new line, and return the set
* of {link SLTLxFormula}a that model it.
*
- * @param synthesisEngine - SAT synthesis engine
- * @param formulasInSLTLx - SLTLx formulas in textual format (separated by new
+ * @param synthesisEngine SAT synthesis engine
+ * @param formulasInSLTLx SLTLx formulas in textual format (separated by new
* lines)
* @return Set of {link SLTLxFormula} objects, where each represents a row
* (formula) from the text.
- * @throws SLTLxParsingGrammarException - Exception is thrown when a formula
+ * @throws SLTLxParsingGrammarException Exception is thrown when a formula
* does not follow the provided grammar
* rules.
- * @throws SLTLxParsingAnnotationException - Exception is thrown if the formula
+ * @throws SLTLxParsingAnnotationException Exception is thrown if the formula
* follows the given grammar, but cannot
* be interpreted under the current
* domain (e.g., used operation does not
diff --git a/src/main/java/nl/uu/cs/ape/solver/ModuleUtils.java b/src/main/java/nl/uu/cs/ape/solver/ModuleUtils.java
index 514f3cbd..6d65b5a2 100644
--- a/src/main/java/nl/uu/cs/ape/solver/ModuleUtils.java
+++ b/src/main/java/nl/uu/cs/ape/solver/ModuleUtils.java
@@ -83,7 +83,7 @@ public String encodeDataInstanceDependencyCons(TypeAutomaton typeAutomaton, SATA
* Returns the representation of the input type constraints for all tools
* regarding @typeAutomaton, for the synthesis concerning @moduleAutomaton.
*
- * @param synthesisInstance - synthesis instance
+ * @param synthesisInstance synthesis instance
*
* @return String representation of constraints.
*/
@@ -95,7 +95,7 @@ public String encodeDataInstanceDependencyCons(TypeAutomaton typeAutomaton, SATA
* ensure that the {@link AtomType#MEM_TYPE_REFERENCE} are implemented
* correctly.
*
- * @param synthesisInstance - synthesis instance
+ * @param synthesisInstance synthesis instance
*
* @return String representing the constraints required to ensure that the
* {@link AtomType#MEM_TYPE_REFERENCE} are implemented correctly.
@@ -111,7 +111,7 @@ public String encodeDataInstanceDependencyCons(TypeAutomaton typeAutomaton, SATA
* regarding @typeAutomaton, for the synthesis concerning @moduleAutomaton and
* the Shared Memory Approach.
*
- * @param synthesisInstance - synthesis instance
+ * @param synthesisInstance synthesis instance
*
* @return String representation of constraints.
*/
@@ -157,7 +157,7 @@ public abstract String enforceDataDependencyOverDataReferencing(TypeAutomaton ty
* workflow inputs have to be used, then each of them has to be referenced at
* least once.
*
- * @param synthesisInstance - synthesis instance
+ * @param synthesisInstance synthesis instance
*
* @return String representation of constraints.
*/
@@ -168,7 +168,7 @@ public abstract String enforceDataDependencyOverDataReferencing(TypeAutomaton ty
* regarding @typeAutomaton, for the synthesis concerning @moduleAutomaton.
* Generate constraints that preserve tool outputs.
*
- * @param synthesisInstance - synthesis instance
+ * @param synthesisInstance synthesis instance
*
* @return String representation of constraints.
*/
diff --git a/src/main/java/nl/uu/cs/ape/solver/SynthesisEngine.java b/src/main/java/nl/uu/cs/ape/solver/SynthesisEngine.java
index ffb6283e..cb2fd2d9 100644
--- a/src/main/java/nl/uu/cs/ape/solver/SynthesisEngine.java
+++ b/src/main/java/nl/uu/cs/ape/solver/SynthesisEngine.java
@@ -64,6 +64,8 @@ public interface SynthesisEngine {
/**
* Delete all temp files generated.
+ *
+ * @throws IOException the io exception if the files cannot be deleted.
*/
public void deleteTempFiles() throws IOException;
diff --git a/src/main/java/nl/uu/cs/ape/solver/minisat/EnforceModuleRelatedRules.java b/src/main/java/nl/uu/cs/ape/solver/minisat/EnforceModuleRelatedRules.java
index 0a6cf0b8..c6c98a91 100644
--- a/src/main/java/nl/uu/cs/ape/solver/minisat/EnforceModuleRelatedRules.java
+++ b/src/main/java/nl/uu/cs/ape/solver/minisat/EnforceModuleRelatedRules.java
@@ -126,7 +126,7 @@ public static Set ancestorRelationsDependency(SATSynthesisEngine s
* Function returns the encoding that ensures that identity relation (IS)
* among data objects is preserved.
*
- * @param typeAutomaton - collection of states representing the data objects in
+ * @param typeAutomaton collection of states representing the data objects in
* the workflow
* @return Set of SLTLx formulas that represent the constraints.
*/
@@ -564,7 +564,7 @@ private static Set ancestorRelRestrictOverModules(SATSynthesisEngi
* Generate constraints that ensure that the relations (e.g., identity relation
* (IS)) are reflexive.
*
- * @param binRel - binary relation that is reflexive
+ * @param binRel binary relation that is reflexive
*
* @return Set of SLTLx formulas that represent the constraints.
*/
@@ -598,7 +598,7 @@ private static Set relationalReflexivity(AtomType binRel, TypeAuto
* (IS)) are an identity.
* Forall X,Y IS(X,Y) IFF
*
- * @param binRel - binary relation that is reflexive
+ * @param binRel binary relation that is reflexive
*
* @return Set of SLTLx formulas that represent the constraints.
*/
@@ -650,8 +650,8 @@ private static Set relationalIdentity(AtomType binRel, TypeAutomat
* Function returns the encoding that ensures that the relation (e.g., ancestor
* relation (R)) is transitive.
*
- * @param binRel - relation that is transitive
- * @param typeAutomaton - system that represents states in the workflow
+ * @param binRel relation that is transitive
+ * @param typeAutomaton system that represents states in the workflow
* @return Set of SLTLx formulas that represent the constraints.
*/
private static Set relationalTransitivity(AtomType binRel, TypeAutomaton typeAutomaton) {
@@ -688,8 +688,8 @@ private static Set relationalTransitivity(AtomType binRel, TypeAut
* Function returns the encoding that ensures that
* the relation (e.g., identity relations (IS)) is symmetrical.
*
- * @param binRel - binary relation that is symmetrical
- * @param typeAutomaton - system that represents states in the workflow
+ * @param binRel binary relation that is symmetrical
+ * @param typeAutomaton system that represents states in the workflow
* @return Set of SLTLx formulas that represent the constraints.
*/
private static Set relationalSymmetry(AtomType binRel, TypeAutomaton typeAutomaton) {
@@ -722,7 +722,7 @@ private static Set relationalSymmetry(AtomType binRel, TypeAutomat
* workflow inputs have to be used, then each of them has to be referenced at
* least once.
*
- * @param synthesisInstance - instance of the synthesis engine
+ * @param synthesisInstance instance of the synthesis engine
*
* @return Set of SLTLx formulas that represent the constraints.
*/
@@ -838,7 +838,7 @@ private static Set usageOfGeneratedTypes(SATSynthesisEngine synthe
* regarding @typeAutomaton, for the synthesis concerning @moduleAutomaton.
* Generate constraints that preserve tool outputs.
*
- * @param synthesisInstance - instance of the synthesis engine
+ * @param synthesisInstance instance of the synthesis engine
*
* @return Set of SLTLx formulas that represent the constraints.
*/
diff --git a/src/main/java/nl/uu/cs/ape/solver/minisat/EnforceTypeRelatedRules.java b/src/main/java/nl/uu/cs/ape/solver/minisat/EnforceTypeRelatedRules.java
index 8e10042d..8013da95 100644
--- a/src/main/java/nl/uu/cs/ape/solver/minisat/EnforceTypeRelatedRules.java
+++ b/src/main/java/nl/uu/cs/ape/solver/minisat/EnforceTypeRelatedRules.java
@@ -47,8 +47,8 @@ private EnforceTypeRelatedRules() {
* (excluding abstract modules from the taxonomy) in each memory state
* of @moduleAutomaton.
*
- * @param pair - pair of types from a dimension.
- * @param typeAutomaton - System that represents states in the workflow
+ * @param pair pair of types from a dimension.
+ * @param typeAutomaton System that represents states in the workflow
* @return String representation of constraints.
*/
public static Set memoryTypesMutualExclusion(Pair pair, TypeAutomaton typeAutomaton) {
@@ -77,8 +77,8 @@ public static Set memoryTypesMutualExclusion(Pair
* (excluding abstract modules from the taxonomy) in each used state
* of @moduleAutomaton.
*
- * @param pair - pair of types from a dimension.
- * @param typeAutomaton - System that represents states in the workflow
+ * @param pair pair of types from a dimension.
+ * @param typeAutomaton System that represents states in the workflow
* @return String representation of constraints.
*/
public static Set usedTypeMutualExclusion(Pair pair, TypeAutomaton typeAutomaton) {
@@ -109,8 +109,8 @@ public static Set usedTypeMutualExclusion(Pair pai
* state of @moduleAutomaton. It enforces that each type instance is either
* defined on all the dimensions or is empty.
*
- * @param domainSetup - Domain model
- * @param typeAutomaton - System that represents states in the workflow
+ * @param domainSetup Domain model
+ * @param typeAutomaton System that represents states in the workflow
* @return String representation of constraints.
*/
public static Set typeMandatoryUsage(APEDomainSetup domainSetup, TypeAutomaton typeAutomaton) {
@@ -158,8 +158,8 @@ public static Set typeMandatoryUsage(APEDomainSetup domainSetup, T
* and it's valid in each state of @typeAutomaton. @emptyType denotes the type
* that is being used if the state has no type.
*
- * @param allTypes - Collection of all the types in the domain.
- * @param typeAutomaton - System that represents states in the workflow
+ * @param allTypes Collection of all the types in the domain.
+ * @param typeAutomaton System that represents states in the workflow
* @return The String representation of constraints enforcing taxonomy
* classifications.
*/
@@ -187,9 +187,9 @@ public static Set typeEnforceTaxonomyStructure(AllTypes allTypes,
/**
* Supporting recursive method for typeEnforceTaxonomyStructure.
*
- * @param currType - Current type
- * @param typeState - Current type state
- * @param typeElement - Current type element
+ * @param currType Current type
+ * @param typeState Current type state
+ * @param typeElement Current type element
* @return Set of the corresponding SLTLx formulas
*/
private static Set typeEnforceTaxonomyStructureForState(TaxonomyPredicate currType,
@@ -235,21 +235,21 @@ private static Set typeEnforceTaxonomyStructureForState(TaxonomyPr
* Encodes rules that ensure the initial workflow input.
*
* @param allTypes Set of all the types in the domain
- * @param program_inputs Input types for the program.
+ * @param programInputs Input types for the program.
* @param typeAutomaton Automaton representing the type states in the model
* @return The String representation of the initial input encoding.
* @throws APEConfigException Exception thrown when one of the output types is
* not defined in the taxonomy.
*/
- public static Set workflowInputs(AllTypes allTypes, List program_inputs,
+ public static Set workflowInputs(AllTypes allTypes, List programInputs,
TypeAutomaton typeAutomaton) throws APEConfigException {
Set fullEncoding = new HashSet<>();
List workflowInputStates = typeAutomaton.getWorkflowInputBlock().getStates();
for (int i = 0; i < workflowInputStates.size(); i++) {
State currState = workflowInputStates.get(i);
- if (i < program_inputs.size()) {
- Type currType = program_inputs.get(i);
+ if (i < programInputs.size()) {
+ Type currType = programInputs.get(i);
if (allTypes.get(currType.getPredicateID()) == null) {
throw APEConfigException.workflowIODataTypeNotInDomain(currType.getPredicateID());
}
@@ -274,20 +274,20 @@ public static Set workflowInputs(AllTypes allTypes, List pro
* Encodes the rules that ensure generation of the workflow output.
*
* @param allTypes Set of all the types in the domain
- * @param program_outputs Output types for the program.
+ * @param programOutputs Output types for the program.
* @param typeAutomaton Automaton representing the type states in the model
* @return String representation of the workflow output encoding.
* @throws APEConfigException Exception thrown when one of the output types is
* not defined in the taxonomy.
*/
- public static Set workdlowOutputs(AllTypes allTypes, List program_outputs,
+ public static Set workflowOutputs(AllTypes allTypes, List programOutputs,
TypeAutomaton typeAutomaton) throws APEConfigException {
Set fullEncoding = new HashSet<>();
List workflowOutputStates = typeAutomaton.getWorkflowOutputBlock().getStates();
for (int i = 0; i < workflowOutputStates.size(); i++) {
- if (i < program_outputs.size()) {
- TaxonomyPredicate currType = program_outputs.get(i);
+ if (i < programOutputs.size()) {
+ TaxonomyPredicate currType = programOutputs.get(i);
if (allTypes.get(currType.getPredicateID()) == null) {
throw APEConfigException.workflowIODataTypeNotInDomain(currType.getPredicateID());
}
diff --git a/src/main/java/nl/uu/cs/ape/solver/minisat/SATSynthesisEngine.java b/src/main/java/nl/uu/cs/ape/solver/minisat/SATSynthesisEngine.java
index 5f602be1..b34bd128 100644
--- a/src/main/java/nl/uu/cs/ape/solver/minisat/SATSynthesisEngine.java
+++ b/src/main/java/nl/uu/cs/ape/solver/minisat/SATSynthesisEngine.java
@@ -124,7 +124,7 @@ public class SATSynthesisEngine implements SynthesisEngine {
* @param allSolutions Set of {@link SolutionWorkflow}.
* @param runConfig Setup configuration for the synthesis.
* @param workflowLength Workflow length
- * @throws IOException - Error if the temp file cannot be created
+ * @throws IOException Error if the temp file cannot be created
*/
public SATSynthesisEngine(APEDomainSetup domainSetup, SolutionsList allSolutions,
APERunConfig runConfig, int workflowLength) throws IOException {
@@ -248,7 +248,7 @@ public boolean synthesisEncoding() throws IOException {
* Encode the workflow output
*/
SLTLxFormula.appendCNFToFile(cnfEncoding, this, EnforceTypeRelatedRules
- .workdlowOutputs(domainSetup.getAllTypes(), runConfig.getProgramOutputs(), typeAutomaton));
+ .workflowOutputs(domainSetup.getAllTypes(), runConfig.getProgramOutputs(), typeAutomaton));
/*
* Encode rule that the given inputs should not be used as workflow outputs
@@ -287,14 +287,12 @@ public boolean synthesisEncoding() throws IOException {
/* add the cnf encoding file to Desktop */
// Files.copy(satInputFile, new File("~/Desktop/tmp"+ problemSetupStartTime));
+
/*
- * Add human readable version of the cnf encoding file to Desktop. Used when
- * needed.
+ * Add human readable version of the cnf encoding file to Desktop. Used only when
+ * explicitly specified (used for local testing).
*/
- // FileInputStream cnfStream = new FileInputStream(satInputFile);
- // String encoding = APEUtils.convertCNF2humanReadable(cnfStream, mappings);
- // cnfStream.close();
- // APEFiles.write2file(encoding, new File("~/Desktop/tmp.txt"), false);
+ domainSetup.localCNF(satInputFile, mappings);
long problemSetupTimeElapsedMillis = System.currentTimeMillis() - problemSetupStartTime;
log.info("Total problem setup time: " + (problemSetupTimeElapsedMillis / 1000F) + " sec (" + clauses
@@ -446,7 +444,7 @@ public SLTLxVariableOccurrenceCollection getVariableUsage() {
/**
* Delete all temporary files created.
*
- * @throws IOException - Failed to delete temp files.
+ * @throws IOException Failed to delete temp files.
*/
public void deleteTempFiles() throws IOException {
try {
diff --git a/src/main/java/nl/uu/cs/ape/solver/minisat/SatEncodingUtils.java b/src/main/java/nl/uu/cs/ape/solver/minisat/SatEncodingUtils.java
index 674e711d..3e0b320f 100644
--- a/src/main/java/nl/uu/cs/ape/solver/minisat/SatEncodingUtils.java
+++ b/src/main/java/nl/uu/cs/ape/solver/minisat/SatEncodingUtils.java
@@ -15,6 +15,10 @@
import nl.uu.cs.ape.models.sltlxStruc.SLTLxFormula;
import nl.uu.cs.ape.parserSLTLx.SLTLxSATVisitor;
+/**
+ * The {@code SatEncodingUtils} class is used to provide utility functions for
+ * encoding constraints in SAT.
+ */
@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class SatEncodingUtils {
@@ -22,7 +26,7 @@ public class SatEncodingUtils {
/**
* Encode APE constraints string.
*
- * @param synthesisEngine
+ * @param synthesisEngine the synthesis engine used to generate the CNF encoding
*
* @param domainSetup Domain information, including all the existing tools
* and types.
diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/ModuleNode.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/ModuleNode.java
index a9c541be..957ba222 100644
--- a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/ModuleNode.java
+++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/ModuleNode.java
@@ -92,7 +92,7 @@ public ModuleNode(State automatonState) throws ExceptionInInitializerError {
/**
* Set module/tool that defines this step in the workflow.
*
- * @param module - tool provided by the tool/module annotations.
+ * @param module tool provided by the tool/module annotations.
*/
public void setUsedModule(Module module) {
this.usedModule = module;
@@ -102,7 +102,7 @@ public void setUsedModule(Module module) {
* Add the abstract module to the list of modules that describes the tool
* instance.
*
- * @param abstractModule - abstract type that describes the instance.
+ * @param abstractModule abstract type that describes the instance.
*/
public void addAbstractDescriptionOfUsedType(AbstractModule abstractModule) {
if (!abstractModule.isSimplePredicate()) {
@@ -304,6 +304,8 @@ public Graph addTavernaStyleModuleToGraph(Graph workflowGraph) {
/**
* Get id of the current workflow node.
+ *
+ * @return ID of the current workflow node.
*/
public String getNodeID() {
StringBuilder printString = new StringBuilder();
@@ -315,6 +317,8 @@ public String getNodeID() {
/**
* Get label of the current workflow node.
+ *
+ * @return Label of the current workflow node.
*/
public String getNodeLabel() {
return this.usedModule.getPredicateLabel();
@@ -322,6 +326,8 @@ public String getNodeLabel() {
/**
* Get label of the current workflow node as an HTML element.
+ *
+ * @return HTML label of the current workflow node.
*/
public String getNodeGraphLabel() {
return "" + this.usedModule.getPredicateLabel() + "";
@@ -329,6 +335,8 @@ public String getNodeGraphLabel() {
/**
* Gets node descriptive label, containing module IDs.
+ *
+ * @return The node descriptive label.
*/
public String getNodeLongLabel() {
return this.usedModule.getPredicateLongLabel();
diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/SolutionsList.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/SolutionsList.java
index df92831e..83a6e90d 100644
--- a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/SolutionsList.java
+++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/SolutionsList.java
@@ -61,10 +61,10 @@ public class SolutionsList {
/**
* Create an object that will contain all the solutions of the synthesis.
*
- * @param runConfig - setup configuration for the synthesis run.
+ * @param runConfig setup configuration for the synthesis run.
*/
public SolutionsList(APERunConfig runConfig) {
- this.solutions = new ArrayList();
+ this.solutions = new ArrayList<>();
this.runConfig = runConfig;
/*
* Provides mapping from each atom/predicate to a number/string, and vice versa
@@ -175,8 +175,8 @@ public int size() {
* Set a specific number to be the number of solutions that are found up to the
* specified length.
*
- * @param length - the length up until which the solutions are evaluated
- * @param noSolutions - number of solutions that can be found up until the given
+ * @param length the length up until which the solutions are evaluated
+ * @param noSolutions number of solutions that can be found up until the given
* length
*/
public void addNoSolutionsForLength(Integer length, Integer noSolutions) {
@@ -185,7 +185,7 @@ public void addNoSolutionsForLength(Integer length, Integer noSolutions) {
if (solutionsPerLength == null) {
solutionsPerLength = new ArrayList<>();
}
- solutionsPerLength.add(new Pair(length, noSolutions));
+ solutionsPerLength.add(new Pair<>(length, noSolutions));
}
/**
@@ -220,7 +220,7 @@ public Stream getParallelStream() {
* Set the synthesis result flag, i.e., set the reason why the synthesis
* execution was interrupted.
*
- * @param flag - the {@link SynthesisFlag} that should be set
+ * @param flag the {@link SynthesisFlag} that should be set
*/
public void setFlag(SynthesisFlag flag) {
this.runFlag = flag;
diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/TypeNode.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/TypeNode.java
index d359facc..b2bf6138 100644
--- a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/TypeNode.java
+++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/TypeNode.java
@@ -4,7 +4,6 @@
import guru.nidi.graphviz.attribute.Label;
import guru.nidi.graphviz.attribute.Shape;
import guru.nidi.graphviz.attribute.Style;
-import guru.nidi.graphviz.attribute.Label.Justification;
import guru.nidi.graphviz.model.Graph;
import lombok.extern.slf4j.Slf4j;
import nl.uu.cs.ape.automaton.State;
@@ -68,10 +67,10 @@ public class TypeNode extends SolutionWorkflowNode {
*/
public TypeNode(State automatonState) throws ExceptionInInitializerError {
super(automatonState);
- this.usedTypes = new TreeSet();
- this.abstractTypes = new TreeSet();
+ this.usedTypes = new TreeSet<>();
+ this.abstractTypes = new TreeSet<>();
this.createdByModule = null;
- usedByModules = new ArrayList();
+ usedByModules = new ArrayList<>();
if (automatonState.getWorkflowStateType() != AtomType.MEMORY_TYPE) {
throw new ExceptionInInitializerError(
"Class MemTypeNode can only be instantiated using State that is of type AtomType.MEMORY_TYPE, as a parameter.");
diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/AbstractCWLCreator.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/AbstractCWLCreator.java
index 4f040e33..6fb30a69 100644
--- a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/AbstractCWLCreator.java
+++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/AbstractCWLCreator.java
@@ -14,7 +14,7 @@
* Class to generate a CWL workflow structure from a given workflow solution.
*/
@Slf4j
-public class AbstractCWLCreator extends CWLCreatorBase {
+public class AbstractCWLCreator extends CWLWorkflowBase {
/**
* Maintain a list of the CWL parameter names which represent {@link TypeNode}s.
* I.e. this hashmap has TypeNode IDs as keys and their names in the CWL file as
@@ -31,13 +31,6 @@ public AbstractCWLCreator(SolutionWorkflow solution) {
super(solution);
}
- @Override
- public String getCWLVersion() {
- // CWL version 1.2.0-dev2 is the minimum version required for the features we
- // use here.
- return "v1.2.0-dev2";
- }
-
/**
* Generates the CWL representation.
*/
diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/CWLToolBase.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/CWLToolBase.java
new file mode 100644
index 00000000..4fda32a3
--- /dev/null
+++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/CWLToolBase.java
@@ -0,0 +1,248 @@
+package nl.uu.cs.ape.solver.solutionStructure.cwl;
+
+import nl.uu.cs.ape.solver.solutionStructure.ModuleNode;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import nl.uu.cs.ape.models.AuxTypePredicate;
+import nl.uu.cs.ape.models.AuxiliaryPredicate;
+import nl.uu.cs.ape.models.Module;
+import nl.uu.cs.ape.models.Type;
+import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
+
+/**
+ * Base class with shared behavior for CWL export classes.
+ */
+public abstract class CWLToolBase {
+ /**
+ * Cwl representation.
+ */
+ protected final StringBuilder cwlRepresentation;
+ /**
+ * Tool depicted in the CWL file.
+ */
+ protected Module tool;
+ /**
+ * Indent style used.
+ */
+ private IndentStyle indentStyle;
+
+ /**
+ * Generate the creator base from the workflow solution.
+ *
+ * @param tool APE workflow solution
+ */
+ protected CWLToolBase(Module tool) {
+ this.tool = tool;
+ this.cwlRepresentation = new StringBuilder();
+ this.indentStyle = IndentStyle.SPACES2;
+ }
+
+ /**
+ * Override the default indentation style.
+ *
+ * @param indentStyle The indentation style to use.
+ * @return A reference to this CWLCreator.
+ */
+ public CWLToolBase setIndentStyle(IndentStyle indentStyle) {
+ this.indentStyle = indentStyle;
+ return this;
+ }
+
+ /**
+ * Get the CWL version required for the CWL file.
+ *
+ * @return The required CWL version.
+ */
+ public String getCWLVersion() {
+ return "v1.2";
+ }
+
+ /**
+ * Generates the CWL representation.
+ *
+ * @return The CWL representation.
+ */
+ public String generate() {
+ // Top of file comment
+ generateTopComment();
+
+ cwlRepresentation.append(String.format("cwlVersion: %s%n", getCWLVersion()));
+ cwlRepresentation.append("class: CommandLineTool").append("\n");
+
+ cwlRepresentation.append("baseCommand: ").append(tool.getPredicateID()).append("\n");
+ cwlRepresentation.append("label: ").append(tool.getPredicateLabel()).append("\n");
+
+ // Add requirements (generic)
+ cwlRepresentation.append("requirements:\n");
+ cwlRepresentation.append(" ShellCommandRequirement: {}\n");
+ cwlRepresentation.append(" InitialWorkDirRequirement:\n");
+ cwlRepresentation.append(" listing:\n");
+
+ // Dynamically add inputs to InitialWorkDirRequirement listing
+ for (String input : this.getInputs().keySet()) {
+ cwlRepresentation.append(" - $(inputs.").append(input).append(")\n");
+ }
+
+ // Add DockerRequirement dynamically
+ cwlRepresentation.append(" DockerRequirement:\n");
+ cwlRepresentation.append(" dockerPull: fix-this-path/").append(tool.getPredicateLabel()).append("\n")
+ .append("\n");
+
+ generateCWLRepresentation();
+
+ return cwlRepresentation.toString();
+ }
+
+ /**
+ * Get the map of input names and their types.
+ *
+ * @return The map of input names and their types.
+ */
+ protected Map> getInputs() {
+ int i = 0;
+ Map> inputNames = new HashMap<>();
+ for (Type inType : tool.getModuleInput()) {
+ List formatType = new ArrayList<>();
+ if (inType instanceof AuxTypePredicate) {
+ formatType = extractFormat((AuxTypePredicate) inType);
+ }
+
+ inputNames.put(tool.getPredicateLabel() + "_in_" + i++, formatType);
+
+ }
+ return inputNames;
+ }
+
+ private List extractFormat(AuxTypePredicate auxType) {
+ List formatTypes = new ArrayList<>();
+ for (TaxonomyPredicate subtype : auxType.getGeneralizedPredicates()) {
+ if (subtype instanceof AuxTypePredicate) {
+ formatTypes.addAll(extractFormat((AuxTypePredicate) subtype));
+ } else if (subtype.getRootNodeID().equals("http://edamontology.org/format_1915")) {
+ formatTypes.add(subtype);
+ }
+ }
+ return formatTypes;
+ }
+
+ /**
+ * Get the map of input names and their types.
+ *
+ * @return The map of input names and their types.
+ */
+ protected Map> getOutputs() {
+ int i = 0;
+ Map> inputNames = new HashMap<>();
+ for (Type inType : tool.getModuleOutput()) {
+ List formatType = new ArrayList<>();
+ if (inType instanceof AuxTypePredicate) {
+ formatType = extractFormat((AuxTypePredicate) inType);
+ }
+
+ inputNames.put(tool.getPredicateLabel() + "_out_" + i++, formatType);
+
+ }
+ return inputNames;
+ }
+
+ /**
+ * Adds the comment at the top of the file.
+ */
+ protected void generateTopComment() {
+ cwlRepresentation.append(
+ "# The template for this tool description is generated by APE (https://github.com/sanctuuary/APE).\n");
+ }
+
+ /**
+ * Generate the name of the input or output of a step's run input or output.
+ * I.e. "moduleName_indicator_n".
+ *
+ * @param moduleNode The {@link ModuleNode} that is the workflow step.
+ * @param indicator Indicator whether it is an input or an output.
+ * @param n The n-th input or output this is.
+ * @return The name of the input or output.
+ */
+ protected String generateInputOrOutputName(ModuleNode moduleNode, String indicator, int n) {
+ return String.format("%s_%s_%o",
+ moduleNode.getNodeLabel(),
+ indicator,
+ n);
+ }
+
+ /**
+ * Generate the name for a step in the workflow.
+ *
+ * @param moduleNode The {@link ModuleNode} that is the workflow step.
+ * @return The name of the workflow step.
+ */
+ protected String stepName(ModuleNode moduleNode) {
+ int stepNumber = moduleNode.getAutomatonState().getLocalStateNumber();
+ if (stepNumber < 10) {
+ return String.format("%s_0%o", moduleNode.getUsedModule().getPredicateLabel(), stepNumber);
+ } else {
+ return String.format("%s_%o", moduleNode.getUsedModule().getPredicateLabel(), stepNumber);
+ }
+ }
+
+ /**
+ * Generate the main part of the CWL representation.
+ */
+ protected abstract void generateCWLRepresentation();
+
+ /**
+ * Gets the CWL representation.
+ *
+ * @return The CWL representation.
+ */
+ public String getCWL() {
+ return cwlRepresentation.toString();
+ }
+
+ /**
+ * Delete a number of characters at the end of the CWL file.
+ *
+ * @param numberOfCharToDel The number of characters to remove.
+ */
+ protected void deleteLastNCharactersFromCWL(int numberOfCharToDel) {
+ cwlRepresentation.delete(cwlRepresentation.length() - numberOfCharToDel, cwlRepresentation.length());
+ }
+
+ /**
+ * Generate the indentation at the start of a line.
+ *
+ * @param level The level of indentation.
+ * @return The indentation of the given level.
+ */
+ protected String ind(int level) {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < level; i++) {
+ builder.append(this.indentStyle);
+ }
+ return builder.toString();
+ }
+
+ /**
+ * The available indentation styles.
+ */
+ public enum IndentStyle {
+ /** Two spaces for indentation. */
+ SPACES2(" "),
+ /** Four spaces for indentation. */
+ SPACES4(" ");
+
+ private final String text;
+
+ IndentStyle(String s) {
+ this.text = s;
+ }
+
+ @Override
+ public String toString() {
+ return this.text;
+ }
+ }
+}
diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/CWLCreatorBase.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/CWLWorkflowBase.java
similarity index 95%
rename from src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/CWLCreatorBase.java
rename to src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/CWLWorkflowBase.java
index 5bd9a078..76dd303a 100644
--- a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/CWLCreatorBase.java
+++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/CWLWorkflowBase.java
@@ -6,7 +6,7 @@
/**
* Base class with shared behavior for CWL export classes.
*/
-public abstract class CWLCreatorBase {
+public abstract class CWLWorkflowBase {
/**
* Cwl representation.
*/
@@ -23,9 +23,9 @@ public abstract class CWLCreatorBase {
/**
* Generate the creator base from the workflow solution.
*
- * @param solution - APE workflow solution
+ * @param solution APE workflow solution
*/
- protected CWLCreatorBase(SolutionWorkflow solution) {
+ protected CWLWorkflowBase(SolutionWorkflow solution) {
this.solution = solution;
this.cwlRepresentation = new StringBuilder();
this.indentStyle = IndentStyle.SPACES2;
@@ -37,7 +37,7 @@ protected CWLCreatorBase(SolutionWorkflow solution) {
* @param indentStyle The indentation style to use.
* @return A reference to this CWLCreator.
*/
- public CWLCreatorBase setIndentStyle(IndentStyle indentStyle) {
+ public CWLWorkflowBase setIndentStyle(IndentStyle indentStyle) {
this.indentStyle = indentStyle;
return this;
}
@@ -47,7 +47,9 @@ public CWLCreatorBase setIndentStyle(IndentStyle indentStyle) {
*
* @return The required CWL version.
*/
- public abstract String getCWLVersion();
+ public String getCWLVersion() {
+ return "v1.2";
+ }
/**
* Generates the CWL representation.
diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/DefaultCWLCreator.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/DefaultCWLCreator.java
index c2f62d22..4653bcfa 100644
--- a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/DefaultCWLCreator.java
+++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/DefaultCWLCreator.java
@@ -1,7 +1,6 @@
package nl.uu.cs.ape.solver.solutionStructure.cwl;
import nl.uu.cs.ape.models.Type;
-import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
import nl.uu.cs.ape.solver.solutionStructure.ModuleNode;
import nl.uu.cs.ape.solver.solutionStructure.SolutionWorkflow;
import nl.uu.cs.ape.solver.solutionStructure.TypeNode;
@@ -17,7 +16,7 @@
* Class to generate a CWL workflow structure from a given workflow solution.
*/
@Slf4j
-public class DefaultCWLCreator extends CWLCreatorBase {
+public class DefaultCWLCreator extends CWLWorkflowBase {
/**
* Maintain a list of the CWL parameter names which represent {@link TypeNode}s.
* I.e. this hashmap has TypeNode IDs as keys and their names in the CWL file as
@@ -34,10 +33,6 @@ public DefaultCWLCreator(SolutionWorkflow solution) {
super(solution);
}
- @Override
- public String getCWLVersion() {
- return "v1.2";
- }
/**
* Generates the CWL representation.
@@ -254,7 +249,7 @@ private void generateStepOut(ModuleNode moduleNode) {
*/
private void generateDefaultStepRun(ModuleNode moduleNode) {
final int baseInd = 2;
- String moduleReference = "add-path-to-the-implementation/" + moduleNode.getUsedModule().getPredicateLabel()
+ String moduleReference = "add-path-to-the-implementation/" + moduleNode.getUsedModule().getPredicateID()
+ ".cwl ";
if (moduleNode.getUsedModule().getCwlFileReference() != null) {
moduleReference = moduleNode.getUsedModule().getCwlFileReference();
diff --git a/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/ToolCWLCreator.java b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/ToolCWLCreator.java
new file mode 100644
index 00000000..7580bcbb
--- /dev/null
+++ b/src/main/java/nl/uu/cs/ape/solver/solutionStructure/cwl/ToolCWLCreator.java
@@ -0,0 +1,81 @@
+package nl.uu.cs.ape.solver.solutionStructure.cwl;
+
+import nl.uu.cs.ape.models.Module;
+import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
+
+import java.util.List;
+import java.util.Map;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * Class to generate a CWL structure for a tool.
+ */
+@Slf4j
+public class ToolCWLCreator extends CWLToolBase {
+ /**
+ * Instantiates a new CWL creator.
+ *
+ * @param module The solution to represent in CWL.
+ */
+ public ToolCWLCreator(Module module) {
+ super(module);
+ }
+
+ /**
+ * Generates the CWL representation.
+ */
+ @Override
+ protected void generateCWLRepresentation() {
+ // Tool annotations
+ generateWorkflowInOut("inputs", super.getInputs());
+ generateWorkflowInOut("outputs", super.getOutputs());
+ }
+
+ /**
+ * Generate the inputs and outputs of the tool.
+ *
+ * @param header The header of the section (inputs/outputs).
+ * @param map The types of the inputs/outputs.
+ */
+ private void generateWorkflowInOut(String header, Map> map) {
+ cwlRepresentation.append(header).append(":\n");
+ // Inputs
+ map.entrySet().forEach(input ->
+
+ cwlRepresentation
+ // Name
+ .append(ind(1))
+ .append(input.getKey())
+ .append(":\n")
+ // Data type
+ .append(ind(2))
+ .append("type: File")
+ .append("\n")
+ // Format
+ .append(ind(2))
+ .append("format: ")
+ .append(formatType(input.getValue()))
+ .append("\n"));
+ }
+
+ /**
+ * Get the format of the current workflow node and a label for the CWL file.
+ *
+ * @param list
+ */
+ public String formatType(List list) {
+ StringBuilder printString = new StringBuilder();
+
+ if (!list.isEmpty()) {
+ printString.append("\"").append(list.get(0).getPredicateLongLabel()).append("\" # ").append(list.get(0).getPredicateLabel()).append("\n");
+ }
+ if (list.size() > 1) {
+ log.info("Multiple formats for the same input/output are not supported.");
+ printString.append(ind(2)).append("doc: The I/O is annotated with multiple data formats in bio.tools. We specified here the first one, while the rest are part of tool.json file. Please check the instructions on how to handle such cases: https://workflomics.readthedocs.io/en/latest/domain-expert-guide/domain-development.html");
+ }
+
+ return printString.toString();
+ }
+
+}
diff --git a/src/main/java/nl/uu/cs/ape/utils/APEFiles.java b/src/main/java/nl/uu/cs/ape/utils/APEFiles.java
index cac3a6b1..703f2af6 100644
--- a/src/main/java/nl/uu/cs/ape/utils/APEFiles.java
+++ b/src/main/java/nl/uu/cs/ape/utils/APEFiles.java
@@ -13,14 +13,14 @@
import nl.uu.cs.ape.models.sltlxStruc.CNFClause;
import org.apache.commons.io.LineIterator;
-import org.apache.commons.io.output.FileWriterWithEncoding;
import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
-import java.io.Writer;
+import java.io.OutputStreamWriter;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
@@ -54,8 +54,8 @@ public enum Permission {
/**
* Verify and get full local path based based on the field.
*
- * @param tag - tag
- * @param path - path
+ * @param tag tag
+ * @param path path
* @return Return the path to the file
*/
private static Path getLocalPath(String tag, String path) {
@@ -80,7 +80,7 @@ private static Path getLocalPath(String tag, String path) {
/**
* Verify whether the path is a valid local path.
*
- * @param path - local path
+ * @param path local path
* @return Return {@code true} if the local path exists, {@code false}
* otherwise.
*/
@@ -193,8 +193,8 @@ public static Path readDirectoryPath(String tag, String inputPath, Permission...
/**
* Create a directory path if needed.
*
- * @param tag - tag used
- * @param path - directory path
+ * @param tag tag used
+ * @param path directory path
*/
private static void createDirectory(String tag, Path path) throws APEConfigException {
@@ -305,7 +305,7 @@ public static boolean isURI(String uri) {
* Read file content from the given path (local path or a public URL) and return
* the content as a File object.
*
- * @param filePath - Local path or a public URL with the content.
+ * @param filePath Local path or a public URL with the content.
* @return File containing info provided at the path.
* @throws IOException Exception in case of a badly formatted path or file.
*/
@@ -318,7 +318,7 @@ public static File readPathToFile(String filePath) throws IOException {
/**
* Read content from a URL and return it as a file.
*
- * @param fileUrl - URL of the content
+ * @param fileUrl URL of the content
* @return File containing info provided at the URL.
* @throws IOException Exception in case of a badly formatted URL or file.
*/
@@ -333,33 +333,41 @@ private static File readURLToFile(String fileUrl) throws IOException {
}
/**
- * Append text to the existing file. It adds the text at the end of the content
+ * Appends text to the existing file. It adds the text at the end of the content
* of the file.
- *
- * @param file - existing file
- * @param content - content that should be appended
- * @throws IOException in case of an I/O error
- * @throws NullPointerException if the file is null
+ *
+ * @param file The existing file.
+ * @param content The content that should be appended.
+ * @throws IOException In case of an I/O error.
+ * @throws NullPointerException If the file or content is null.
*/
- public static void appendToFile(File file, String content) throws IOException, NullPointerException {
- Writer fileWriter = new FileWriterWithEncoding(file, "ASCII", true);
- try (BufferedWriter writer = new BufferedWriter(fileWriter, 8192 * 4)) {
+ public static void appendToFile(File file, String content) throws IOException {
+ if (file == null || content == null) {
+ throw new NullPointerException("File or content cannot be null.");
+ }
+
+ try (BufferedWriter writer = new BufferedWriter(
+ new OutputStreamWriter(new FileOutputStream(file, true), StandardCharsets.US_ASCII), 8192 * 4)) {
writer.write(content);
}
}
/**
- * Append text to the existing file. It adds the text at the end of the content
- * of the file.
- *
- * @param file - existing file
- * @param content - content that should be appended
- * @throws IOException in case of an I/O error
- * @throws NullPointerException if the file is null
+ * Appends a set of text strings to the existing file. Each element in the set
+ * is added at the end of the content of the file.
+ *
+ * @param file The existing file.
+ * @param content The set of content strings that should be appended.
+ * @throws IOException In case of an I/O error.
+ * @throws NullPointerException If the file or content set is null.
*/
- public static void appendSetToFile(File file, Set content) throws IOException, NullPointerException {
- Writer fileWriter = new FileWriterWithEncoding(file, "ASCII", true);
- try (BufferedWriter writer = new BufferedWriter(fileWriter, 8192 * 4)) {
+ public static void appendSetToFile(File file, Set content) throws IOException {
+ if (file == null || content == null) {
+ throw new NullPointerException("File or content set cannot be null.");
+ }
+
+ try (BufferedWriter writer = new BufferedWriter(
+ new OutputStreamWriter(new FileOutputStream(file, true), StandardCharsets.US_ASCII), 8192 * 4)) {
for (String str : content) {
writer.write(str);
}
@@ -367,48 +375,62 @@ public static void appendSetToFile(File file, Set content) throws IOExce
}
/**
- * Append text to the existing file. It adds the text at the end of the content
- * of the file.
- *
- * @param file - existing file
- * @param cnfEncoding - cnf clauses that should be appended
- * @throws IOException in case of an I/O error
- * @throws NullPointerException if the file is null
+ * Appends CNFClause objects' CNF string representations to the existing file.
+ * Each CNF clause is added at the end of the content of the file.
+ *
+ * @param file The existing file.
+ * @param cnfEncoding The set of CNFClause objects to be appended.
+ * @throws IOException In case of an I/O error.
+ * @throws NullPointerException If the file or CNF encoding set is null.
*/
- public static void appendToFile(File file, Set cnfEncoding) throws IOException, NullPointerException {
- StringBuilder string = new StringBuilder();
- cnfEncoding.forEach(clause -> string.append(clause.toCNF()));
- Writer fileWriter = new FileWriterWithEncoding(file, "ASCII", true);
- try (BufferedWriter writer = new BufferedWriter(fileWriter, 8192 * 4)) {
- writer.write(string.toString());
+ public static void appendToFile(File file, Set cnfEncoding) throws IOException {
+ if (file == null || cnfEncoding == null) {
+ throw new NullPointerException("File or CNF encoding set cannot be null.");
}
+ StringBuilder stringBuilder = new StringBuilder();
+ cnfEncoding.forEach(clause -> stringBuilder.append(clause.toCNF()));
+
+ try (BufferedWriter writer = new BufferedWriter(
+ new OutputStreamWriter(new FileOutputStream(file, true), StandardCharsets.US_ASCII), 8192 * 4)) {
+ writer.write(stringBuilder.toString());
+ }
}
/**
- * Prepend text to the existing file content and create a new file out of it.
- * It adds the text at the beginning, before the existing content of the file.
- *
- * @param file
- * @param prefix
- * @throws IOException
+ * Prepends text to the existing file content and creates a new file with the
+ * modified content. It adds the text at the beginning, before the existing
+ * content of the file.
+ *
+ * @param prefix The text to be prepended.
+ * @param file The existing file.
+ * @return A new file with the prepended content.
+ * @throws IOException In case of an I/O error.
+ * @throws NullPointerException If the file or prefix is null.
*/
public static File prependToFile(String prefix, File file) throws IOException {
- LineIterator li = FileUtils.lineIterator(file);
+ if (file == null || prefix == null) {
+ throw new NullPointerException("File or prefix cannot be null.");
+ }
+
File tempFile = File.createTempFile("prependPrefix", ".tmp");
tempFile.deleteOnExit();
- Writer fileWriter = new FileWriterWithEncoding(tempFile, "ASCII", true);
- BufferedWriter writer = new BufferedWriter(fileWriter);
- try {
+
+ try (LineIterator lineIterator = FileUtils.lineIterator(file, StandardCharsets.US_ASCII.name());
+ BufferedWriter writer = new BufferedWriter(
+ new OutputStreamWriter(new FileOutputStream(tempFile, true), StandardCharsets.US_ASCII))) {
+
+ // Write the prefix first.
writer.write(prefix);
- while (li.hasNext()) {
- writer.write(li.next());
- writer.write("\n");
+ writer.newLine();
+
+ // Append the existing file content.
+ while (lineIterator.hasNext()) {
+ writer.write(lineIterator.nextLine());
+ writer.newLine();
}
- } finally {
- writer.close();
- li.close();
}
+
return tempFile;
}
diff --git a/src/main/java/nl/uu/cs/ape/utils/APEUtils.java b/src/main/java/nl/uu/cs/ape/utils/APEUtils.java
index 447c6ecb..128b9786 100644
--- a/src/main/java/nl/uu/cs/ape/utils/APEUtils.java
+++ b/src/main/java/nl/uu/cs/ape/utils/APEUtils.java
@@ -120,7 +120,7 @@ public static List getListFromJson(JSONObject jsonObject, String key, Cla
Object tmp = jsonObject.get(key);
try {
if (tmp instanceof JSONArray) {
- jsonList = getListFromJsonList((JSONArray) tmp, clazz);
+ jsonList = getListFromJSONArray((JSONArray) tmp, clazz);
} else {
T element = (T) tmp;
jsonList.add(element);
@@ -138,6 +138,23 @@ public static List getListFromJson(JSONObject jsonObject, String key, Cla
}
}
+ /**
+ * The method return a list of {@link JSONObject} elements that correspond to
+ * the value of a given key in the given json object. If the key corresponds to
+ * a {@link JSONArray} all the elements are put in a {@link List}, otherwise if
+ * the key corresponds to a {@link JSONObject} list will contain only that
+ * object.
+ *
+ * @param jsonObject {@link JSONObject} that is being explored.
+ * @param key Key label that corresponds to the elements.
+ *
+ * @return List of elements that corresponds to the key. If the key does not
+ * exists returns empty list.
+ */
+ public static List getJSONListFromJson(JSONObject jsonObject, String key) {
+ return getListFromJson(jsonObject, key, JSONObject.class);
+ }
+
/**
* The method converts the {@link JSONArray} object to {@link List} of objects
* of the given structure.
@@ -148,7 +165,7 @@ public static List getListFromJson(JSONObject jsonObject, String key, Cla
* @return List of objects of type {@link T}.
*/
@SuppressWarnings("unchecked")
- public static List getListFromJsonList(JSONArray jsonArray, Class clazz) {
+ public static List getListFromJSONArray(JSONArray jsonArray, Class clazz) {
List newList = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
T element = (T) jsonArray.get(i);
@@ -157,6 +174,17 @@ public static List getListFromJsonList(JSONArray jsonArray, Class claz
return newList;
}
+ /**
+ * The method converts the {@link JSONArray} object to {@link List} of
+ * {@link JSONObject} objects.
+ *
+ * @param jsonArray JSON array object.
+ * @return List of {@link JSONObject} objects.
+ */
+ public static List getJSONListFromJSONArray(JSONArray jsonArray) {
+ return getListFromJSONArray(jsonArray, JSONObject.class);
+ }
+
/**
* Debug printout.
*
@@ -567,7 +595,7 @@ public static void enableErr() {
/**
* Clone the given JSON object
*
- * @param original - original JSON object
+ * @param original original JSON object
* @return copy of the original JSONObject.
*/
public static JSONObject clone(JSONObject original) {
@@ -577,7 +605,7 @@ public static JSONObject clone(JSONObject original) {
/**
* Count the number of lines in a file.
*
- * @param cnfEncoding - file to count lines
+ * @param cnfEncoding file to count lines
* @return number of lines
*/
public static int countLines(File cnfEncoding) {
@@ -597,7 +625,7 @@ public static int countLines(File cnfEncoding) {
* Visualises in the command line the memory status of the VM at the given step,
* if debug mode is on.
*
- * @param debugMode - true if debug mode is on
+ * @param debugMode true if debug mode is on
*/
public static void printMemoryStatus(boolean debugMode) {
if (!debugMode) {
@@ -619,23 +647,23 @@ public static void printMemoryStatus(boolean debugMode) {
/**
* Get all unique pairs of PredicateLabels within the collection.
*
- * @param set - Set of PredicateLabel that should be used to create the pairs
+ * @param The type that extends PredicateLabel
+ * @param set Set of PredicateLabel that should be used to create the pairs
* @return Set of unique pairs.
*/
- public static Set> getUniquePairs(Collection extends PredicateLabel> set) {
- Set> pairs = new HashSet<>();
+ public static Set> getUniquePairs(Collection set) {
+ Set> pairs = new HashSet<>();
set.stream().forEach(ele1 -> set.stream().filter(ele2 -> ele1.compareTo(ele2) < 0)
.forEach(ele2 -> pairs.add(new Pair<>(ele1, ele2))));
return pairs;
-
}
/**
* Get unique pairs of elements within 2 collections.
*
- * @param set1 - Set of elements that should be used to create the first
+ * @param set1 Set of elements that should be used to create the first
* elements of the pairs
- * @param set2 - Set of elements that should be used to create the second
+ * @param set2 Set of elements that should be used to create the second
* elements of the pairs
* @return Set of unique pairs.
*/
@@ -645,4 +673,24 @@ public static Set> getUniquePairs(Collection set1, Collection
return pairs;
}
+ /**
+ * Generates a list of distinct pairs of integers where the first element is
+ * smaller than the second.
+ * Each pair is generated up to the specified maximum number (exclusive).
+ *
+ * @param maxNumber The exclusive upper bound for generating pairs.
+ * @return List of distinct pairs of integers.
+ */
+ public static List> generateDistinctPairs(int maxNumber) {
+ List> distinctPairs = new ArrayList<>();
+
+ for (int first = 0; first < maxNumber - 1; first++) {
+ for (int second = first + 1; second < maxNumber; second++) {
+ distinctPairs.add(new Pair<>(first, second));
+ }
+ }
+
+ return distinctPairs;
+ }
+
}
diff --git a/src/test/java/nl/uu/cs/ape/test/sat/ape/APEDomainSetupTest.java b/src/test/java/nl/uu/cs/ape/test/sat/ape/APEDomainSetupTest.java
new file mode 100644
index 00000000..0c7155b1
--- /dev/null
+++ b/src/test/java/nl/uu/cs/ape/test/sat/ape/APEDomainSetupTest.java
@@ -0,0 +1,47 @@
+package nl.uu.cs.ape.test.sat.ape;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.json.JSONObject;
+import org.junit.jupiter.api.Test;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+
+import nl.uu.cs.ape.APE;
+import nl.uu.cs.ape.domain.BioToolsAPI;
+import nl.uu.cs.ape.models.Module;
+import nl.uu.cs.ape.solver.solutionStructure.cwl.ToolCWLCreator;
+
+class APEDomainSetupTest {
+
+ @Test
+ void updateModuleFromJsonTest() throws IOException, OWLOntologyCreationException {
+ List toolIDs = List.of("Comet", "ape", "shic", "Jalview");
+ JSONObject toolAnnotationJson = BioToolsAPI.getAndConvertToolList(toolIDs);
+ for (int i = 0; i < toolIDs.size(); i++) {
+ String biotoolsID = toolIDs.get(i);
+ JSONObject toolJson = toolAnnotationJson.getJSONArray("functions").getJSONObject(i);
+
+
+ assertFalse(toolJson.isEmpty());
+ APE apeFramework = new APE(
+ "https://raw.githubusercontent.com/Workflomics/tools-and-domains/refs/heads/main/domains/bio.tools/config.json");
+
+ Module currModule = apeFramework.getDomainSetup()
+ .updateModuleFromJson(toolJson).get();
+
+ assertTrue(toolIDs.stream()
+ .map(String::toLowerCase)
+ .anyMatch(id -> id.equals(currModule.getPredicateLabel().toLowerCase())));
+
+ ToolCWLCreator toolCWLCreator = new ToolCWLCreator(currModule);
+ String cwlRepresentation = toolCWLCreator.generate();
+ assertFalse(cwlRepresentation.isEmpty());
+
+ }
+
+ }
+}
diff --git a/src/test/java/nl/uu/cs/ape/test/sat/ape/BioToolsAPITest.java b/src/test/java/nl/uu/cs/ape/test/sat/ape/BioToolsAPITest.java
new file mode 100644
index 00000000..2cdc37bf
--- /dev/null
+++ b/src/test/java/nl/uu/cs/ape/test/sat/ape/BioToolsAPITest.java
@@ -0,0 +1,86 @@
+package nl.uu.cs.ape.test.sat.ape;
+
+import nl.uu.cs.ape.domain.BioToolsAPI;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+class BioToolsAPITest {
+
+ private static File testFile;
+
+ @BeforeAll
+ static void setup() throws IOException {
+ // Create a temporary file with some sample tool IDs for testing.
+ testFile = File.createTempFile("testToolList", ".json");
+ testFile.deleteOnExit();
+ JSONArray sampleToolIDs = new JSONArray();
+ sampleToolIDs.put("comet");
+ sampleToolIDs.put("sage");
+ sampleToolIDs.put("proteinprophet");
+
+ Files.writeString(Path.of(testFile.getAbsolutePath()), sampleToolIDs.toString(4));
+ }
+
+ @Test
+ void testGetAndConvertToolListFromFile() throws IOException {
+ // Call the method and get the result
+ JSONObject result = BioToolsAPI.getAndConvertToolList(testFile);
+
+ // Assert the result is not null and check the number of tools
+ assertNotNull(result, "The result should not be null");
+ assertEquals(3, result.getJSONArray("functions").length(),
+ "The number of functions should match the input size");
+
+ System.out.println("Response: " + result.toString(4));
+ }
+
+ @Test
+ void testGetAndConvertToolListFromList() throws IOException {
+ // Create a list of tool IDs
+ List toolIDs = List.of("comet");
+
+ // Call the method and get the result
+ JSONObject result = BioToolsAPI.getAndConvertToolList(toolIDs);
+
+ // Assert the result is not null and check the number of tools
+ assertNotNull(result, "The result should not be null");
+ assertEquals(1, result.getJSONArray("functions").length(),
+ "The number of functions should match the input size");
+
+ // Check the content of the retrieved tool annotation
+ JSONObject comet = result.getJSONArray("functions").getJSONObject(0);
+ assertEquals("comet", comet.getString("biotoolsID"), "The biotoolsID should match the input");
+ assumeTrue(comet.getJSONArray("inputs").length() > 0, "The tool should have at least one input");
+ assumeTrue(comet.getJSONArray("outputs").length() > 0, "The tool should have at least one output");
+ assumeTrue(comet.getJSONArray("taxonomyOperations").length() > 0, "The tool should have at least one taxonomyOperation");
+
+
+ System.out.println("Response: " + result.toString(4));
+ }
+
+ @Test
+ void testGetToolsFromDomain() throws IOException {
+ String domainName = "proteomics";
+ JSONObject result = BioToolsAPI.getToolsFromDomain(domainName, false);
+
+ // Check that the result is not null and contains some tools
+ assertNotNull(result, "The result should not be null");
+ assertTrue(result.getJSONArray("functions").length() > 700, "There should be some functions in the result");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/nl/uu/cs/ape/test/sat/ape/CLITest.java b/src/test/java/nl/uu/cs/ape/test/sat/ape/CLITest.java
index 5a748a97..f09ca330 100644
--- a/src/test/java/nl/uu/cs/ape/test/sat/ape/CLITest.java
+++ b/src/test/java/nl/uu/cs/ape/test/sat/ape/CLITest.java
@@ -19,10 +19,10 @@
import java.util.Objects;
-public class CLITest {
+class CLITest {
@Test
- public void GMTFromCLITest() throws IOException {
+ void GMTFromCLITest() throws IOException {
run(
"cli/gmt/base_config.json",
"cli/gmt/GMT_UseCase_taxonomy.owl",
@@ -34,7 +34,7 @@ public void GMTFromCLITest() throws IOException {
// add files to 'src/test/resources/' folder and add the relative paths here
//@Test
- public void templateTest() throws IOException {
+ void templateTest() throws IOException {
run(
"relative/path/base_config.json",
"relative/path/ontology.owl",
@@ -44,7 +44,7 @@ public void templateTest() throws IOException {
);
}
- public void run(String base_config_path, String ontology_path, String tools_path, String constraints_path, String solution_dir_path) throws IOException {
+ void run(String base_config_path, String ontology_path, String tools_path, String constraints_path, String solution_dir_path) throws IOException {
// absolute solution_dir_path
final Path solution_path = Paths.get(Objects.requireNonNull(TestResources.getAbsoluteResourcePath(solution_dir_path)));