def _set_meta_from_biotool(self, biotool): """ Add first set of metadata found on bio.tools to the description. :param biotool: Biotool object of an entry from https://bio.tools. :type biotool: :class:`tooldog.biotool_model.Biotool` """ self.tool.metadata = cwlgen.Metadata() self.tool.metadata.name = biotool.name self.tool.metadata.about = biotool.description self.tool.metadata.url = biotool.homepage if biotool.informations.language: self.tool.metadata.programmingLanguage = biotool.informations.language
def generate_cwl(cls): """ Produces a CWL App object which can then be exported to yaml """ import cwlgen module = cls.get_module() # Basic definition of the tool cwl_tool = cwlgen.CommandLineTool(tool_id=cls.name, label=cls.name, base_command=f'python3 -m {module}') #TODO: Add documentation in ceci elements cwl_tool.doc = "Pipeline element from ceci" # Add the inputs of the tool for i,inp in enumerate(cls.input_tags()): input_binding = cwlgen.CommandLineBinding(position=(i+1)) input_param = cwlgen.CommandInputParameter(inp, param_type='File', input_binding=input_binding, doc='Some documentation about the input') cwl_tool.inputs.append(input_param) # Add the definition of the outputs for i,out in enumerate(cls.output_tags()): output_binding = cwlgen.CommandOutputBinding(glob=out) output = cwlgen.CommandOutputParameter(out, param_type='File', output_binding=output_binding, param_format='http://edamontology.org/format_2330', doc='Some results produced by the pipeline element') cwl_tool.outputs.append(output) # Potentially add more metadata metadata = {'name': cls.name, 'about': 'I let you guess', 'publication': [{'id': 'one_doi'}, {'id': 'another_doi'}], 'license': ['MIT']} cwl_tool.metadata = cwlgen.Metadata(**metadata) return cwl_tool
def createStep(cwl_tool, cwl_tool_docker, implementation_file_binding, cases_file_binding, type, doc, input_doc, extension, output_doc, language="knime"): cwl_tool.namespaces.s = "http://phenomics.kcl.ac.uk/phenoflow/" metadata = {'type': type} cwl_tool.metadata = cwlgen.Metadata(**metadata) cwl_tool.doc = doc # Assume run in Docker cwl_tool.requirements.append(cwl_tool_docker) implementation_input_file = cwlgen.CommandInputParameter( "inputModule", param_type='File', input_binding=implementation_file_binding, doc=language[0].upper() + language[1:] + " implementation unit") cwl_tool.inputs.append(implementation_input_file) if ("external" not in type): data_input_file = cwlgen.CommandInputParameter( "potentialCases", param_type='File', input_binding=cases_file_binding, doc=input_doc) cwl_tool.inputs.append(data_input_file) workflow_output_binding = cwlgen.CommandOutputBinding(glob="*." + extension) output = cwlgen.CommandOutputParameter( 'output', doc=output_doc, param_type="File", output_binding=workflow_output_binding) cwl_tool.outputs.append(output) return cwl_tool
cwl_tool.inputs.append(input_file) pattern_binding = cwlgen.CommandLineBinding(position=1) pattern = cwlgen.CommandInputParameter( 'pattern', param_type='string', input_binding=pattern_binding, doc='pattern to find in the input file') cwl_tool.inputs.append(pattern) # Add 1 output output = cwlgen.CommandOutputParameter('output', param_type='stdout', doc='lines found with the pattern') cwl_tool.outputs.append(output) cwl_tool.stdout = "grep.txt" # Add documentation cwl_tool.doc = "grep searches for a pattern in a file." # Add Metadata metadata = { 'name': 'grep', 'about': 'grep searches for a pattern in a file.' } cwl_tool.metadata = cwlgen.Metadata(**metadata) cwl_tool.metadata = cwlgen.Metadata(**metadata) # Write in an output file cwl_tool.export() # cwl_tool.export("grep.cwl")
cores = cwlgen.CommandInputParameter('no_of_cores', param_type='int', input_binding=core_binding, doc='choose 2, 3, 4') west_tool.inputs.append(cores) # Add 1 output with type to fetch output_bind = cwlgen.CommandOutputBinding(glob="*.out") output = cwlgen.CommandOutputParameter( 'west_output_file', param_type='File', output_binding=output_bind, doc='Output File generated with west pw.x or wstat.x code') west_tool.outputs.append(output) # Add documentation west_tool.doc = "Runs west code for different input paramaters" # Add Metadata metadata = { 'name': 'West', 'about': 'West code runs pw for an input pw.in file to generate pw.out, or wstat for wstat.in with wstat.out file' } west_tool.metadata = cwlgen.Metadata(**metadata) west_tool.metadata = cwlgen.Metadata(**metadata) # Write in an output file west_tool.export("west.cwl")