Utilities
nplinker.strain.utils
¶
create_strain_mappings
¶
create_strain_mappings(
strain_bgcs: dict[str, list[str]],
strain_features: dict[str, list[str]],
version: str,
filename: str,
) -> dict[str, Any]
Creates a dictionary for strain mappings based on strain IDs and their aliases.
Parameters:
-
strain_bgcs
(dict[str, list[str]]
) –dict that comes from extract_bgcs_genome_id
-
strain_features
(dict[str, list[str]]
) –dict that comes from extract_features_metabolome_id
-
version
(str
) –str representing the version of the data
-
filename
(str
) –str to save the JSON output
Returns:
Source code in src/nplinker/strain/utils.py
extract_bgcs_genome_id
¶
Extract bgcs based on the strain_genome mapping.
Parameters:
-
strain_genome
(dict[str, list[str]]
) –dict that comes from extract_strain_metadata function
-
bgc_path
(str | PathLike
) –path of the folder of antismash results
Returns:
-
dict
–A dict with the strains and bgcs
Source code in src/nplinker/strain/utils.py
extract_features_metabolome_id
¶
Extract features based on the strain_spectra mapping.
Parameters:
-
strain_spectra
(dict
) –dict that comes from extract_strain_metadata function
-
features_file
(str | PathLike
) –path of file of the gnps results
Returns:
-
dict
–A dict with the strains and features
Source code in src/nplinker/strain/utils.py
extract_strain_metadata
¶
Generate dict based on strain - genome, strain - spectra metadata info.
Parameters:
Returns:
Source code in src/nplinker/strain/utils.py
load_user_strains
¶
Load user specified strains from a JSON file.
The JSON file will be validated against the schema USER_STRAINS_SCHEMA
The content of the JSON file could be, for example:
Parameters:
Returns:
Source code in src/nplinker/strain/utils.py
merge_bgcs_features
¶
merge_bgcs_features(
strain_bgcs: dict[str, list[str]],
strain_features: dict[str, list[str]],
) -> dict[str, list[str]]
Merges dict based on the strains with the dict_bgcs and dict_features.
Parameters:
-
strain_bgcs
(dict[str, list[str]]
) –dict that comes from extract_bgcs_genome_id
-
strain_features
(dict[str, list[str]]
) –dict that comes from extract_features_metabolome_id
Returns:
Source code in src/nplinker/strain/utils.py
podp_generate_strain_mappings
¶
podp_generate_strain_mappings(
podp_project_json_file: str | PathLike,
genome_status_json_file: str | PathLike,
genome_bgc_mappings_file: str | PathLike,
gnps_file_mappings_file: str | PathLike,
output_json_file: str | PathLike,
) -> StrainCollection
Generate strain mappings JSON file for PODP pipeline.
To get the strain mappings, we need to combine the following mappings:
- strain_id <-> original_genome_id <-> resolved_genome_id <-> bgc_id
- strain_id <-> MS_filename <-> spectrum_id
These mappings are extracted from the following files:
- "strain_id <-> original_genome_id" is extracted from
podp_project_json_file
. - "original_genome_id <-> resolved_genome_id" is extracted from
genome_status_json_file
. - "resolved_genome_id <-> bgc_id" is extracted from
genome_bgc_mappings_file
. - "strain_id <-> MS_filename" is extracted from
podp_project_json_file
. - "MS_filename <-> spectrum_id" is extracted from
gnps_file_mappings_file
.
Parameters:
-
podp_project_json_file
(str | PathLike
) –The path to the PODP project JSON file.
-
genome_status_json_file
(str | PathLike
) –The path to the genome status JSON file.
-
genome_bgc_mappings_file
(str | PathLike
) –The path to the genome BGC mappings JSON file.
-
gnps_file_mappings_file
(str | PathLike
) –The path to the GNPS file mappings file (csv or tsv).
-
output_json_file
(str | PathLike
) –The path to the output JSON file.
Returns:
-
StrainCollection
–The strain mappings stored in a StrainCollection object.
See Also
extract_mappings_strain_id_original_genome_id
: Extract mappings "strain_id <-> original_genome_id".extract_mappings_original_genome_id_resolved_genome_id
: Extract mappings "original_genome_id <-> resolved_genome_id".extract_mappings_resolved_genome_id_bgc_id
: Extract mappings "resolved_genome_id <-> bgc_id".get_mappings_strain_id_bgc_id
: Get mappings "strain_id <-> bgc_id".extract_mappings_strain_id_ms_filename
: Extract mappings "strain_id <-> MS_filename".extract_mappings_ms_filename_spectrum_id
: Extract mappings "MS_filename <-> spectrum_id".get_mappings_strain_id_spectrum_id
: Get mappings "strain_id <-> spectrum_id".
Source code in src/nplinker/strain/utils.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|