hybkit.util

This module contains helper functions for hybkit’s command line scripts.

hybkit.util.dir_exists(dir_name)

Check if a directory exists at the provided path, and return a normalized path.

Parameters

dir_name (str) – Name of directory to check for existence.

Returns

A normalized version of the path passed to dir_name.

hybkit.util.file_exists(file_name, required_suffixes=[])

Check if a file exists at the provided path, and return a normalized path.

Parameters
  • file_name (str) – Name of file to check for existence.

  • required_suffixes (list, optional) – List of strings containing file-name suffixes. If provided, a file passed to file-exists must end with one of the strings provided. Otherwise an error will be raised.

Returns

A normalized version of the path passed to file_name.

hybkit.util.hyb_exists(file_name)

Check if a .hyb file exists at the provided path, and return a normalized path.

Wrapper for file_exists() that includes the required suffixes in hybkit.settings.HYB_SUFFIXES.

Parameters

file_name (str) – Name of file to check for existence.

Returns

A normalized version of the path passed to file_name.

hybkit.util.vienna_exists(file_name)

Check if a .vienna file exists at the provided path, and return a normalized path.

Wrapper for file_exists() that includes the required suffixes in hybkit.settings.VIENNA_SUFFIXES.

Parameters

file_name (str) – Name of file to check for existence.

Returns

A normalized version of the path passed to file_name.

hybkit.util.ct_exists(file_name)

Check if a .ct file exists at the provided path, and return a normalized path.

Wrapper for file_exists() that includes the required suffixes in hybkit.settings.CT_SUFFIXES.

Parameters

file_name (str) – Name of file to check for existence.

Returns

A normalized version of the path passed to file_name.

hybkit.util.fold_exists(file_name)

Check if a fold-representing file exists at the provided path, and return a normalized path.

Wrapper for file_exists() that includes the required suffixes in hybkit.settings.FOLD_SUFFIXES.

Parameters

file_name (str) – Name of file to check for existence.

Returns

A normalized version of the path passed to file_name.

hybkit.util.out_path_exists(file_name)

Check if the directory of the specified output path exists, and return a normalized path.

Parameters

file_name (str) – Name of path to an output file to check.

Returns

A normalized version of the path passed to file_name.

hybkit.util.make_out_file_name(in_file_name, name_suffix='out', in_suffix='', out_suffix='', out_dir='', seg_sep='_')

Given an input file name, generate an output file name.

Parameters
  • in_file_name (str) – Name of input file as template.

  • name_suffix (str) – Suffix to add to name before file type.

  • in_suffix (str) – File type suffix on in_file_name (to remove).

  • out_suffix (str) – File type suffix to add to final output file.

  • out_dir (str) – Directory path in which to place output file.

  • seg_sep (str) – Separator string between file name segements.

Returns

An output file path based on the input file template.

hybkit.util.validate_args(args, parser=None)

Check supplied arguments to make sure there are no hidden contradictions.

Current checks:
If explicit output file names supplied, be sure that they match the number of input files provided.
If fold files provided, make sure that they match the number of input hyb files provided.
Parameters
hybkit.util.set_settings(nspace, verbose=False)

Take a namespace object as from an argparse parser and update settings.

Each setting in the following settings dictionaries are checked and set where applicable:

Parameters
  • nspace (argparse.Namespace) – Namespace containing settings

  • verbose (bool, optional) – If True, print when changing setting.