Package geofetch Documentation
Package Overview
The geofetch package provides tools for downloading metadata and data from Gene Expression Omnibus (GEO) and Sequence Read Archive (SRA). It can convert GEO/SRA metadata into PEP format for easy integration with other PEPkit tools.
Key Features
- GEO/SRA Download: Fetch metadata and raw data from NCBI repositories
- PEP Generation: Automatically create PEP-formatted project configs
- Flexible Filtering: Search and filter GEO datasets by date and criteria
- SRA Integration: Download and convert SRA data to FASTQ format
- Processed Data: Download processed data matrices from GEO
Installation
pip install geofetch
Quick Example
from geofetch import Geofetcher
# Initialize geofetcher
gf = Geofetcher()
# Fetch a GEO series
gf.fetch_all(input="GSE####", name="my_project")
API Reference
Geofetcher Class
The main class for fetching data from GEO/SRA:
Geofetcher
Geofetcher(name='', metadata_root='', metadata_folder='', just_metadata=False, refresh_metadata=False, config_template=None, pipeline_samples=None, pipeline_project=None, skip=0, acc_anno=False, use_key_subset=False, processed=False, data_source='samples', filter=None, filter_size=None, geo_folder='.', split_experiments=False, bam_folder='', fq_folder='', sra_folder='', bam_conversion=False, picard_path='', input=None, const_limit_project=50, const_limit_discard=1000, attr_limit_truncate=500, max_soft_size='1GB', discard_soft=False, add_dotfile=False, disable_progressbar=False, add_convert_modifier=False, opts=None, max_prefetch_size=None, **kwargs)
Class to download or get projects, metadata, data from GEO and SRA
Constructor
:param input: GSEnumber or path to the input file :param name: Specify a project name. Defaults to GSE number or name of accessions file name :param metadata_root: Specify a parent folder location to store metadata. The project name will be added as a subfolder [Default: $SRAMETA:] :param metadata_folder: Specify an absolute folder location to store metadata. No subfolder will be added. Overrides value of --metadata-root [Default: Not used (--metadata-root is used by default)] :param just_metadata: If set, don't actually run downloads, just create metadata :param refresh_metadata: If set, re-download metadata even if it exists. :param config_template: Project config yaml file template. :param pipeline_samples: Specify one or more filepaths to SAMPLES pipeline interface yaml files. These will be added to the project config file to make it immediately compatible with looper. [Default: null] :param pipeline_project: Specify one or more filepaths to PROJECT pipeline interface yaml files. These will be added to the project config file to make it immediately compatible with looper. [Default: null] :param acc_anno: Produce annotation sheets for each accession. Project combined PEP for the whole project won't be produced. :param discard_soft: Create project without downloading soft files on the disc :param add_dotfile: Add .pep.yaml file that points .yaml PEP file :param disable_progressbar: Set true to disable progressbar
:param const_limit_project: Optional: Limit of the number of the constant sample characters that should not be in project yaml. [Default: 50] :param const_limit_discard: Optional: Limit of the number of the constant sample characters that should not be discarded [Default: 250] :param attr_limit_truncate: Optional: Limit of the number of sample characters. Any attribute with more than X characters will truncate to the first X, where X is a number of characters [Default: 500]
:param max_soft_size: Optional: Max size of soft file. Supported input formats : 12B, 12KB, 12MB, 12GB. [Default value: 1GB]
:param processed: Download processed da_soft_sizeta [Default: download raw data]. :param data_source: Specifies the source of data on the GEO record to retrieve processed data, which may be attached to the collective series entity, or to individual samples. Allowable values are: samples, series or both (all). Ignored unless 'processed' flag is set. [Default: samples] :param filter: Filter regex for processed filenames [Default: None].Ignored unless 'processed' flag is set. :param filter_size: Filter size for processed files that are stored as sample repository [Default: None]. Works only for sample data. Supported input formats : 12B, 12KB, 12MB, 12GB. Ignored unless 'processed' flag is set. :param geo_folder: Specify a location to store processed GEO files. Ignored unless 'processed' flag is set.[Default: $GEODATA:]
:param split_experiments: Split SRR runs into individual samples. By default, SRX experiments with multiple SRR Runs will have a single entry in the annotation table, with each run as a separate row in the subannotation table. This setting instead treats each run as a separate sample [Works with raw data] :param bam_folder: Optional: Specify folder of bam files. Geofetch will not download sra files when corresponding bam files already exist. [Default: $SRABAM:][Works with raw data] :param fq_folder: Optional: Specify folder of fastq files. Geofetch will not download sra files when corresponding fastq files already exist. [Default: $SRAFQ:][Works with raw data] :param use_key_subset: Use just the keys defined in this module when writing out metadata. [Works with raw data] :param sra_folder: Optional: Specify a location to store sra files [Default: $SRARAW:" + safe_echo("SRARAW") + ] :param bam_conversion: Optional: set True to convert bam files [Works with raw data] :param picard_path: Specify a path to the picard jar, if you want to convert fastq to bam [Default: $PICARD:" + safe_echo("PICARD") + "] [Works with raw data] :param add_convert_modifier: Add looper SRA convert modifier to config file.
:param skip: Skip some accessions. [Default: no skip]. :param opts: opts object [Optional] :param str | int max_prefetch_size: argmuent to prefetch command's --max-size option; for reference: https://github.com/ncbi/sra-tools/wiki/08.-prefetch-and-fasterq-dump#check-the-maximum-size-limit-of-the-prefetch-tool :param kwargs: other values
Source code in geofetch/geofetch.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 | |
fetch_all
fetch_all(input, name=None)
Main function driver/workflow Function that search, filters, downloads and save data and metadata from GEO and SRA :param input: GSE or input file with gse's :param name: Name of the project :return: NoReturn or peppy Project
Source code in geofetch/geofetch.py
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 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | |
fetch_processed_one
fetch_processed_one(gse_file_content, gsm_file_content, gsm_filter_list)
Fetche one processed GSE project and return its metadata :param gsm_file_content: gse soft file content :param gse_file_content: gsm soft file content :param gsm_filter_list: list of gsm that have to be downloaded :return: Tuple of project list of gsm samples and gse samples
Source code in geofetch/geofetch.py
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 | |
get_projects
get_projects(input, just_metadata=True, discard_soft=True)
Function for fetching projects from GEO|SRA and receiving peppy project :param input: GSE number, or path to file of GSE numbers :param just_metadata: process only metadata :param discard_soft: clean run, without downloading soft files :return: peppy project or list of project, if acc_anno is set.
Source code in geofetch/geofetch.py
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 | |
Finder Class
Class for searching and finding GSE accessions:
Finder
Finder(filters=None, retmax=RETMAX)
Class for finding GSE accessions in special period of time. Additionally, user can add specific filters for the search, while initialization of the class
:param filters: filters that have to be added to the query. Filter Patterns can be found here: https://www.ncbi.nlm.nih.gov/books/NBK3837/#EntrezHelp.Using_the_Advanced_Search_Pag :param retmax: maximum number of retrieved accessions.
Source code in geofetch/finder.py
36 37 38 39 40 41 42 43 44 45 | |
find_differences
staticmethod
find_differences(old_list, new_list)
Compare 2 lists and search for elements that are not in old list :param old_list: old list of elements :param new_list: new list of elements :return: list of elements that are not in old list but are in new_list
Source code in geofetch/finder.py
112 113 114 115 116 117 118 119 120 | |
generate_file
generate_file(file_path, gse_list=None)
Save the list of GSE accessions stored in this Finder object to a given file :param file_path: root to the file where gse accessions have to be saved :param gse_list: list of gse accessions :return: NoReturn
Source code in geofetch/finder.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
get_gse_all
get_gse_all()
Get list of all gse accession available in GEO :return: list of gse accession
Source code in geofetch/finder.py
47 48 49 50 51 52 | |
get_gse_by_date
get_gse_by_date(start_date, end_date=None)
Search gse accessions by providing start date and end date. By default, the last date is today. :param start_date: the oldest date of update (from YYYY/MM/DD to now) [input format: 'YYYY/MM/DD'] :param end_date: the nearest date of update (from __ to YYYY/MM/DD) [input format: 'YYYY/MM/DD'] :return: list of gse accessions
Source code in geofetch/finder.py
79 80 81 82 83 84 85 86 87 88 89 | |
get_gse_by_day_count
get_gse_by_day_count(n_days=1)
Get list of gse accessions that were uploaded or updated in last X days :param n_days: number of days from now [e.g. 5] :return: list of gse accession
Source code in geofetch/finder.py
68 69 70 71 72 73 74 75 76 77 | |
get_gse_id_by_query
get_gse_id_by_query(url)
Run esearch (ncbi search tool) by specifying URL and retrieve gse list result :param url: url of the query :return: list of gse ids
Source code in geofetch/finder.py
91 92 93 94 95 96 97 98 99 100 | |
get_gse_last_3_month
get_gse_last_3_month()
Get list of gse accession that were uploaded or updated in last 3 month :return: list of gse accession
Source code in geofetch/finder.py
54 55 56 57 58 59 | |
get_gse_last_week
get_gse_last_week()
Get list of gse accession that were uploaded or updated in last week :return: list of gse accession
Source code in geofetch/finder.py
61 62 63 64 65 66 | |
uid_to_gse
staticmethod
uid_to_gse(uid)
UID to GES accession converter :param uid: uid string (Unique Identifier Number in GEO) :return: GSE id string
Source code in geofetch/finder.py
102 103 104 105 106 107 108 109 110 | |