load
genie.load
¶
This module contains all the functions that stores data to Synapse
Attributes¶
__version__ = '17.0.0'
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Functions¶
store_file(syn, filepath, parentid, name=None, annotations=None, used=None, version_comment=None)
¶
Stores file into Synapse
| PARAMETER | DESCRIPTION |
|---|---|
syn
|
Synapse connection
TYPE:
|
filepath
|
Path to file
TYPE:
|
parentid
|
Synapse Id of a folder or project
TYPE:
|
name
|
Name of entity. Defaults to basename of your file path.
TYPE:
|
annotations
|
Synapse annotations to the File Entity. Defaults to None.
TYPE:
|
used
|
Entities used to generate file. Defaults to None.
TYPE:
|
version_comment
|
File Entity version comment. Defaults to None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
File
|
synapseclient.File: Synapse File entity |
Source code in genie/load.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
store_files(syn, filepaths, parentid)
¶
Stores a list of files
| PARAMETER | DESCRIPTION |
|---|---|
syn
|
Synapse connection
TYPE:
|
filepaths
|
List of filepaths
TYPE:
|
parentid
|
Synapse Id of a folder or project
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[File]
|
List[synapseclient.File]: List of Synaps File entities |
Source code in genie/load.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
store_table(syn, filepath, tableid)
¶
Stores a tsv to a Synapse Table. This can append, update, and delete rows in a Synapse table depending on how the tsv file is formatted.
| PARAMETER | DESCRIPTION |
|---|---|
syn
|
Synapse connection
TYPE:
|
filepath
|
Path to a TSV
TYPE:
|
tableid
|
Synapse Id of a Synapse Table
TYPE:
|
Source code in genie/load.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
update_process_trackingdf(syn, process_trackerdb_synid, center, process_type, start=True)
¶
Updates the processing tracking database
| PARAMETER | DESCRIPTION |
|---|---|
syn
|
Synapse connection
TYPE:
|
process_trackerdb_synid
|
Synapse Id of Process Tracking Table
TYPE:
|
center
|
GENIE center (ie. SAGE)
TYPE:
|
process_type
|
processing type (dbToStage or public)
TYPE:
|
start
|
Start or end of processing. Default is True for start
TYPE:
|
Source code in genie/load.py
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 | |
update_table(syn, databaseSynId, newData, filterBy, filterByColumn='CENTER', col=None, toDelete=False)
¶
Update Synapse table given a new dataframe
| PARAMETER | DESCRIPTION |
|---|---|
syn
|
Synapse connection
TYPE:
|
databaseSynId
|
Synapse Id of Synapse Table
TYPE:
|
newData
|
New data in a dataframe
TYPE:
|
filterBy
|
Value to filter new data by
TYPE:
|
filterByColumn
|
Column to filter values by. Defaults to "CENTER".
TYPE:
|
col
|
List of columns to ingest. Defaults to None.
TYPE:
|
toDelete
|
Delete rows given the primary key. Defaults to False.
TYPE:
|
Source code in genie/load.py
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 | |
_update_table(syn, database, new_dataset, database_synid, primary_key_cols, to_delete=False)
¶
A helper function to compare new dataset with existing data, and store any changes that need to be made to the database
Source code in genie/load.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
_get_col_order(orig_database_cols)
¶
Get column order
| PARAMETER | DESCRIPTION |
|---|---|
orig_database_cols
|
A list of column names of the original database
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
The list of re-ordered column names |
Source code in genie/load.py
196 197 198 199 200 201 202 203 204 205 206 207 208 | |
_reorder_new_dataset(orig_database_cols, new_dataset)
¶
Reorder new dataset based on the original database
| PARAMETER | DESCRIPTION |
|---|---|
orig_database_cols
|
A list of column names of the original database
TYPE:
|
new_dataset
|
New Data
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
The re-ordered new dataset |
Source code in genie/load.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
_generate_primary_key(dataset, primary_key_cols, primary_key)
¶
Generate primary key column a dataframe
| PARAMETER | DESCRIPTION |
|---|---|
dataset
|
A dataframe
TYPE:
|
primary_key_cols
|
Column(s) that make up the primary key
TYPE:
|
primary_key
|
The column name of the primary_key
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
pd.DataFrame: The dataframe with primary_key column added |
Source code in genie/load.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
check_database_changes(database, new_dataset, primary_key_cols, to_delete=False)
¶
Check changes that need to be made, i.e. append/update/delete rows to the database based on its comparison with new data
| PARAMETER | DESCRIPTION |
|---|---|
database
|
Original Data
TYPE:
|
new_dataset
|
New Data
TYPE:
|
primary_key_cols
|
Column(s) that make up the primary key
TYPE:
|
to_delete
|
Delete rows. Defaults to False
TYPE:
|
Source code in genie/load.py
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 | |
store_database(syn, database_synid, col_order, all_updates, to_delete_rows)
¶
Store changes to the database
| PARAMETER | DESCRIPTION |
|---|---|
syn
|
Synapse object
TYPE:
|
database_synid
|
Synapse Id of the Synapse table
TYPE:
|
col_order
|
The ordered column names to be saved
TYPE:
|
all_updates
|
rows to be appended and/or updated
TYPE:
|
to_deleted_rows
|
rows to be deleted
TYPE:
|
Source code in genie/load.py
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 | |
_copyRecursive(syn, entity, destinationId, mapping=None, skipCopyAnnotations=False, **kwargs)
¶
NOTE: This is a copy of the function found here: https://github.com/Sage-Bionetworks/synapsePythonClient/blob/develop/synapseutils/copy_functions.py#L409 This was copied because there is a restriction that doesn't allow for copying entities with access requirements
Recursively copies synapse entites, but does not copy the wikis
| PARAMETER | DESCRIPTION |
|---|---|
syn
|
A Synapse object with user's login
TYPE:
|
entity
|
A synapse entity ID
TYPE:
|
destinationId
|
Synapse ID of a folder/project that the copied entity is being copied to
TYPE:
|
mapping
|
A mapping of the old entities to the new entities
TYPE:
|
skipCopyAnnotations
|
Skips copying the annotations Default is False
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, str]
|
a mapping between the original and copied entity: {'syn1234':'syn33455'} |
Source code in genie/load.py
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 | |