Mappers
Mapping related classes and functions.
FastaType
MappingResult
dataclass
Results from mapping peptide sequences to proteins.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
peptide_to_protein
|
dict[str, list[str]]
|
Dictionary where keys are peptide sequences and values are the list of proteins that map to that sequence. |
required |
protein_sequences
|
dict[str, str] | None
|
Optional dictionary where keys are protein names and values are those proteins sequence. Used for linkage location. None if sequence not available (i.e. mapping table) |
required |
Source code in src/xlranker/util/mapping.py
PeptideMapper
Peptide mapper class.
Raises:
Type | Description |
---|---|
ValueError
|
Raises error if there is an issue with mapping tables |
Source code in src/xlranker/util/mapping.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 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 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
|
__init__(mapping_table_path=None, split_by='|', split_index=3, is_fasta=True, fasta_type=FastaType.UNIPROT)
Initialize PeptideMapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mapping_table_path
|
str | None
|
Path to mapping table. Can be in fasta or mapping table. If none, then uses the default uniprot version Defaults to None. |
None
|
split_by
|
str
|
character in fasta description to split into id components. Defaults to "|". |
'|'
|
split_index
|
int
|
index of gene symbol in fasta file. Defaults to 3. |
3
|
is_fasta
|
bool
|
is input file fasta file. Defaults to True. |
True
|
fasta_type
|
FastaType
|
Type of FASTA header. Can be UNIPROT or GENCODE |
UNIPROT
|
Source code in src/xlranker/util/mapping.py
from_config(mapping_config)
staticmethod
Create a PeptideMapper from a MappingConfig object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mapping_config
|
MappingConfig
|
mapping config to build PeptideMapper. |
required |
Returns:
Name | Type | Description |
---|---|---|
PeptideMapper |
PeptideMapper
|
PeptideMapper built according to config options. |
Source code in src/xlranker/util/mapping.py
map_fasta(sequences)
Map the provided sequences to proteins using a FASTA file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequences
|
list[str]
|
list of peptide sequences to map. |
required |
Returns:
Name | Type | Description |
---|---|---|
MappingResult |
MappingResult
|
Result of the mapping. |
Source code in src/xlranker/util/mapping.py
map_fasta_no_reduction(sequences)
Maps the provided sequences to proteins using the original FASTA file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequences
|
list[str]
|
list of peptide sequences to map. |
required |
Returns:
Name | Type | Description |
---|---|---|
MappingResult |
MappingResult
|
Result of the mapping. |
Source code in src/xlranker/util/mapping.py
map_fasta_with_reduction(sequences)
Maps the provided sequences to proteins with a modified FASTA file where only the longest sequence is kept for duplicated proteins.
Duplicate proteins are proteins that share the same gene symbol identification.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequences
|
list[str]
|
list of peptide sequences to map. |
required |
Returns:
Name | Type | Description |
---|---|---|
MappingResult |
MappingResult
|
Result of the mapping. |
Source code in src/xlranker/util/mapping.py
map_sequences(sequences)
Map a list of sequences to genes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequences
|
list[str]
|
list of sequences to map to genes |
required |
Returns:
Type | Description |
---|---|
MappingResult
|
dict[str, list[str]]: dictionary where keys are peptide sequences values are list of genes that map to that sequence |
Source code in src/xlranker/util/mapping.py
convert_str_to_fasta_type(possible_type)
Convert string to FastaType enum. Case insensitive.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
possible_type
|
str
|
string to convert to FastaType. |
required |
Returns:
Name | Type | Description |
---|---|---|
FastaType |
FastaType
|
FastaType.GENCODE if possible_type is GENCODE. FastaType.UNIPROT for all other cases. |
Source code in src/xlranker/util/mapping.py
extract_gene_symbol(fasta_description, fasta_type, **kwargs)
Extract the gene symbol from a FASTA entry based on fasta_type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fasta_description
|
str
|
FASTA entry string |
required |
fasta_type
|
FastaType
|
FastaType of the FASTA file. Either UNIPROT or GENCODE |
required |
**kwargs
|
See below. |
{}
|
Kwargs
split_by (str): Character to split description string. Only used if FastaType is GENCODE. split_index (str): Index (0-based) of gene symbol after splitting. All characters after first space are removed. Only used if FastaType is GENCODE.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the gene symbol extracted from the FASTA entry |
Source code in src/xlranker/util/mapping.py
extract_gene_symbol_gencode(fasta_description, **kwargs)
Get the gene symbol from a UNIPROT style FASTA description.
Method:
- Split the description by spaces
- Find split with GN= (Gene Name)
- Remove GN= from split and return
If split with GN= not found, return the UNIPROT symbol.
- Using first split (when splitting by space), split again by |
- If there is at least 2 elements in split, return second element
If can't get UNIPROT symbol, return original description.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fasta_description
|
str
|
FASTA description string |
required |
**kwargs
|
See below. |
{}
|
Kwargs
split_by (str): Character to split description string split_index (str): Index (0-based) of gene symbol after splitting. All characters after first space are removed.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Gene Symbol from description. If can't be extracted, return original description |
Source code in src/xlranker/util/mapping.py
extract_gene_symbol_uniprot(fasta_description)
Get the gene symbol from a UNIPROT style FASTA description.
Method:
- Split the description by spaces
- Find split with GN= (Gene Name)
- Remove GN= from split and return
If split with GN= not found, return the UNIPROT symbol.
- Using first split (when splitting by space), split again by |
- If there is at least 2 elements in split, return second element
If can't get UNIPROT symbol, return original description.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fasta_description
|
str
|
FASTA description string |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Gene Symbol from description. If can't be extracted, try getting UNIPROT ID. If all fails, return original description |