dump
ensembl.io.genomio.events.dump
¶
Module to dump stable id events from an Ensembl Core database
BRC4_START_DATE = datetime(2020, 5, 1)
module-attribute
¶
DictToIdsSet = Dict[str, IdsSet]
module-attribute
¶
IdsSet = Set[str]
module-attribute
¶
DumpStableIDs
¶
An processor that create events from pairs of ids and can print those events out.
Attributes:
Name | Type | Description |
---|---|---|
server |
a core server set to a database, to retrieve the data from. |
Source code in src/python/ensembl/io/genomio/events/dump.py
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 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
|
session = session
instance-attribute
¶
extend_event(event, from_list, to_list)
¶
Given an event, aggregate ids in the 'from' and 'to' sets, to connect the whole group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event
|
Event
|
the event to extend. |
required |
from_list
|
DictToIdsSet
|
A dict a the from ids, and their corresponding to ids. |
required |
to_list
|
DictToIdsSet
|
A dict of the to ids, and their corresponding from ids. |
required |
Returns:
Type | Description |
---|---|
Event
|
A tuple of the extended event, and the from_list and to_list from which the ids that |
DictToIdsSet
|
have been added to the event have been removed. |
Source code in src/python/ensembl/io/genomio/events/dump.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
|
get_history()
¶
Retrieve all events from a database.
Returns:
Type | Description |
---|---|
List
|
A list of all events. |
Source code in src/python/ensembl/io/genomio/events/dump.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
get_mapping_sessions()
¶
Retrieve the mapping sessions from the connected database.
Returns:
Type | Description |
---|---|
List[MappingSession]
|
A list of sessions. |
Source code in src/python/ensembl/io/genomio/events/dump.py
355 356 357 358 359 360 361 362 363 364 |
|
get_pairs(session_id)
¶
Retrieve all pair of ids for a given session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id
|
int
|
id of a session from the connected database. |
required |
Returns:
Type | Description |
---|---|
List[Pair]
|
All pairs of IDs. |
Source code in src/python/ensembl/io/genomio/events/dump.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
|
get_pairs_from_to(pairs)
staticmethod
¶
From a list of Pairs, extract a mapping of all ids from a given old id (from_list), and a mapping of all ids to a given new id (to_list).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pairs
|
List[Pair]
|
list of Pairs. |
required |
Return
Tuple of 2 values: from_list to_list
Source code in src/python/ensembl/io/genomio/events/dump.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
|
make_events(pairs)
¶
Given a list of pairs, create events.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pairs
|
List[Pair]
|
list of Pair. |
required |
Return
A list of events.
Source code in src/python/ensembl/io/genomio/events/dump.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
|
print_events(events, output_file)
¶
Print events in a format for BRC.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
events
|
List[Event]
|
list of events for a given genome. |
required |
output_file
|
Path
|
where the events will be printed. |
required |
Source code in src/python/ensembl/io/genomio/events/dump.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
|
Event
¶
Represents a stable id event from one gene set version to another one. Various events: - new genes - deleted genes - merged genes (several genes to one) - split genes (one gene to several) - mixed (several genes to several)
Attributes:
Name | Type | Description |
---|---|---|
from_list |
List of genes the previous gene set. |
|
to_list |
List of genes in the new gene set. |
|
release |
New gene set release name. |
|
date |
Date of the new gene set. |
|
name |
Name of the event (will be updated automatically). |
|
pairs |
List[Pair]
|
All pair of ids for this event. |
Any gene set before 2019-09 is dubbed pre-BRC4.
Source code in src/python/ensembl/io/genomio/events/dump.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 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 |
|
date = date
instance-attribute
¶
from_set = self.clean_set(from_list)
instance-attribute
¶
name = ''
instance-attribute
¶
pairs = []
instance-attribute
¶
release = release
instance-attribute
¶
to_set = self.clean_set(to_list)
instance-attribute
¶
add_from(from_id)
¶
Store an id in the from_set.
Source code in src/python/ensembl/io/genomio/events/dump.py
205 206 207 208 |
|
add_pair(pair)
¶
Keeps a record of this pair.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pair
|
Pair
|
a Pair to record. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
can't add an empty pair. |
Source code in src/python/ensembl/io/genomio/events/dump.py
223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
add_pairs(pairs)
¶
Provided all the pairs, keep those that are used by this event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pairs
|
List[Pair]
|
list of Pair. |
required |
Source code in src/python/ensembl/io/genomio/events/dump.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
add_to(to_id)
¶
Store an id in the from_set.
Source code in src/python/ensembl/io/genomio/events/dump.py
210 211 212 213 |
|
brc_format_1()
¶
Returns a list events, one line per initial ID, in the following TSV format: - old gene id - event name - release - release date - list of old gene ids in the event (comma-separated) - list of new gene ids in the event (comma-separated)
Source code in src/python/ensembl/io/genomio/events/dump.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
brc_format_2()
¶
Returns a list of combination of genes, one line per combination of old_id - new_ids, in the following TSV format: - old gene id - new gene id - event name - release - release date
Source code in src/python/ensembl/io/genomio/events/dump.py
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 |
|
clean_pairs()
¶
Remove the empty old pairs when the event is not 'new'.
Source code in src/python/ensembl/io/genomio/events/dump.py
266 267 268 269 270 271 272 273 274 275 276 277 |
|
clean_set(this_list)
staticmethod
¶
Removes any empty elements from a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
this_list
|
Set
|
list of items, so of which can be empty/None. |
required |
Returns:
Type | Description |
---|---|
Set
|
The cleaned list. |
Source code in src/python/ensembl/io/genomio/events/dump.py
192 193 194 195 196 197 198 199 200 201 202 203 |
|
get_full_release()
¶
Returns the expanded release name, pre-BRC4 or BRC4 = build
.
Source code in src/python/ensembl/io/genomio/events/dump.py
237 238 239 240 241 242 243 244 245 246 247 |
|
get_name()
¶
Retrieve the name for this event, update it beforehand.
Source code in src/python/ensembl/io/genomio/events/dump.py
279 280 281 282 |
|
set_date(date)
¶
Set the date of the release for this event
Source code in src/python/ensembl/io/genomio/events/dump.py
219 220 221 |
|
set_release(release)
¶
Set the release name of the event
Source code in src/python/ensembl/io/genomio/events/dump.py
215 216 217 |
|
Pair
¶
Simple old_id - new_id pair representation
Source code in src/python/ensembl/io/genomio/events/dump.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
new_id = new_id
instance-attribute
¶
old_id = old_id if old_id is not None else ''
instance-attribute
¶
has_new_id()
¶
Check if the pair has a new_id
Source code in src/python/ensembl/io/genomio/events/dump.py
63 64 65 |
|
has_old_id()
¶
Check if the pair has an old_id
Source code in src/python/ensembl/io/genomio/events/dump.py
59 60 61 |
|
is_empty()
¶
Test if the current pair has no id.
Source code in src/python/ensembl/io/genomio/events/dump.py
67 68 69 70 |
|
UnsupportedEvent
¶
Bases: ValueError
If an event is not supported
Source code in src/python/ensembl/io/genomio/events/dump.py
73 74 |
|
main()
¶
Main entrypoint
Source code in src/python/ensembl/io/genomio/events/dump.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
|