Detect the file type from its extension and/or content, then dispatch to the appropriate parser.
Details
Extension mapping:
.vcf,.vcf.gz:mp_read_vcf.fastq,.fq,.fastq.gz,.fq.gz:mp_read_fastq.bam:mp_read_bam.xml:mp_read_xml_report.pdf:mp_read_pdf_report.xlsx,.xls,.csv: tries survival/clinical format detection
Examples
files <- mp_example_files(file.path(tempdir(), "molpathR-example"))
mp_read_auto(files$vcf[1])
#> ℹ Auto-detected file type: "vcf"
#>
#> ── molpath_parsed ──────────────────────────────────────────────────────────────
#> ℹ Source type: "vcf"
#> ℹ Source file: /tmp/RtmpYMvdo5/molpathR-example/vcf/SAM-2024-0001.vcf
#> ℹ Parsed: "2026-11-22 05:43:52"
#> ℹ Data: 8 rows x 10 columns
#> ℹ Columns: chrom, pos, id, ref, alt, qual, filter, info, format, and SAM-2024-0001
#> ℹ Completeness: "100%"
mp_read_auto(files$survival)
#> ℹ Auto-detected file type: "tabular"
#> ℹ Reading survival data: survival.csv
#> ✔ Parsed 30 patient record(s) with survival data
#>
#> ── molpath_parsed ──────────────────────────────────────────────────────────────
#> ℹ Source type: "survival"
#> ℹ Source file: /tmp/RtmpYMvdo5/molpathR-example/survival.csv
#> ℹ Parsed: "2026-11-22 05:43:52"
#> ℹ Data: 30 rows x 5 columns
#> ℹ Columns: patient_id, os_months, os_status, pfs_months, and pfs_status
#> ℹ Completeness: "100%"