IO Modules
Module for reading and writing files.
create_config(args=None)
Write the default configuration file to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace | None
|
Optional arguments to parse. |
None
|
Source code in isoslam/io.py
data_frame_to_file(data, output_dir='./output/', outfile='summary_counts.tsv', sep='\t', **kwargs)
Write a Pandas DataFrame to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame | DataFrame
|
Pandas DataFrame to write to disk. |
required |
output_dir
|
str | Path
|
Location to write the output to, default is ''./output''.capitalize. |
'./output/'
|
outfile
|
str
|
Filename to write data to. |
'summary_counts.tsv'
|
sep
|
str
|
Separator to use in output file. |
'\t'
|
**kwargs
|
dict[Any, Any]
|
Dictionary of keyword arguments to pass to ''pandas.DataFrame.to_csv()''. |
{}
|
Source code in isoslam/io.py
load_and_update_config(args)
Load a configuration file to dictionary and update entries with user supplied arguments.
If ''args'' does not contain any value for ''args.config_file'' the default configuration (''isoslam/default_config.yaml'') is loaded, otherwise the user specified configuration is loaded.
Once the configuration is loaded any user specified options update the dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Arguments supplied by user. |
required |
Returns:
| Type | Description |
|---|---|
dict[str:Any]
|
Dictionary of configuration optionsupdated with user specified options. |
Source code in isoslam/io.py
load_file(file_path)
Load files of different types.
Supports the following file types...
.bam- The sequence data that is to be analysed..bed- The locations of introns/splice junctions..gtf- Transcript structures from which the.bedfile is derived..vcf- Locations of known sequences difference from the reference sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | Path
|
Path to file to load. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Returns the loaded file as an object. |
Source code in isoslam/io.py
load_output_files(file_ext='.tsv', directory=None)
Read a set of files into a list of Polars DataFrames.
Supports reading ''.parquet'', ''.tsv'' and .csv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_ext
|
str
|
File name pattern to search for. |
'.tsv'
|
directory
|
str | Path | None
|
Directory to search for files. |
None
|
Returns:
| Type | Description |
|---|---|
list[DataFrame]
|
A list of Polars DataFrames of each file found. |
Source code in isoslam/io.py
read_yaml(filename=None)
Read a YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Union[str, Path]
|
YAML file to read. |
None
|
Returns:
| Type | Description |
|---|---|
Dict
|
Dictionary of the file. |
Source code in isoslam/io.py
write_assigned_conversions(assigned_conversions, coverage_counts, read_uid, assignment, outfile, delim)
Write assigned conversions to files.
Combines the ''coverage_counts'' with the ''assigned_conversions'' and outputs to disk at the specified location and filename with configurable delimiter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assigned_conversions
|
set[list[Any]]
|
A set of assigned conversions. Each element of the set is a list of key features (CHECK WHAT THESE ARE). |
required |
coverage_counts
|
dict[str, int] dest_dir: str | Path
|
A dictionary of coverage counts indexed by CHECK. |
required |
read_uid
|
int
|
Integer representing the unique read ID. |
required |
assignment
|
str
|
Type of assignment, either ''Rep'' or ''Spl'' (for Splice). |
required |
outfile
|
Any
|
Open connection to write results to. |
required |
delim
|
str
|
Delimiter to be used between fields, typically '','' for ''.csv'' or ''\t'' for ''.tsv'' output. |
required |
Source code in isoslam/io.py
write_yaml(config, output_dir, config_file='config.yaml', header_message=None)
Write a configuration (stored as a dictionary) to a YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict
|
Configuration dictionary. |
required |
output_dir
|
Union[str, Path]
|
Path to save the dictionary to as a YAML file (it will be called 'config.yaml'). |
required |
config_file
|
str
|
Filename to write to. |
'config.yaml'
|
header_message
|
str
|
String to write to the header message of the YAML file. |
None
|