Readers
Functions for reading data files, mapping files, and networks.
base_name(file_path)
Get the base name from a path.
Example
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
Path | str
|
path of file to get base name of |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the base file name |
Source code in src/xlranker/util/readers.py
read_data_folder(folder_path, additional_null_values=[])
Reads all TSV files in a folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folder_path
|
str
|
path of the folder that contains files ending in .tsv |
required |
additional_null_values
|
list[str]
|
list of str of additional values that should considered as null in the data files |
[]
|
Raises:
Type | Description |
---|---|
FileNotFoundError
|
raised if no TSV files are found |
Returns:
Type | Description |
---|---|
dict[str, DataFrame]
|
list[pl.DataFrame]: list of all of the data files in a Polars DataFrame, as read by the read_data_matrix function |
Source code in src/xlranker/util/readers.py
read_data_matrix(data_path, additional_null_values=[])
Reads data matrix into a Polars DataFrame with samples/measurements being columns.
Format
- Has header (any names allowed).
- First column must be the protein/gene followed by measurements.
- Null/missing values: "", "NA". More can be added.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_path
|
str
|
path to the data matrix |
required |
additional_null_values
|
list[str]
|
list of str of additional values that should considered as null |
[]
|
Returns:
Type | Description |
---|---|
DataFrame
|
pl.DataFrame: Polars DataFrame of the input data |
Source code in src/xlranker/util/readers.py
read_mapping_table_file(file_path)
Read mapping file where the first column is the peptide sequence and the following columns are proteins that map to that sequence.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
path to the tab-separated mapping table |
required |
Source code in src/xlranker/util/readers.py
read_network_file(network_path)
Reads TSV network file to a list of PeptideGroup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
network_path
|
str
|
path to the TSV file |
required |
Returns:
Type | Description |
---|---|
dict[str, PeptidePair]
|
list[PeptideGroup]: list of PeptideGroup representing the network |