Using fife utils in your python scripts

If you want to use the fife utils tools in your python scripts, most of their behaviours are available through importing the fife_sam_utils module (as of v3_2_6 and later).

For example:

import fife_sam_utils 


tapesused = set() 
count = {} 

ds = fife_sam_utils.fake_file_dataset(filename) 
res = fife_sam_utils.validate( ds, list_tapes = tapesused, locality = count ) 

print("found all locations:", res == 0) 
print("found tapesused: " , tapesused) 
print("found locality:" , count) 

There are a couple of things to be aware of:

  • initial setup
    • setup_environ(experiment='xxx') will get things setup
  • datasets to operate on
    • ds = fake_file_dataset(filename) makes a one-file fake dataset (This doesn't declare a dataset. It just makes a python object that looks like the python object we use to represent a dataset.)
    • ds = dataset(name) makes a whole dataset representation
  • Operations on datasets:
    • clone(dataset, destination_path, experiment='xxx', ...) copies files to dest if not there
    • unclone(dataset, delete_match, experiment='xxx',...) removes file locations matching delete_match regexp
    • validate(dataset, experiment='xxx',...) reviews file locations and makes sure they actually exist, example above shows how to extract tapes used and locality counts.

These routines actually cover most of the sam_xxx_dataset routines, in one permutation or other. If you read through
the scripts, the other optional arguments are used to implement command line options like "--just_say", or "--prune".