Path Resolution

When using the command-line client, you may refer to objects either through their ID or by name.

In the DNAnexus platform, every data object has a unique ID starting with the class of the object (e.g. "record", "file", "project") followed by a hyphen ('-') and 24 alphanumberic characters, e.g. record-9zGPKyvvbJ3Q3P8J7bx00005. A string matching this format will always be interpreted to be meant as the ID of such an object and will not be further resolved as a name.

The command-line client, however, also accepts names and paths as input in a particular syntax.

Path Syntax

There are three main types of paths that are recognized for referring to data objects: project paths, job-based object references (JBORs), and DNAnexus links.

Project Paths

To refer to a project by name, it must be suffixed with the colon character ":". Anything appearing after the ":" or without a ":" will be interpreted as a folder path to a named object. For example, to refer to a file called "hg19.fq.gz" in a folder called "human" in a project called "Genomes", the following path can be used in place of its object ID:

Genomes:human/hg19.fa.gz

Note that the folder path appearing after the ":" is assumed to be relative to the root folder "/" of the project.

Exceptions to this are when commands take in arbitrary names (e.g. for dx describe which takes in app names, user IDs, etc.). In this case, all possible interpretations will be attempted. However, it will always be assumed that it is not a project name unless it ends in ":".

Job-Based Object References (JBORs)

To refer to the output of a particular job, you can use the syntax <job id>:<output name>.

Examples

If you have the job ID handy, you can use it directly.

$ dx describe job-B0kK3p64Zg2FG1J75vJ00004:reads

Or if you know it's the last analysis you ran:

$ dx describe $(dx find jobs -n 1 --brief):reads

You can also automatically download a file once the job producing it is done:

$ dx download $(dx run some_exporter_app -iinput=my_input -y --brief --wait):file_output

If the output is an array, you can extract a single element by specifying its array index (numbered 0, 1, etc.) as follows:

$ dx describe job-B0kK3p64Zg2FG1J75vJ00004:reads.0

DNAnexus links are JSON hashes which are used for job input and output. They always contain one key, $dnanexus_link, and have as a value either

  • a string representing a data object ID

  • another hash with two keys:

    • project a string representing a project or other data container ID

    • id a string representing a data object ID

For example:

$ dx ls '{"$dnanexus_link": "file-B2VBGXyK8yjzxF5Y8j40001Y"}'
file-name

Special Characters

Because of the use of : to denote project names and of / to separate folder names, they must be escaped with a preceding backslash \\ when they appear in a data object's name. The characters * and ? are also reserved for the use in wildcard patterns and must also be escaped. Depending on your terminal and whether you put the entire name or path in quotes, you may have to additionally escape spaces in order to pass them in as part of the string. The use of backslashes in names is discouraged, and the best way to interact with objects with such names will probably be to use their IDs directly. See the following table for some examples of the necessary representation for accessing existing objects with special characters in their names (assuming a bash shell).

Character

Escaped version (no quotes)

Escaped version (with quotes)

`` (single space)

' '

:

\\\\:

'\\:'

/

\\\\/

'\/'

*

\\\\\\\\*

'\\\\\\*'

?

\\\\\\\\?

'\\\\\\?'

The following example illustrates how the special characters are escaped for use on the command line, with and without quotes.

$ dx ls Project\ Mouse:
name: with/special*characters?
$ dx cd Project\ Mouse:
$ dx describe name\\\\:\ with\\\\/special\\\\\\\\*characters\\\\\\\\?
ID              file-9zz0xKJkf6V4yzQjgx2Q006Y
Class           file
Project         project-9zb014Jkf6V33pgy75j0000G
Folder          /
Name            name: with/special*characters?
State           closed
Hidden          visible
Types           -
Properties      -
Tags            -
Outgoing links  -
Created         Wed Jul 11 16:39:37 2012
Created by      alice
Last modified   Sat Jul 21 14:19:55 2012
Media type      text/plain
Size (bytes)    4
$ dx describe "name\: with\/special\\\\\\*characters\\\\\\?"
...

For commands where the argument supplied involves naming or renaming something, the only escaping necessary is whatever is necessary for your shell or for setting it apart from a project or folder path.

$ dx new record -o "must\: escape\/everything\*once\?at creation"
ID              record-B13BBVK4Zg29fvVv08q00005
...
Name            must: escape/everything*once? at creation
...
$ dx rename record-B13BBVK4Zg29fvVv08q00005 "no:escaping/necessary*even?wildcards"

Name Conflicts

It is possible to have multiple objects with the same name in the same folder. When an attempt is made to access or modify an object which shares the same name as another object, you will be prompted to select the desired data object.

$ dx ls
sample : file-9zbpq72y8x6F0xPzKZB00003
sample : file-9zbjZf2y8x61GP1199j00085
$ dx mv sample mouse_sample
The given path "sample" resolves to the following data objects:
0) closed  2012-06-27 18:04:28 sample (file-9zbpq72y8x6F0xPzKZB00003)
1) closed  2012-06-27 15:34:00 sample (file-9zbjZf2y8x61GP1199j00085)

Pick a numbered choice or "*" for all: 1
$ dx ls -l
closed  2012-06-27 15:34:00 mouse_sample (file-9zbjZf2y8x61GP1199j00085)
closed  2012-06-27 18:04:28 sample (file-9zbpq72y8x6F0xPzKZB00003)

Some commands (like mv here) will allow you to enter * so that all matches will be used. Other commands may automatically apply the command to all of them (e.g. ls and describe), and others will require that exactly one object be chosen (e.g. run).

Last updated