use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowToolRepository in project irida by phac-nml.
the class ToolsListExporter method main.
public static void main(String[] args) throws IridaWorkflowNotFoundException, JsonGenerationException, JsonMappingException, IOException {
if (args.length != 1) {
throw new RuntimeException("Error: invalid number of arguments \n" + usage);
}
Path toolsListOutput = Paths.get(args[0]);
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
Map<AnalysisType, IridaWorkflow> workflows = getDefaultWorkflows();
Set<IridaWorkflowToolRepository> uniqueToolRepositories = new HashSet<>();
Map<String, Object> yamlMap = Maps.newHashMap();
yamlMap.put("api_key", "<Galaxy Admin user API key>");
yamlMap.put("galaxy_instance", "<IP address for target Galaxy instance>");
List<Map<String, String>> tools = Lists.newArrayList();
yamlMap.put("tools", tools);
List<IridaWorkflow> workflowsSorted = workflows.values().stream().sorted(new Comparator<IridaWorkflow>() {
@Override
public int compare(IridaWorkflow o1, IridaWorkflow o2) {
return o1.getWorkflowDescription().getName().compareTo(o2.getWorkflowDescription().getName());
}
}).collect(Collectors.toList());
for (IridaWorkflow workflow : workflowsSorted) {
logger.info("Adding tools for workflow " + workflow);
String workflowName = workflow.getWorkflowDescription().getName();
String workflowVersion = workflow.getWorkflowDescription().getVersion();
tools.add(ImmutableMap.of(toolsSectionName, "### Tools for " + workflowName + " v" + workflowVersion + " ###"));
for (IridaWorkflowToolRepository toolRepository : workflow.getWorkflowDescription().getToolRepositories()) {
// Append trailing '/' to URL, so it becomes for example
// http://example.com/galaxy-shed/
// This is because other software (e.g. bioblend) assume a
// Galaxy toolshed URL ends with a '/'
// Otherwise, the end component of the path is stripped (e.g.,
// becomes http://example.com)
String toolRepositoryURLString = toolRepository.getUrl().toString();
if (!toolRepositoryURLString.endsWith("/")) {
toolRepositoryURLString += "/";
}
if (uniqueToolRepositories.contains(toolRepository)) {
logger.info("Tool defined by " + toolRepository + " already exists, skipping ...");
} else {
uniqueToolRepositories.add(toolRepository);
// @formatter:off
tools.add(ImmutableMap.<String, String>builder().put("name", toolRepository.getName()).put("owner", toolRepository.getOwner()).put("tool_shed_url", toolRepositoryURLString).put("revision", toolRepository.getRevision()).put("tool_panel_section_id", defaultToolPanelId).build());
// @formatter:on
}
}
}
// Bit of a hack, but does the job. Wanted to add a comment in the YAML
// file for each tool section for readability but no YAML library
// supports this. Instead, I do some pattern substitute/replace on a
// special String variable "toolsSectionName" to generate the comments.
String yaml = replaceAllWithCaptureGroup1(mapper.writeValueAsString(yamlMap), regexPattern, "\n ", "\n");
if (yaml.matches(toolsSectionName)) {
throw new RuntimeException("Error: not all instances of \"" + toolsSectionName + "\" were replaced");
}
PrintWriter outputFileWriter = new PrintWriter(toolsListOutput.toFile());
outputFileWriter.print(yaml);
outputFileWriter.close();
logger.info("Wrote tools list to: " + toolsListOutput.toAbsolutePath());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowToolRepository in project irida by phac-nml.
the class IridaWorkflowTestBuilder method buildTestDescription.
/**
* Builds a {@link IridaWorkflowDescription} with the following information.
*
* @param id
* The id of the workflow.
* @param name
* The name of the workflow.
* @param version
* The version of the workflow.
* @param analysisType
* The {@link AnalysisType} of the workflow.
* @param reference
* The reference label for the workflow.
* @param requiresSingleSample
* Whether or not this workflow requires a single sample.
* @return An {@link IridaWorkflowDescription} with the given information.
* @throws MalformedURLException
*/
public static IridaWorkflowDescription buildTestDescription(UUID id, String name, String version, AnalysisType analysisType, Input input, String reference, boolean requiresSingleSample) throws MalformedURLException {
List<IridaWorkflowOutput> outputs = new LinkedList<>();
outputs.add(new IridaWorkflowOutput("output1", "output1.txt"));
outputs.add(new IridaWorkflowOutput("output2", "output2.txt"));
List<IridaWorkflowToolRepository> tools = new LinkedList<>();
IridaWorkflowToolRepository workflowTool = new IridaWorkflowToolRepository("sam_to_bam", "devteam", new URL("http://toolshed.g2.bx.psu.edu/"), "8176b2575aa1");
tools.add(workflowTool);
IridaWorkflowInput workflowInput = null;
switch(input) {
case SINGLE:
workflowInput = new IridaWorkflowInput("sequence_reads", null, reference, requiresSingleSample);
break;
case PAIRED:
workflowInput = new IridaWorkflowInput(null, "sequence_reads_paired", reference, requiresSingleSample);
break;
case SINGLE_PAIRED:
workflowInput = new IridaWorkflowInput("sequence_reads", "sequence_reads_paired", reference, requiresSingleSample);
break;
}
List<IridaWorkflowParameter> parameters = new LinkedList<>();
IridaToolParameter tool1 = new IridaToolParameter("irida.corefacility.ca/galaxy-shed/repos/irida/test-tool/0.1", "a");
IridaToolParameter tool2 = new IridaToolParameter("irida.corefacility.ca/galaxy-shed/repos/irida/test-tool/0.1", "b");
IridaWorkflowParameter parameter1 = new IridaWorkflowParameter("test-parameter", "1", Lists.newArrayList(tool1, tool2));
parameters.add(parameter1);
IridaWorkflowDescription iridaWorkflow = new IridaWorkflowDescription(id, name, version, analysisType, workflowInput, outputs, tools, parameters);
return iridaWorkflow;
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowToolRepository in project irida by phac-nml.
the class TestDataFactory method getIridaWorkflow.
public static IridaWorkflow getIridaWorkflow(UUID id) {
IridaWorkflowInput input = new IridaWorkflowInput();
List<IridaWorkflowOutput> outputs = ImmutableList.of(new IridaWorkflowOutput());
List<IridaWorkflowToolRepository> tools = ImmutableList.of();
List<IridaWorkflowParameter> parameters = ImmutableList.of();
IridaWorkflowDescription description = new IridaWorkflowDescription(id, "My Workflow", "V1", AnalysisType.DEFAULT, input, outputs, tools, parameters);
IridaWorkflowStructure structure = new IridaWorkflowStructure(null);
return new IridaWorkflow(description, structure);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowToolRepository in project irida by phac-nml.
the class IridaWorkflowLoaderServiceIT method buildTestDescription.
private IridaWorkflowDescription buildTestDescription(UUID id, String name, String version, String sequenceReadsSingle, String sequenceReadsPaired, boolean requiresSingleSample) throws MalformedURLException {
List<IridaWorkflowOutput> outputs = new LinkedList<>();
outputs.add(new IridaWorkflowOutput("output1", "output1.txt"));
outputs.add(new IridaWorkflowOutput("output2", "output2.txt"));
List<IridaWorkflowToolRepository> tools = new LinkedList<>();
IridaWorkflowToolRepository workflowTool = new IridaWorkflowToolRepository("sam_to_bam", "devteam", new URL("http://toolshed.g2.bx.psu.edu/"), "8176b2575aa1");
tools.add(workflowTool);
List<IridaWorkflowParameter> parameters = new LinkedList<>();
IridaToolParameter tool1 = new IridaToolParameter("irida.corefacility.ca/galaxy-shed/repos/irida/test-tool/0.1", "a");
IridaToolParameter tool2 = new IridaToolParameter("irida.corefacility.ca/galaxy-shed/repos/irida/test-tool/0.1", "b");
IridaWorkflowParameter parameter1 = new IridaWorkflowParameter("test-parameter", "1", Lists.newArrayList(tool1, tool2));
parameters.add(parameter1);
IridaWorkflowDescription iridaWorkflow = new IridaWorkflowDescription(id, name, version, AnalysisType.DEFAULT, new IridaWorkflowInput(sequenceReadsSingle, sequenceReadsPaired, "reference", requiresSingleSample), outputs, tools, parameters);
return iridaWorkflow;
}
Aggregations