| 31 | |
| 32 | |
| 33 | class NextflowGenerator: |
| 34 | |
| 35 | def __init__(self, process_connections, nextflow_file, process_map, |
| 36 | pipeline_name="flowcraft", ignore_dependencies=False, |
| 37 | auto_dependency=True, merge_params=True, export_params=False): |
| 38 | |
| 39 | self.processes = [] |
| 40 | |
| 41 | self.process_map = process_map |
| 42 | """ |
| 43 | dict: Maps the nextflow template name to the corresponding Process |
| 44 | class of the component. |
| 45 | """ |
| 46 | |
| 47 | # Create the processes attribute with the first special init process. |
| 48 | # This process will handle the forks of the raw input channels and |
| 49 | # secondary inputs |
| 50 | self.processes = [pc.Init(template="init")] |
| 51 | """ |
| 52 | list: Stores the process interfaces in the specified order |
| 53 | """ |
| 54 | |
| 55 | self._fork_tree = defaultdict(list) |
| 56 | """ |
| 57 | dict: A dictionary with the fork tree of the pipeline, which consists |
| 58 | on the the paths of each lane. For instance, a single fork with two |
| 59 | sinks is represented as: {1: [2,3]}. Subsequent forks are then added |
| 60 | sequentially: {1:[2,3], 2:[3,4,5]}. This allows the path upstream |
| 61 | of a process in a given lane to be traversed until the start of the |
| 62 | pipeline. |
| 63 | """ |
| 64 | |
| 65 | self.lanes = 0 |
| 66 | """ |
| 67 | int: Stores the number of lanes in the pipelines |
| 68 | """ |
| 69 | |
| 70 | self.export_parameters = export_params |
| 71 | """ |
| 72 | bool: Determines whether the build mode is only for the export of |
| 73 | parameters in JSON format. Setting to True will disabled some checks, |
| 74 | such as component dependency requirements |
| 75 | """ |
| 76 | |
| 77 | # When the export_params option is used, disable the auto dependency |
| 78 | # feature automatically |
| 79 | auto_deps = auto_dependency if not self.export_parameters else False |
| 80 | |
| 81 | # Builds the connections in the processes, which parses the |
| 82 | # process_connections dictionary into the self.processes attribute |
| 83 | # list. |
| 84 | self._build_connections(process_connections, ignore_dependencies, |
| 85 | auto_deps) |
| 86 | |
| 87 | self.nf_file = nextflow_file |
| 88 | """ |
| 89 | str: Path to file where the pipeline will be generated |
| 90 | """ |