Command-Line Interface
Convert-Pheno includes a command-line utility for file-based conversions. This is the primary way most users work with the project.
The CLI is organized around one input format, one output format, and optional controls for BFF entities, mapping files, ontology search, streaming, and source provenance.
Command Modelβ
Every command has three parts:
| Part | Meaning | Example |
|---|---|---|
| Input | What format is being read | -ipxf phenopacket.json |
| Output | What format is being written | -obff individuals.json |
| Options | Extra behavior | --entities individuals biosamples --out-dir out/ |
The most important distinction is BFF output mode:
-obff FILEwrites oneindividualsfile.-obff --entities ... --out-dir DIRwrites one file per requested BFF entity.
Detailed CLI reference
Basic patternβ
The command is organized around one input format and one output format:
convert-pheno -i <input-type> <infile> -o <output-type> <outfile> [options]
Both CLI styles are supported:
- Generic form:
-i pxf ... -o bff ... - Compact form:
-ipxf ... -obff ...
The compact flags are still the ones most users rely on:
-ipxf,-ibff,-icbioportal,-iomop,-iopenehr,-iredcap,-icdisc-odm,-idataset-json,-idataset-xml,-ifhir,-icsv-obff,-opxf,-oomop,-ocsv,-ojsonf,-ojsonld
cBioPortal clinical packages, openEHR canonical input, CDISC Dataset-JSON and
Dataset-XML SDTM input, and FHIR R4 Bundle input are implemented but marked experimental while independent source coverage
grows. Standard/OpenClinica CDISC-ODM and the bounded ODM 2.0 ClinicalData
profile are also experimental beyond the established REDCap ODM workflow.
Dataset-JSON, Dataset-XML, and FHIR can write BFF, PXF, or OMOP-CDM; openEHR
currently writes BFF or PXF.
You can always check the current built-in help with:
convert-pheno --help
BFF output modesβ
BFF output has two explicit CLI forms:
individuals-only BFF output:-obff FILE- Entity-aware output:
-obff --entities ... --out-dir DIR
In other words, --entities does not replace -obff. It refines which BFF entities are written after you have already selected BFF as the output format.
Notesβ
-obffkeeps the individuals-onlyBFFbehavior.BFFentity mode is also explicit: use-obff --entities ... --out-dir DIR.- When
PXFinput containsbiosamples, the individuals-only-obff FILEpath still writes onlyindividuals. In that mode,convert-phenowarns and preserves the biosamples underinfo.phenopacket.biosamples. --entitiescan be used withBFFoutput. The supported output entities areindividuals,biosamples,datasets, andcohorts.biosamplesare emitted from PXF biosample data, cBioPortal sample clinical tables, FHIRSpecimen, OMOPSPECIMEN, or explicitbeacon.biosamples.rulesin mapping-file routes.datasetsandcohortsare synthesized from the normalizedindividualscollection.- In mapping-file conversions,
beacon.biosamplesdefines first-class biosample rules, whilebeacon.datasets.defaultsandbeacon.cohorts.defaultsoverride synthesized metadata. - These mapping features are available for
csv2bff,redcap2bff, andcdiscodm2bff; cBioPortal accepts the same Mapping V2 structure optionally to augment its built-in patient and sample mapping. --entitiesnarrowsBFFoutput. It must be combined with-obffand--out-dir.--out-name key=filelets you override one multi-file output name. Use entity keys forBFFentity mode and table keys forOMOPoutput.--no-source-infoomits raw source provenance copied intoBFFinfo, such asOMOP_columns,CSV_columns,REDCap_columns,CDISC_ODM,cbioportal,datasetJson.domains,datasetXml.domains, andfhirresources. Mapped fields andinfo.convertPhenoare kept.--term-audit FILEwrites a TSV, compressed TSV, or color-coded XLSX audit of direct terms, identifier lookups, label searches, and fallbacks, including retrieval paths, decision reasons, candidate scores, score margins, and provenance.--streamis mainly relevant for large OMOP inputs. Use--no-streamto force the default in-memory mode when a wrapper or previous option may have enabled streaming.
Important optionsβ
Mapping-file conversionsβ
--mapping-file FILEsupplies a Mapping V2 YAML or JSON document targeting Beacon schema2.0.0. It is required by CSV, REDCap, and CDISC-ODM routes; optional for cBioPortal augmentation and Dataset-JSON/Dataset-XML terminology enrichment.--redcap-dictionary FILEor-rcd FILEsupplies the dictionary required by REDCap CSV and REDCap-origin ODM. Standard/OpenClinica ODM uses embedded metadata and rejects this option.--schema-file FILElets you validate mapping files against an alternative JSON Schema.--self-validate-schemaor-svsperforms a self-validation of the mapping schema itself. This is mainly an author or development check and may require SSL support in the Perl environment.--term-audit FILEwrites a terminology-decision report selected by the.tsv,.tsv.gz, or.xlsxextension. The audit includes source values and labels, lookup inputs, converted terms, retrieval paths, decision reasons, candidate scores and margins, provenance, fallbacks, and effective search settings.
CDISC-ODM-specific behaviorβ
-icdisc-odm FILEor-i cdisc-odm FILEaccepts Snapshot XML using ODM 1.3.1, 1.3.2, or the bounded ODM 2.0 ClinicalData profile.- Version and vendor profile are detected from the ODM namespace,
ODMVersion, source system, and extension namespaces. Version-specific input flags are not used. - REDCap-origin ODM uses
source.profile: redcapwith--redcap-dictionary. Standard or OpenClinica ODM usessource.profile: cdisc-odmand embeddedMetaDataVersion,ItemDef, andCodeListmetadata. - Repeated item groups are kept as separate occurrences for repeated BFF sections; ambiguous repeated scalar values stop the conversion instead of overwriting data.
- The route is available through the CLI and local module interfaces, but not through the HTTP(s) API.
cBioPortal-specific behaviorβ
-icbioportal PATHor-i cbioportal PATHaccepts an unpacked cBioPortal study directory or.ziparchive.- Clinical data files are discovered through
meta_*.txtdescriptors. The sample table is required; a missing patient table is derived from sample-to-patient links. - Entity-aware BFF output can emit patient-derived
individuals, sample-derivedbiosamples, a study-deriveddataset, and case-list-derivedcohorts. - A mapping file using
source.profile: cbioportalis optional and may augment project-specific patient and sample fields. It cannot rewritePATIENT_IDorSAMPLE_ID. - Timeline and molecular files are currently outside this clinical package profile. Directory and ZIP input is available through the CLI and local module interfaces, not the HTTP(s) API.
Ontology search tuningβ
--search exact|mixed|fuzzyselects the ontology lookup strategy. Default:exact.--text-similarity-method cosine|diceselects the token-similarity method used bymixedandfuzzy. Default:cosine.--min-text-similarity-score FLOATsets the minimum score accepted bymixedandfuzzy. Default:0.8.--levenshtein-weight FLOATsets the normalized Levenshtein weight used byfuzzy. Default:0.1.
For resolution precedence, audit columns, and threshold tradeoffs, see Terminology Search.
OMOP-specific optionsβ
--ohdsi-dbenables Athena-OHDSI lookup. It is required for OMOP output and optional for OMOP input when concepts are absent from the suppliedCONCEPTtable.--path-to-ohdsi-db DIRpoints to the directory containingohdsi.db.--omop-tables TABLE ...restricts which OMOP-CDM tables are processed, whileCONCEPTandPERSONstay included.--exposures-file FILEprovides a CSV list of OMOPconcept_idvalues to be treated as exposures.--streamenables incremental OMOP processing for-iomop ... -obffoutput. Use--no-streamto explicitly keep the default non-streaming mode.--sql2csvprints SQL tables instead of converting them.--max-lines-sql Ncaps rows read per SQL table and individuals emitted by non-streaming OMOP conversions, including CSV/TSV input. CSV/TSV streaming is not capped by this option. Default:500.
openEHR-specific optionsβ
-iopenehr FILE ...or-i openehr FILE ...accepts openEHR JSON or YAML input as patient-bearing envelopes or composition sets.- openEHR input must carry a resolvable patient identifier in the payload or envelope; otherwise the conversion fails.
- multiple openEHR files are supported when patient identity can be resolved; multi-patient input is grouped automatically before mapping.
- The current openEHR CLI path is experimental and currently supports BFF and PXF output.
Dataset-JSON-specific optionsβ
-idataset-json FILE ...or-i dataset-json FILE ...accepts one or more CDISC Dataset-JSON v1.1 SDTM domain files in.jsonor.json.gzform.- Exactly one
DMdataset is required. Subject-level domains are grouped byUSUBJID; no REDCap dictionary is used. A mapping file withsource.profile: sdtmis optional for terminology enrichment. --define-xml FILEis optional for Dataset-JSON and can supply authoritativenci:ExtCodeIDidentifiers and controlled-term displays.datasetjson2bff,datasetjson2pxf, anddatasetjson2omopare available. OMOP output also requires--ohdsi-dband--out-dir.- Input is currently processed in memory rather than streamed. See CDISC Dataset-JSON for mapped domains and current boundaries.
Dataset-XML-specific optionsβ
-idataset-xml FILE ...or-i dataset-xml FILE ...accepts one or more CDISC Dataset-XML v1.0 SDTM domain files in.xmlform.--define-xml FILEis required and supplies the Define-XML v2.0/v2.1 metadata used to resolve each domain, column, order, label, and data type.- Exactly one
DMdataset is required. Subject-level domains are grouped byUSUBJID; a mapping file withsource.profile: sdtmis optional for terminology enrichment. datasetxml2bff,datasetxml2pxf, anddatasetxml2omopare available. OMOP output also requires--ohdsi-dband--out-dir.- Input is processed in memory. See CDISC Dataset-XML for cross-file checks and current boundaries.
FHIR-specific optionsβ
-ifhir FILE ...or-i fhir FILE ...accepts one or more FHIR R4 Bundle files in.jsonor.json.gzform.- Each Bundle must contain at least one Patient. Relative, absolute, and
urn:uuid:resource references are resolved before resources are grouped by Patient. - mCODE 4.0 Bundles use the same input route. Canonical profile URLs are detected automatically; no mCODE-specific flag is required.
fhir2bff,fhir2pxf, andfhir2omopare available. Entity-aware BFF output can emit Specimen-derivedbiosamples; OMOP output also requires--ohdsi-dband--out-dir.- Input is processed in memory. See FHIR R4 for mapped resources and current boundaries.
General optionsβ
--separator CHARor--sep CHARoverrides the CSV delimiter. For.csvfiles the default remains;.--username NAMEor-u NAMEoverrides the username stored in conversion metadata.--default-vital-status ALIVE|DECEASED|UNKNOWN_STATUSsets the fallbacksubject.vitalStatus.statusused forPXFoutput when no source-derived value is available. Default:ALIVE.--source-info/--no-source-infocontrols whether raw source payloads are preserved inBFFinfo. Default:--source-info.--log [FILE]writes the resolved request/configuration JSON. If no filename is provided, the default isconvert-pheno-log.jsonin--out-dir.--color/--no-colorcontrols colored terminal output. Default:--color.--testsuppresses time-varying metadata so generated files are stable for comparisons.--verboseor-vprints progress information.--debug LEVELprints the resolved internal request and extra debugging output. WithLEVEL >= 2, it also prints a compact SQLite lookup summary (requests, cache hits, DB lookups, search resolution, and SQL timings).
More helpβ
- Choose a Conversion for route commands
- Download & Installation for setup
- Google Colab tutorial if you want a disposable environment