qiime2 / galaxy-tools

Official QIIME 2 tools for Galaxy
BSD 3-Clause "New" or "Revised" License
1 stars 4 forks source link

Import: set file name automatically #50

Open bernt-matthias opened 8 months ago

bernt-matthias commented 8 months ago

Would it be possible to set the name argument, e.g. over here [https://github.com/qiime2/galaxy-tools/blob/65e4952f33eb335528e8553150e9097e5ea8f556/tools/suite_qiime2_core__tools/qiime2_core__tools__import.xml#L245C78-L245C78] automatically based on the corresponding data parameter?

In Galaxy you could use data.element_identifier. This would be equal to data.name for normal datasets, but different for collection elements (where element_identfier is the name of the collection element).

Edit: Maybe use the element identifier in case if name is left empty (which leads currently to an error).

Edit: So, the actual problem is that we see the following error if the name is something different than the name of the dataset. When running the tool manually that is "no problem" (but still a bit inconvenient and redundant), but when running in a workflow we do not know the name of the dataset...

Traceback (most recent call last):
  File "/opt/conda/envs/qiime2-2023.5/bin/q2galaxy", line 11, in <module>
    sys.exit(root())
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/q2galaxy/__main__.py", line 96, in run
    builtin_runner(action, config)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/q2galaxy/core/drivers/builtins.py", line 24, in builtin_runner
    tool(inputs, stdio=stdio)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/q2galaxy/core/drivers/builtins.py", line 43, in import_data
    artifact = _import_name_data(type_, format_, files_to_move,
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/q2galaxy/core/drivers/stdio.py", line 38, in wrapped
    return function(*args, **kwargs)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/q2galaxy/core/drivers/builtins.py", line 85, in _import_name_data
    return qiime2.Artifact.import_data(type_, dir_, view_type=format_)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/qiime2/sdk/result.py", line 327, in import_data
    return cls._from_view(type_, view, view_type, provenance_capture,
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/qiime2/sdk/result.py", line 355, in _from_view
    result = transformation(view, validate_level)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/qiime2/core/transform.py", line 68, in transformation
    self.validate(view, level=validate_level)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/qiime2/core/transform.py", line 143, in validate
    view.validate(level)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/qiime2/plugin/model/directory_format.py", line 177, in validate
    getattr(self, field)._validate_members(collected_paths, level)
  File "/opt/conda/envs/qiime2-2023.5/lib/python3.8/site-packages/qiime2/plugin/model/directory_format.py", line 109, in _validate_members
    raise ValidationError(
qiime2.core.exceptions.ValidationError: Missing one or more files for EMPSingleEndDirFmt: 'sequences.fastq.gz'
ebolyen commented 1 month ago

I'm going to look into this for the next release. I think name is just something that shouldn't be there. I think this may have been a workaround for regex-based paths, where there is some variable prefix (like in reference indices/databases).