For the complete documentation index, see llms.txt. This page is also available as Markdown.

Running Apps and Applets

You can run apps and applets from the command-line using the command dx run. The inputs to these app(let)s can be from any project for which you have VIEW access. You can also run them from the UI.

Running in Interactive Mode

If dx run is run without specifying any inputs, interactive mode launches. When you run this command, the platform prompts you for each required input, followed by a prompt to set any optional parameters. The following example uses the BWA-MEM FASTQ Read Mapper app. After you finish entering inputs, confirm that you want the applet or app to run with the selected inputs.

$ dx run app-bwa_mem_fastq_read_mapper
Entering interactive mode for input selection.

Input:   Reads (reads_fastqgz)
Class:   file

Enter file ID or path ((<TAB> twice for compatible files in current directory, '?' for more options)
reads_fastqgz: reads.fastq.gz

Input:   BWA reference genome index (genomeindex_targz)
Class:   file
Suggestions:
    project-BQpp3Y804Y0xbyG4GJPQ01xv://file-* (DNAnexus Reference Genomes)

Enter file ID or path (<TAB> twice for compatible files in current directory, '?' for more options)
genomeindex_targz: "Reference Genome Files:/H. Sapiens - hg19 (UCSC)/ucsc_hg19.bwa-index.tar.gz"

Select an optional parameter to set by its # (^D or <ENTER> to finish):

 [0] Reads (right mates) (reads2_fastqgz)
 [1] Add read group information to the mappings (required by downstream GATK)? (add_read_group) [default=true]
 [2] Read group id (read_group_id) [default={"$dnanexus_link": {"input": "reads_fastqgz", "metadata": "name"}}]
 [3] Read group platform (read_group_platform) [default="ILLUMINA"]
 [4] Read group platform unit (read_group_platform_unit) [default="None"]
 [5] Read group library (read_group_library) [default="1"]
 [6] Read group sample (read_group_sample) [default="1"]
 [7] Output all alignments for single/unpaired reads? (all_alignments)
 [8] Mark shorter split hits as secondary? (mark_as_secondary) [default=true]
 [9] Advanced command line options (advanced_options)

Optional param #: <ENTER>

Using input JSON:
{
    "reads_fastqgz": {
        "$dnanexus_link": {
            "project": "project-xxxx",
            "id": "file-xxxx"
        }
    },
    "genomeindex_targz": {
        "$dnanexus_link": {
            "project": "project-xxxx",
            "id": "file-xxxx"
        }
    }
}

Confirm running the applet/app with this input [Y/n]: <ENTER>
Calling app-xxxx with output destination project-xxxx:/

Job ID: job-xxxx
Watch launched job now? [Y/n] n

Running in Non-interactive Mode

Naming Each Input

You can also specify each input parameter by name using the -i or --input flags with the syntax -i<input name>=<input value>. Names of data objects in your project are resolved to the appropriate IDs and packaged correctly for the API method as shown in the following example.

When specifying input parameters using the -i/--input flag, you must use the input field names (not to be confused with their human-readable labels). To look up the input field names for an app, applet, or workflow, you can run the command dx run app(let)-xxxx -h, as shown in the following example using the Swiss Army Knife app.

The help message describes the inputs and outputs of the app, their types, and how to identify them when running the app from the command line. For example, from the above help message, the Swiss Army Knife app has two primary inputs: one or more files and a string to be executed on the command line, to be specified as -iin=file-xxxx and -icmd=<string>, respectively.

The following example shows you how to run the same Swiss Army Knife app to sort a small BAM file using these inputs.

Specifying Array Input

To specify array inputs, reuse the ‑i/‑‑input flag for each input in the array and each specified file is appended to an array in the same order as it was entered on the command line. The following example uses the Swiss Army Knife app to index multiple BAM files.

Job-Based Object References (JBORs)

Job-based object references (JBORs) can also be provided using the -i flag with the syntax ‑i<input name>=<job id>:<output name>. Combined with the --brief flag (which allows dx run to output only the job ID) and the -y flag (to skip confirmation), you can string together two jobs using one command.

The following example runs the BWA-MEM FASTQ Read Mapper app, producing the output named sorted_bam as described in the dx help output by executing the command dx run app-bwa_mem_fastq_read_mapper -h. The sorted_bam output is then used as input for the Swiss Army Knife app.

Advanced Options

The following sections show additional functionality provided by dx run.

Quiet Output

Regardless of whether you run a job interactively or non-interactively, the command dx run always prints the exact input JSON with which it is calling the applet or app. If you don't want to print this verbose output, you can use the --brief flag which tells dx to print out only the job ID instead. This job ID can then be saved.

Rerunning a Job With the Same Settings

If you are debugging applet-xxxx and want to rerun a job you previously ran, using the same settings (destination project and folder, inputs, instance type requests), but use a new executable applet-yyyy, you can use the --clone flag.

In this command, --clone job-xxxx reuses the job settings while the executable is overridden to use the Swiss Army Knife app instead of the original executable.

If you want to modify some but not all settings from the previous job, you can run dx run <executable> --clone job-xxxx [options]. The command-line arguments you provide in [options] override the settings reused from --clone. For example, this is useful if you want to rerun a job with the same executable and inputs but a different instance type, or if you want to run an executable with the same settings but slightly different inputs.

The following example redirects the job outputs to the folder "outputs/".

While the --clone job-xxxx flag copies the applet, instance type, and inputs, it does not copy usage of the --allow-ssh or --debug-on flags. These must be re-specified for each job run. For more information, see the Connecting to Jobs page.

Specifying the Job Output Folder

Use the --destination flag to specify the full project-ID:/folder/ path in which to output the results of the app(let). If this flag is unspecified, the output of the job defaults to the present working directory, which can be determined by running dx pwd.

In this command, the flag --destination project-xxxx:/mappings instructs the job to output all results into the "mappings" folder of project-xxxx.

Specifying a Different Instance Type

Use dx run --instance-type to specify the instance types to use for the job. More information is available by running the command dx run --instance-type-help.

Some apps and applets have multiple entry points, meaning that different instance types can be specified for different functions executed by the app(let). In the following example, the Parliament app is run while specifying the instance types for the entry points honey, ssake, ssake_insert, and main. Specifying the instance types for each entry point requires a JSON-like string, meaning that the string is wrapped in single quotes, as explained earlier and shown in the following example.

Adding Metadata to a Job

If you are running many jobs that have varying purposes, you can organize the jobs using metadata. Two types of metadata are available on the DNAnexus Platform: properties and tags.

Properties are key-value pairs that can be attached to any object on the platform, whereas tags are strings associated with objects on the platform. Use the --property flag to attach a property to a job and the --tag flag to tag a job.

Adding metadata to executions does not affect the metadata of the executions' output files. Metadata on jobs makes it easier for you to search for a particular job in your job history. This is useful when you want to tag all jobs run with a particular sample, for instance.

Specifying an App Version

If your current workflow is not using the most up-to-date version of an app, you can specify an earlier version when running your job. Append the required version to the app name. For example, if the current version-qualified app name is app-xxxx/1.0.0, you can run app-xxxx/0.0.1 to use an earlier version.

Watching a Job

To monitor your job as it runs, use the --watch flag to display the job's logs in your terminal window as it progresses.

Providing Input JSON

You can also specify the input JSON in its entirety. To specify a data object, you must wrap it in DNAnexus link form (a key-value pair with a key of $dnanexus_link and value of the data object's ID). Because you are already providing the JSON in its entirety, if the applet or app ID can be resolved and the JSON can be parsed, confirmation before the job starts is not required. Three methods exist for entering the full input JSON, discussed in separate sections below.

From the CLI

If using the CLI to enter the full input JSON, you must use the flag ‑j/‑‑input‑json followed by the JSON in single quotes. Only single quotes are used to wrap the JSON to avoid interfering with the double quotes used by the JSON itself.

From a File

If using a file to enter the input JSON, you must use the flag ‑f/‑‑input‑json‑file followed by the name of the JSON file.

From stdin

Entering the input JSON file using stdin is done the same way as entering the file using the -f flag, except that you use - as the filename. The following example shows how to echo the input JSON to stdin and pipe the output to the input of dx run. As with the CLI JSON example, use single quotes to wrap the JSON input to avoid interfering with the double quotes used by the JSON itself.

Getting Additional Information on dx run

Executing the dx run --help command shows the flags available to use with dx run. The message printed by this command is identical to the one displayed in the brief description of dx run.

Cost Run Limits

The --cost-limit cost_limit sets the maximum cost of the job before termination. In the case of workflows, it is the cost of the entire analysis job. For a batch run, this limit applies per job. See the dx run --help command for more information.

Job Runtime Limits

On the DNAnexus Platform, jobs are limited to a runtime of 30 days. Jobs running longer than 30 days are automatically terminated.

Last updated

Was this helpful?