moca.helpers package

Submodules

moca.helpers.configuration_parser module

class moca.helpers.configuration_parser.ConfigurationParser(config_file)[source]

Bases: future.types.newobject.newobject

Parse config file

Parameters:config_file (str) – absolute path to configuration file
get_all_genomes()[source]

Get all genome names as specified in config file

Returns:genome_names – List of all genome names
Return type:list
get_all_sections()[source]

Get all sections in config file

Returns:sections – List of all sections
Return type:list
get_binary_path(binary_name)[source]

Returns absolute path to installed binaries

Parameters:binary_name (string) – Program name
Returns:binary_path – Absolute path to installed binary
Return type:string
get_genome_data(genome_name)[source]

Return all files associated with a genome in the config file

Parameters:genome_name (str) – Genome name as specified in ‘genome:<genome_name>’ format
Returns:genome_dict – Dictionary specifying the files associated with a genome Format: {‘genome_name’: {‘<wig_prefix>’: wig_prefix_path, ‘genome_table’: genome_table_path}}
Return type:str
get_section(section_name)[source]

Get all keys inside a particular section

Parameters:section_name (str) – Section Name
Returns:section_dict – Dict of all keys inside header
Return type:dict
moca.helpers.configuration_parser.is_executable(fpath)[source]

Check if binary is executable

Source: http://stackoverflow.com/a/377028/756986

moca.helpers.exceptions module

exception moca.helpers.exceptions.MocaException(msg)[source]

Bases: exceptions.Exception

Base class for MoCA Exceptions

__str__()[source]

string representation of MoCA Exception

Returns:mocastr
Return type:string representation

moca.helpers.job_executor module

Utility function to run jobs

moca.helpers.job_executor.chdir(*args, **kwds)[source]

Context manager to temporarily change to a new directory.

http://lucentbeing.com/blog/context-managers-and-the-with-statement-in-python/ Credits: Brad Chapman for bcbio-nextgen: https://github.com/chapmanb/bcbio-nextgen/blob/master/bcbio/utils.py#L192

Parameters:new_dir (str) – Location of directory to be created
moca.helpers.job_executor.run_job(cmd, cwd)[source]

Execute command line jobs passed as str argument

Parameters:cmd (str) – Absolute command line statement as would be run on command line
Returns:
  • stdout (str) – standard output as written by cmd program
  • stderr (str) – standard output as written by cmd program
  • returncode (int) – return code as returned by subprocess(not very informative in general)
moca.helpers.job_executor.safe_makedir(dname)[source]

Make a directory if it doesn’t exist, handling concurrent race conditions.

Credits: Brad Chapman for bcbio-nextgen: https://github.com/chapmanb/bcbio-nextgen/blob/master/bcbio/utils.py#L172

Parameters:dname (str) – Path of directory to be created

Module contents