Difference between revisions of "File access through predefined profiles"
Line 25: | Line 25: | ||
<pre>/links/tomograms/tomob001ts0001.mrc | <pre>/links/tomograms/tomob001ts0001.mrc | ||
− | + | /links/tomograms/tomob001ts0002.mrc </pre> | |
... so that if you access them from your Mac system, the catalogue will think that the files don't exist. | ... so that if you access them from your Mac system, the catalogue will think that the files don't exist. | ||
Line 34: | Line 34: | ||
''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. | ''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: | ||
+ | |||
+ | <pre>mbsys.access.addProfile('fromUnix','/links/tomograms'); | ||
+ | mbsys.access.addProfile('fromMac','/Volumes/external/tomograms'); | ||
+ | |||
+ | The profile names <tt>'fromLinux'</tt> and <tt>'fromMac'</tt> 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: | ||
+ | |||
+ | <tt>mbsys,access.fixProfile('fromMac');</tt> | ||
+ | |||
+ | === Using access profile === | ||
+ | |||
+ | 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 <tt>/links/tomograms/tomob001ts0001.mrc </tt> will not be recognized by the operative system of your Mac: | ||
+ | |||
+ | <pre>ls /links/tomograms/tomob001ts0001.mrc | ||
+ | ls: pret: No such file or directory</pre> | ||
+ | |||
+ | === Removal of access profiles === | ||
+ | |||
+ | If you create a profile with wrong information | ||
+ | <tt>mbsys.access.removeProfile('fromMac')</tt>; | ||
+ | |||
+ | but ''Dynamo'' functions will recognize the file: | ||
+ | |||
+ | <tt> dtmshow -otf /links/tomograms/tomob001ts0001.mrc </tt> | ||
+ | |||
+ | === Storing access profiles === | ||
+ | Access profiles are kept from session to session. The are stored in your ''Dynamo'' preferences folder (under <tt>~/.dynamo/preferences</tt> and get loaded whenever you run <tt>dynamo_activate.m</tt> in Matlab. | ||
+ | |||
+ | ==== Standalone ==== | ||
+ | In the standalone, the predefined profiles will not load automatically, you need to load them manually through: | ||
+ | |||
+ | <tt>mbsys.access.aux.loadAccessManager();</tt> | ||
+ | |||
+ | in the ''Dynamo'' console. | ||
+ | |||
+ | === Checking running profiles === | ||
+ | |||
+ | In order to see which profiles are operative in a given moment, write: | ||
+ | |||
+ | <tt>mbsys.access.show</tt> | ||
+ | |||
+ | You should get an output similar to: | ||
+ | |||
+ | <pre>------------------------------------------------------------ | ||
+ | Registered profiles: | ||
+ | * 'nasLinux' : /links/groups/cina | ||
+ | * 'nasMac' : /Volumes/cina | ||
+ | * 'nasNet' : /net/bs-filesvr01/export/group/cina | ||
+ | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
+ | Active profile: ''nasMac'' | ||
+ | Enabled: 1 | ||
+ | ------------------------------------------------------------</pre> |
Revision as of 13:35, 25 June 2018
This system is used when you work frequently with filenames that represent the same file as seen by different file systems.
Contents
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
/links/tomograms/myTomogram.mrc
and in your Mac machine, you see it as:
/Volumes/external/tomograms/myTomogram.mrc.
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:
/links/tomograms/tomob001ts0001.mrc /links/tomograms/tomob001ts0002.mrc
... 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:
mbsys.access.addProfile('fromUnix','/links/tomograms'); mbsys.access.addProfile('fromMac','/Volumes/external/tomograms'); The profile names <tt>'fromLinux'</tt> and <tt>'fromMac'</tt> 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: <tt>mbsys,access.fixProfile('fromMac');</tt> === Using access profile === 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 <tt>/links/tomograms/tomob001ts0001.mrc </tt> will not be recognized by the operative system of your Mac: <pre>ls /links/tomograms/tomob001ts0001.mrc ls: pret: No such file or directory
Removal of access profiles
If you create a profile with wrong information
mbsys.access.removeProfile('fromMac');
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.
Standalone
In the standalone, the predefined profiles will not load automatically, you need to load them manually through:
mbsys.access.aux.loadAccessManager();
in the Dynamo console.
Checking running profiles
In order to see which profiles are operative in a given moment, write:
mbsys.access.show
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 ------------------------------------------------------------