Loads the entries in the biolite.cfg file into two member dictionaries, resources (default parameters and data paths) and executables (paths to external executables called by wrappers Module).
By default, BioLite will look for the configuration file at the following paths, in order of preference:
Called at module load to parse the BioLite configuration file.
Lookup a resource from the configuration file for key and print an intelligble error message on KeyError.
Lookup the full path to an executable key in the configuration file and print an intelligble error message if the path can’t be found in the user’s PATH environment variable (similar to the Unix utility which).
The output is a list, starting with the full path to the executable, ready for input to subprocess.Popen. Any trailing parameters in config entry for the executable are preserved in this list.
If there is no config entry for the key, or the entry is blank, the key is used as the name of the executable. Thus, the config file only needs to override executable paths that won’t resolve correctly using PATH.
Provides an interface to the underlying SQLite database that stores the BioLite catalog, runs, diagnostics, and programs tables.
CREATE TABLE catalog (
id VARCHAR(256) PRIMARY KEY NOT NULL,
paths TEXT,
species VARCHAR(256),
ncbi_id INTEGER,
itis_id INTEGER,
extraction_id VARCHAR(256),
library_id VARCHAR(256),
library_type VARCHAR(256),
tissue VARCHAR(256),
sequencer VARCHAR(256),
seq_center VARCHAR(256),
note TEXT,
sample_prep TEXT,
timestamp DATETIME);
CREATE INDEX catalog_species ON catalog(species);
CREATE INDEX catalog_ncbi_id ON catalog(ncbi_id);
CREATE INDEX catalog_itis_id ON catalog(itis_id);
CREATE INDEX catalog_extraction_id ON catalog(extraction_id);
CREATE INDEX catalog_library_id ON catalog(library_id);
CREATE INDEX catalog_library_type ON catalog(library_type);
CREATE INDEX catalog_tissue ON catalog(tissue);
CREATE INDEX catalog_sequencer ON catalog(sequencer);
CREATE INDEX catalog_seq_center ON catalog(seq_center);
CREATE INDEX catalog_note ON catalog(note);
CREATE INDEX catalog_sample_prep ON catalog(sample_prep);
CREATE INDEX catalog_timestamp ON catalog(timestamp);
CREATE TABLE runs (
run_id INTEGER PRIMARY KEY AUTOINCREMENT,
id VARCHAR(256),
name VARCHAR(32),
hostname VARCHAR(32),
username VARCHAR(32),
timestamp DATETIME,
hidden INTEGER DEFAULT '0');
CREATE INDEX runs_id ON runs(id);
CREATE INDEX runs_name ON runs(name);
CREATE TABLE diagnostics (
id VARCHAR(256),
run_id INTEGER,
entity VARCHAR(128),
attribute VARCHAR(32),
value TEXT,
timestamp DATETIME);
CREATE INDEX diagnostics_id ON diagnostics(id);
CREATE INDEX diagnostics_run_id ON diagnostics(run_id);
CREATE INDEX diagnostics_entity ON diagnostics(entity);
CREATE INDEX diagnostics_attribute ON diagnostics(attribute);
CREATE INDEX diagnostics_timestamp ON diagnostics(timestamp);CREATE UNIQUE INDEX entry ON diagnostics(run_id,entity,attribute);
CREATE TABLE programs (
binary CHAR(32) PRIMARY KEY NOT NULL,
name VARCHAR(256),
version TEXT);
CREATE INDEX programs_name ON programs(name);
Establish a gobal database connection and set the execute function.
Close the global database connection, set it to None, and set the execute function to auto-reconnect.
Establish a gobal database connection and set the execute function.
Utility functions used by other BioLite modules.
Prints the current BioLite module and an error message, then aborts.
Creates the directory, including any missing parent directories, at the specified path.
Aborts if the path points to an existing regular file.
Returns the absolute path of the directory.
Truncates a file (i.e. overwrites with 0 bytes) at the given path.
Returns an rusage object where each field is the difference of the corresponding fields in r1 and r2.
Diagnose why a wrapped executable failed to execute, and print an intelligble error message for the user.
Calls an executable as a subprocess and checks the return value.
All args and kwargs are passed to a subprocess.Popen call, except for the special keywords return_ok, whose value is used to check the return value of the subprocess. By default, this is zero and any non-zero return is considered an error. To disable this check, set return_ok to None.
Returns a 3-tuple with the return code, the elapsed walltime, and an rusage structure with the elapsed usertime and systime.
Returns the string s with only alpha-numerical characters and the special characters ()[]{}|:.-_ preserved. All other characters are replaced by _.
Places an exclusive lock around the file object f and writes line to it as an atomic write operation.
A line return is appended after line.
Seeks to the end of the file object f and yields lines in reverse order.
Uses the cat or awk command to copy the contents at input_path to output_path, starting at line 0 of input_path and appending to output_path by default.
Uses the head to copy the first n lines of input_path to output_path, overwriting the contents of output_path by default.
Uses the head to copy the last n lines of input_path to output_path, overwriting the contents of output_path by default.
Uses the inspect module to determine the name of the calling function and its module.
Returns a 2-tuple with the module name and the function name.
Uses the inspect module to return a dictionary of the local variables in the caller’s frame at the given depth. The default depth of 2 corresponds to the frame that calls this function.
Bases: dict
A mutable alternative to namedtuple that supports accessing values as attributes or with the dict [] operator.
Sorts a list of strings l and returns a list with the elements in alpha-numerical order (i.e. strings starting with numbers are correctly ordered by numerical value).
Reads the current memory usage for this process from /proc/self/status and returns two integer values mem and vmem which correspond to the VmHWM (max physical memory) and VmPeak (max virtual memory) fields.
Note: only works on Linux.
Returns the full path to executable by searching through all entries in the $PATH environment variable, and looking for an executable file with that name.
Returns None if the executable is not found.
Finds the base filename of the path, than the base of the filename (everything before the last .extension).
Recursively zips all files in dirname into a zip archive with the name dirname.zip in the current working directory.
Collapse a list of numbers into a list of range strings, following http://stackoverflow.com/questions/9470611/how-to-do-an-inverse-range-i-