File access through predefined profiles

From Dynamo
Revision as of 16:07, 25 June 2018 by Daniel Castaño (talk | contribs) (→‎Creation of access profiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This system is used when you work frequently with filenames that represent the same file as seen by different file systems.

Name of a file in different systems

For example, you may have a tomogram stored in a fileshare that can be seen in different file systems. Let's say that in your linux machine, you see it as


and in your Mac machine, you see it as:


In this example,we assume that /links and /Volumes/external are different mount points (one defined in the unix machine and the other one in the mac machine) that point to the same location.

When you are are working on the different systems, each naming is coherent. The problem occurs when you are working in one system, and you need to refer to file names expressed in the convention of the other system.

In many situations, you can just use string replacing methods of your favorite parsing system (Perl, awk, etc). In Matlab (or Dynamo standalone) you can just use the convenient strrep function. For instance, if you have a text file with file names (viewed from the unix system) to visit in a loop, producing the equivalent list with the names of the same files as viewed from the Mac is trivial.

However, you might have a problem when you use databasing options in Dynamo that store absolute paths.

Example: tomogram names in catalogues

A frequently happening example are the tomograms and models in the catalogue. If you produced your catalogue in the linux machine, your tomograms will look like:


... so that if you access them from your Mac system, the catalogue will think that the files don't exist.

One think that can be done is to use the option in the calatogue gui to "relink" the tomograms (and linking elements in the models) to the mac convention. This works, but is rather tedious. Moreover, it also means that afterwards the catalogue will not recognise the tomogram files when accessed through the linux machine.

Global file access profiles

Dynamo includes a more convenient system to handle this situation: the global file access profiles. The user can define profiles that express the equivalence of same mount points as viewed in the different machines. Whenever Dynamo looks for a file expressed with an absolute path, it will automatically test internally every possible registered profile.

Creation of access profiles

In the previous example, you could create a link between the two profiles through:


The profile names 'fromLinux' and 'fromMac' are arbitrary.

Activation of access profiles

Accessing files through predetermined profiles is not activated by default. You need to chose one of the defined profiles and declare it active in your system. To activate it , you would write in your mac:


Using access profiles

When a profile is running, most Dynamo functions that read or check existence of files will check all available profiles when analysing a file name. For instance, the location /links/tomograms/tomob001ts0001.mrc will not be recognized by the operative system of your Mac:

ls /links/tomograms/tomob001ts0001.mrc
ls: pret: No such file or directory

In users scripts

You can incorporate this functionality in your scripts through the function mbsys.access.isfile. For a given string, it returns 0 if the string is not a valid filename under any registered access profile. If a profile is located where the file is valid, it returns also a filename that will be valid in the current system.

[ok,file] = mbsys.access.isfile(file);

Removal of access profiles

If you create a profile with wrong information


but Dynamo functions will recognize the file:

 dtmshow -otf  /links/tomograms/tomob001ts0001.mrc 

Storing access profiles

Access profiles are kept from session to session. The are stored in your Dynamo preferences folder (under ~/.dynamo/preferences and get loaded whenever you run dynamo_activate.m in Matlab.


In the standalone, the predefined profiles will not load automatically, you need to load them manually through:


in the Dynamo console.

Checking running profiles

In order to see which profiles are operative in a given moment, write:

You should get an output similar to:

Registered profiles: 
* 'nasLinux' : /links/groups/cina
* 'nasMac'   : /Volumes/cina
* 'nasNet'   : /net/bs-filesvr01/export/group/cina
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Active profile: ''nasMac''
Enabled:          1

Related tools

Accessing files through repository components (documented from release Dynamo 1.3) has a similar effect, although it is constrained to files that are located and accessible through the repository tree. File accessing profiles can be used for general files in the file system.