1 package jalview.ext.cipres;
3 import java.util.Collection;
4 import java.util.HashMap;
7 import org.ngbw.directclient.CiApplication;
8 import org.ngbw.directclient.CiCipresException;
9 import org.ngbw.directclient.CiClient;
10 import org.ngbw.restdatatypes.ErrorData;
11 import org.ngbw.restdatatypes.ParamError;
16 private final CiClient cipresClient;
18 private final CiApplication app = CiApplication.getInstance();
20 private Map<String, Collection<String>> vParams = new HashMap<>();
22 private Map<String, String> inputParams = new HashMap<>();
24 private Map<String, String> metadata = new HashMap<>();
28 cipresClient = new CiClient(
29 app.getAppKey(), app.getUsername(), app.getPassword(),
35 public TreeJob(String alignmentFilePath)
37 cipresClient = new CiClient(
38 app.getAppKey(), app.getUsername(), app.getPassword(),
41 inputParams.put("infile_", alignmentFilePath);
47 * Specifies a parameter about the input data for a CIPRES job with its value,
48 * for example the "infile_" parameter for the MSA file to calculate a tree
49 * from with file path as value. Note that different tools support different
55 public void addInputParameter(String parameter, String value)
57 inputParams.put(parameter, value);
62 * Adds a CIPRES tool parameter that specifies job behaviour, for example
63 * "runtime_" with the maximum runtime (in hours) as value.
68 public void addToolParameters(String parameter, Collection<String> values)
70 vParams.put(parameter, values);
74 * Adds a metadata tag to the job, for example "clientJobName" with the name
75 * that this job should be referred by as value. CIPRES highly recommends all
76 * jobs are given a clientJobId metadata header.
78 * @param metadataHeader
81 public void addMetadata(String metadataHeader, String value)
83 metadata.put(metadataHeader, value);
86 public void clearAllParameters()
93 public void clearInputParameters()
98 public void clearToolsParameters()
103 public void clearMetadata()
109 * Sends this job with all given parameters to the given Cipres tool but
110 * doesn't actually run the job. This is a lightweight way to validate that
111 * the given parameters are correct for a specified tool.
113 public void validateJobParams(String toolName)
117 cipresClient.validateJob(toolName, vParams, inputParams, metadata);
118 } catch (CiCipresException ce)
120 ErrorData ed = ce.getErrorData();
122 "Cipres error while trying to validate parameters, code="
123 + ed.code + ", message="
126 if (ed.code == ErrorData.FORM_VALIDATION)
128 for (ParamError pe : ed.paramError)
130 System.out.println(pe.param + ": " + pe.error);