mkt.databases.io_utils
File I/O helpers for CSV/dataframe round-tripping, tar creation, and kinase-dict loading.
Includes helpers to load and save dataframes, concatenate CSVs by glob, parse iterables into dataframes, create metadata-free tar archives, and load the packaged kinase dictionary.
Functions
Check if OUTPUT_DIR in environmental variables and create directory if doesn't exist. |
|
|
Use glob to find csv files to concatenate. |
|
Convert a string to a list. |
|
Create a tar file without metadata. |
Get the root of the git repository. |
|
|
Load a CSV file as a dataframe |
|
Parse an iterable containing Abstract Base Classes into a dataframe. |
|
Return a dictionary of kinase objects. |
|
Save a dataframe to a CSV file. |
- mkt.databases.io_utils.check_outdir_exists() str[source]
Check if OUTPUT_DIR in environmental variables and create directory if doesn’t exist.
- Returns:
Path to OUTPUT_DIR
- Return type:
str | None
- mkt.databases.io_utils.concatenate_csv_files_with_glob(str_find: str, str_remove: str = 'transformed_mutations.csv') DataFrame[source]
Use glob to find csv files to concatenate.
- Parameters:
str_find (str) – String to use to find files containing csv files of interest
- Returns:
Concatenated dataframe
- Return type:
pd.DataFrame
- mkt.databases.io_utils.convert_str2list(input_str: str) list[str][source]
Convert a string to a list.
- Parameters:
str (str) – String to convert to list
- Returns:
List of strings
- Return type:
list[str]
- mkt.databases.io_utils.create_tar_without_metadata(path_source: str, filename_tar: str) None[source]
Create a tar file without metadata.
- Parameters:
path_source (str) – Path to the source directory to be tarred
filename_tar (str) – Path and filename to the save the tar file
- Return type:
None
- mkt.databases.io_utils.get_repo_root()[source]
Get the root of the git repository.
- Returns:
Path to the root of the git repository; if not found, return current directory
- Return type:
str
- mkt.databases.io_utils.load_csv_to_dataframe(filename: str) None[source]
Load a CSV file as a dataframe
- Parameters:
filename (str) – Filename to load (either with or without “csv” suffix)
- Returns:
df – Dataframe loaded from CSV file
- Return type:
pd.DataFrame
- mkt.databases.io_utils.parse_iterabc2dataframe(input_object: iter, str_prefix: str | None = None, verbose: bool = True) DataFrame[source]
Parse an iterable containing Abstract Base Classes into a dataframe.
- Parameters:
input_object (iter) – Iterable of Abstract Base Classes objects
str_prefix (str | None, optional) – Prefix to add to the column names, by default None
- Returns:
Dataframe for the input list of Abstract Base Classes objects
- Return type:
pd.DataFrame
- mkt.databases.io_utils.return_kinase_dict(bool_hgnc: bool = True) dict[str, object][source]
Return a dictionary of kinase objects.
- Parameters:
bool_hgnc (bool, optional) – If True, return a dictionary of kinase objects with HGNC IDs, by default True
- Returns:
Dictionary of kinase objects with HGNC IDs as keys if bool_hgnc is True, otherwise with UniProt IDs as keys
- Return type:
dict[str, object]