panorama.utility package#
Subpackages#
- panorama.utility.translate package
- Submodules
- panorama.utility.translate.macsymodel_translator module
create_macsyfinder_hmm_list()find_cluster_canonical()find_type_subtype_canonical()get_models_path()parse_macsyfinder_hmm()process_attributes()process_exchangeable()search_canonical_macsyfinder()translate_functional_unit()translate_gene()translate_macsyfinder()translate_macsyfinder_model()
- panorama.utility.translate.padloc_translator module
- panorama.utility.translate.translate module
- Module contents
Submodules#
panorama.utility.genInput module#
- panorama.utility.genInput.create_hmm_list_file(hmm_path: List[Path], output: Path, metadata_df: DataFrame = None, hmm_coverage: float = None, target_coverage: float = None, binary_hmm: bool = False, recursive: bool = False, force: bool = False, disable_bar: bool = False) None#
Creates a TSV file containing information about the given HMM files.
- Parameters:
hmm_path (List[Path]) – The paths to the HMM files.
output (Path) – The path to the output directory.
metadata_df (pd.DataFrame, optional) – The metadata dataframe. Defaults to None.
hmm_coverage – Set a global value of HMM coverage threshold for all HMM. Defaults to None
target_coverage – Set a global value of the target coverage threshold for all targets. Defaults to None
binary_hmm – Rewrite the HMM in binary mode. Defaults False
recursive (bool, optional) – Whether to search for HMM files recursively in the given directory. Defaults to False.
force – Flag to erase and overwrite files in the output directory
disable_bar (bool, optional) – Whether to disable the progress bar. Defaults to False.
- Raises:
FileNotFoundError – If any of the given paths are not found.
Exception – If an unexpected error occurs.
- Returns:
None
- panorama.utility.genInput.generate_unique_accession(existing_accessions: Set[str]) str#
Generate a unique PANORAMA accession ID.
- Parameters:
existing_accessions (Set) – Set of existing accession IDs to avoid duplicates
- Returns:
str – Unique accession ID
- panorama.utility.genInput.parse_hmm_info(hmm: HMM, panorama_acc: Set[str], metadata: DataFrame = None) Dict[str, str | int]#
Parse the hmm information and set the new value if needed
- Parameters:
hmm – hmm filled with information
panorama_acc – Set of new accession number already given to not have duplicate
metadata – metadata dataframe to fill information
- Returns:
Dictionary with the parsed information
- panorama.utility.genInput.process_hmm_accession(hmm: HMM, panorama_acc: Set[str], hmm_dict: Dict[str, str | int | float]) Dict[str, str | int | float]#
Process or generate HMM accession ID.
- Parameters:
hmm (HMM) – HMM object
panorama_acc (Set) – Set of existing accession IDs
hmm_dict (Dict) – HMM dictionary to update
- Returns:
Dict – Updated HMM dictionary
- panorama.utility.genInput.process_hmm_name(hmm: HMM, hmm_file: Path, hmm_dict: Dict[str, str | int | float]) Dict[str, str | int | float]#
Process HMM name from the HMM object and file path.
- Parameters:
hmm (HMM) – HMM object
hmm_file (Path) – Path to HMM file
hmm_dict (Dict) – HMM dictionary to update
- Returns:
Dict – Updated HMM dictionary
- Raises:
IOError – If HMM name cannot be determined
- panorama.utility.genInput.read_hmm(hmm_path: Path) List[HMM]#
Read a HMM file to get a HMM object from pyHMMer.
- Parameters:
hmm_path – Path to the HMM file.
- Returns:
HMM object
- Raises:
Exception – if opening the HMM file failed
IOError – if there is a problem in HMM reading
- panorama.utility.genInput.read_metadata(metadata: Path) DataFrame#
Read metadata associate with HMM
- Parameters:
metadata (Path) – path to the metadata file
- Raises:
FileNotFoundError – If the metadata path is not found.
IOError – If the metadata path is not a file
ValueError – If the number of fields is unexpected
NameError – If the column names used in metadata are not allowed
- Returns:
str – metadata dataframe with hmm information
- panorama.utility.genInput.write_hmm(hmm: HMM, output: Path, binary: bool = False, name: bool = False) Path#
Write a HMM in text or binary
- Parameters:
hmm – hmm to write
output – Path to the output directory
binary – Flag to write the HMM in binary mode
name – Flag to une the name of the HMM as file name rather than the accession number
- Returns:
Path of the HMM file
panorama.utility.utility module#
This module provides some utilities function
- panorama.utility.utility.check_models(models_list: Path, disable_bar: bool = False) Models#
Checks all JSON files listed in models_list to ensure that they are valid models.
- Parameters:
models_list (Path) – paths to the models_list.tsv.
disable_bar (bool, optional) – Whether to disable the progress bar. Defaults to False.
- Returns
Models: A Models object to get all models
- Raises:
Exception – If a model is not readable.
- panorama.utility.utility.check_parameters(args: Namespace) None#
Checks the provided arguments to ensure that they are valid.
- Parameters:
args – The parsed arguments.
- Raises:
argparse.ArgumentError – If any required arguments are missing or invalid.
- panorama.utility.utility.create_models_list(models_path: List[Path], output: Path, recursive: bool = False, disable_bar: bool = False) None#
Create a file that listing models and path to them. Also, models are checked
- Parameters:
models_path (List[Path]) – List of paths to models
output (Path) – Directory to write models’ list file
recursive (bool, optional) – Flag to read models directory recursively (default: False)
disable_bar (bool, optional) – Flag to disable progress bar (default: False)
- panorama.utility.utility.launch(args: Namespace)#
Launches the utilities function for pangenomes.
- Parameters:
args – The parsed arguments.
- Returns:
None
- panorama.utility.utility.parser_utils(parser: ArgumentParser)#
Parser for the specific arguments of the utils command.
- Parameters:
parser (argparse.ArgumentParser) – The parser for the utils command.
- Returns:
None
- panorama.utility.utility.subparser(sub_parser: _SubParsersAction) ArgumentParser#
Subparser to launch PANORAMA in the command line.
- Parameters:
sub_parser (argparse._SubParsersAction) – The subparser for the utils command.
- Returns:
argparse.ArgumentParser – The parser for the utils command.