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 followed by a hyphen ('-') and 24 alphanumeric characters. Common object classes include "record", "file", and "project". An example ID would be 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
The DNAnexus Platform recognizes three main types of paths 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
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. This applies to commands like dx describe
which accepts app names, user IDs, and other identifiers. 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 (starting from 0) as follows:
dx describe job-B0kK3p64Zg2FG1J75vJ00004:reads.0
DNAnexus Links
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 IDid
a string representing a data object ID
For example:
$ dx ls '{"$dnanexus_link": "file-B2VBGXyK8yjzxF5Y8j40001Y"}'
file-name
Special Characters
When naming data objects, certain characters require special handling because they have specific meanings in the DNAnexus Platform:
The colon (
:
) identifies project namesThe forward slash (
/
) separates folder namesAsterisks (
*
) and question marks (?
) are used for wildcard matching
To use these characters in object names, you must escape them with backslashes. Spaces may also need escaping depending on your shell environment and whether you use quotes.
For the best experience, we recommend avoiding special characters in names when possible. If you need to work with objects that have special characters, using their object IDs directly is often simpler.
The table below shows how to escape special characters when accessing objects with these characters in their names:
| ------------------- | --------------------------- | ----------------------------- | | `` (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 matches. This includes commands like ls
and describe
. Some commands will require that exactly one object be chosen, such as the run
command.
Last updated
Was this helpful?