name: filter_with_pattern
namespace: "filter"
scope: "public"
description: |
  Filter a MuData object based on gene names using a regex.
authors:
  - __merge__: /src/authors/dorien_roosen.yaml
    roles: [ author ]

argument_groups:
  - name: Inputs
    arguments:
      - name: "--input"
        type: file
        description: Input h5mu file
        direction: input
        required: true
        example: input.h5mu
      - name: "--modality"
        description: |
          Which modality from the input MuData file to process.
        type: string
        default: "rna"
      - name: "--var_gene_names"
        type: string
        description: |
          The .var field containing the gene names to be filtered. If not provided, `.var.index` will be used.
        example: "gene_symbol"
        required: false
      - name: "--pattern"
        required: true
        type: string
        multiple: true
        example: ["MIR\\d+", "AL\\d+", "LINC\\d+", "AC\\d+", "AP\\d+"]
        description: |
          A regex pattern to filter the gene names.
  - name: Outputs
    arguments:
      - name: "--output"
        type: file
        description: Output h5mu file.
        direction: output
        example: output.h5mu
      - name: "--do_subset"
        type: boolean_true
        description: Whether to subset before storing the output.
      - name: "--var_name_filter"
        type: string
        default: "filter_with_pattern"
        description: In which .var slot to store a boolean array corresponding to which variables should be removed.
    __merge__: [., /src/base/h5_compression_argument.yaml]

resources:
  - type: python_script
    path: script.py
  - path: /src/utils/setup_logger.py
  - path: /src/utils/compress_h5mu.py
test_resources:
  - type: python_script
    path: test.py
  - path: /resources_test/pbmc_1k_protein_v3

engines:
- type: docker
  image: python:3.12-slim
  setup:
    - type: apt
      packages: 
        - procps
    - type: python
      __merge__: /src/base/requirements/anndata_mudata.yaml
  test_setup:
    - type: python
      __merge__: [ /src/base/requirements/viashpy.yaml, .]

runners:
- type: executable
- type: nextflow
  directives:
    label: [lowcpu, midmem]