Skip to content

OpenVariant Bug |mapping filename declaration should accept full path #55

@FedericaBrando

Description

@FedericaBrando

Describe the issue

When we use a metadata.yaml with a mapping file it expects it to be relative to the yaml. This is potentially a problem if we need to run the tool where the mapping is in a directory while the yaml is in another.

Steps to reproduce the bug

  • mutations files in a folder
  • yaml and mapping file in another.

example:

  - type: "mapping"
    field: "CANCER"
    fieldSource:
    - "SAMPLE"
    fileMapping: metadata_intogen.tsv
    fieldMapping: sampleId
    fieldValue: ONCOTREE_CODE

If I run:

❯ singularity exec docker.io-bbglab-openvariant-1.1.0.img \
    openvar groupby \
    -a metadata.yaml \
    vcf_without_headers \
    --header -g DATASET \
    -s 'gzip >  ${GROUP_KEY}.parsed.tsv.gz'

I get an error. (see below)

If I run:

❯ singularity exec docker.io-bbglab-openvariant-1.1.0.img \
    openvar groupby \
    -a ./metadata.yaml \
    vcf_without_headers \
    --header -g DATASET \
    -s 'gzip >  ${GROUP_KEY}.parsed.tsv.gz'

it correctly picks up the mapping file.

I would like to decouple the two.

Error encountered or actual result

❯ singularity exec -B /data/bbg  /data/bbg/projects/intogen_plus/containers/containers_25/docker.io-bbglab-openvariant-1.1.0.img openvar groupby /data/bbg/datasets/sjd_melos/xpc_cohort/vcf_data/2026_cohort_shared_paper/vcf_without_headers -a metadata.yaml  --header -g DATASET  -s 'gzip >  ${GROUP_KEY}.parsed.tsv.gz'
Traceback (most recent call last):
  File "/usr/local/bin/openvar", line 8, in <module>
    sys.exit(openvar())
             ~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.13/site-packages/openvariant/commands/openvar.py", line 86, in groupby
    for group_key, group_result, command in group_by_task(input_path, annotations, script, key_by=group_by, where=where,
                                            ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                          cores=cores, quite=quite, header=header, skip_files=skip):
                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/openvariant/tasks/groupby.py", line 154, in group_by
    selection = _group(base_path, annotation_path, key_by, skip_files)
  File "/usr/local/lib/python3.13/site-packages/openvariant/tasks/groupby.py", line 38, in _group
    for file, ann in findfiles(base_path, annotation_path):
                     ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/openvariant/find_files/find_files.py", line 96, in findfiles
    annotation, fix = (Annotation(annotation_path), True) if annotation_path is not None else (None, False)
                       ~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/openvariant/annotation/annotation.py", line 174, in __init__
    self._annotations[k[AnnotationKeys.FIELD.value]] = instance(k, self._path)
                                                       ~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/openvariant/annotation/builder.py", line 217, in __call__
    raise FileNotFoundError(f"Unable to find '{mapping_files}' file in '{dirname(base_path)}'")
FileNotFoundError: Unable to find 'metadata_intogen.tsv' file in ''

Expected result

Correctly picking up the mapping file given it's absolute path location

OpenVariant version

1.1.0

Python version

3.13

OS

Ubuntu

Installation method

uv

Environment

Singularity container

Other commentaries (optional)

A way to solve the issue is to let the user insert the full path and not only the filename.

Contact details (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions