Skip to content

Allow multiple file endings for a FileType [490] #490

Closed

Description

@timosachsenberg

Submitted by aiche on 2012-11-27 11:00:09

Currently we have a 1:1 mapping between file type and file endings (except some special cases), but for some file types more then one file ending is regularly used (e.g., csv vs tsv or fasta and fa).

The question is how this should be handled by OpenMS.

  1. introduce a 1:N mapping
  2. register the different endings as individual file types

both solutions have their individual downsides. The 1:N mapping for instance would make CSV and TSV completely equal, which is not always the case. Introducing a new file type for each ending would make the code more complex since we need to handle more types.

Activity

  1. jpfeuffer commented on Nov 5, 2016

    @jpfeuffer
    Contributor

    Do we support this by now?

  2. timosachsenberg commented on Nov 6, 2016

    @timosachsenberg
    ContributorAuthor

    If we introduced support for multiple file endings, would KNIME and GKN work properly with them?

  3. timosachsenberg commented on Sep 5, 2026

    @timosachsenberg
    ContributorAuthor

    This is still only partially implemented in current develop. We have special cases for .pep.xml, .prot.xml and .pqt, but no central alias list. File-dialog filters still use the canonical extension, and TOPPAS checks literal suffixes. See FileTypes.cpp, FileHandler.cpp and TOPPASEdge.cpp.

    I suggest keeping one FileTypes::Type per format, with one preferred extension and a list of accepted aliases. CSV and TSV remain separate types; having multiple extensions does not imply merging different formats.

    • Add a central extension registry. Extend the existing type annotations with aliases and expose an API such as FileTypes::typeToExtensions(Type), returning the preferred extension first. Keep enum values and typeToName() results unchanged. Make nameToType() recognize aliases case-insensitively. Start with fasta/fa/faa, pepXML/pep.xml, protXML/prot.xml and parquet/pqt. Reject duplicate aliases across types; do not make ambiguous suffixes such as generic .xml aliases for specific XML formats.

    • Use the registry for filename handling. Replace the scattered extension special cases with a shared matcher that checks dot-delimited suffixes on the basename and chooses the longest match, so .pep.xml wins over .xml. Preserve xquest.xml/spec.xml, extensionless fid, directory formats and existing .gz/.bz2/.zip handling. Filename-only detection must remain usable for output files that do not exist. Keep content detection as a separate fallback for inputs. Return the matched suffix span so stripExtension() and swapExtension() remove the actual extension, including compound and compression suffixes, instead of searching the path for the canonical type name.

    • Apply aliases consistently during validation. Use the shared matching logic in TOPPBase and TOPPAS, including file lists and tool-to-tool connections. Compare recognized formats by type. Preserve explicitly declared custom extensions and wildcard behavior; two unrecognized strings must not become equivalent just because both map to UNKNOWN. Keep unknown-format handling explicit for each caller. Compression suffixes must not by themselves imply compatibility with every input type, and recognizing a compressed filename must not advertise decompression support that a reader lacks.

    • Include aliases in filters and parameter metadata. Generate GUI patterns such as FASTA file (*.fasta *.fa *.faa) and expand supported file formats for single-file and file-list parameters in INI/CTD metadata. Deduplicate patterns and keep their order stable. Keep preferred output suffixes and canonical format choices in in_type/out_type unchanged. Check save-dialog filter-to-type round trips and preserve explicitly chosen valid output aliases.

    • Add regression coverage. Cover canonical names and aliases, mixed case, compound-suffix precedence, existing compressed-name behavior, dotted directories/stems, extension stripping/swapping, and unchanged handling of custom/unknown formats. Add integration checks for CLI single-file/list validation, TOPPAS connections, GUI filters and exported metadata. Verify that genuine mismatches still fail and CSV/TSV remain distinct.

    Suggested split: one PR for the registry and filename helpers, followed by a PR for validation, GUI and workflow integration. The issue is complete when aliases work consistently across these paths while existing canonical names and output defaults remain compatible.


    Status: boxes 1–4 are done and merged — #10188 (registry and filename helpers) and #10191 (validation, filters, CTD metadata).

    Regression coverage is left unticked because one item in it is genuinely outstanding. Unit coverage is in place (aliases, mixed case, compound-suffix precedence, compressed names, dotted directories/stems, stripping/swapping, custom/unknown formats, CSV≠TSV), as are integration checks for CLI validation (TOPP_SimpleSearchEngine_3_fasta_alias and _4_wrong_format), GUI filters (exact filter strings plus the filter-to-type round trip) and exported metadata. TOPPAS connections have no automated test: the repository has no TOPPAS test harness to hook into, so TOPPASEdge's wiring is covered only indirectly through unit tests of the helpers it calls (FileTypes::sameFormat, supportsCompressedReading, FileNameUtils::compressionType). Building that harness is a separate piece of work.

    Two things found along the way that are worth recording:

    • stripExtension("fid.gz") used to throw Exception::IndexOverflow on develop — it located the canonical name fid at offset 0 and computed prefix(filename, pos - 1), underflowing. Fixed in Support file type aliases and improve extension matching #10188.
    • -out db.peff.gz is still accepted for non-XML outputs, which then write uncompressed bytes under a compressed name; UniPEFF rejects it itself today. XML outputs are unaffected, since XMLFile::save_ genuinely compresses by suffix. Closing this needs a write-side counterpart to COMPRESSED_READABLE and is outside this issue's scope.

    Generated by Claude Code

  4. timosachsenberg commented on Sep 21, 2026

    @timosachsenberg
    ContributorAuthor

    Resolved on develop (verified @ c5403a8).

    A FileType can now carry several extensions: TypeNameBinding in src/openms/source/FORMAT/FileTypes.cpp has an aliases list (:32-34), with the rule that the preferred extension is what typeToName() returns and what gets written, while aliases are only accepted on input and must be unambiguous across types (FileTypes_test enforces uniqueness).

    Landed via 70ee9b8 ("Support file type aliases and improve extension matching", #10188) and 3f80b00 ("Honour file type aliases in validation, filters and CTD metadata (#490)", #10191).

    Proposing to close.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OpenMS - libraryenhancementmajor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions