Open In Colab

Querying Multiple ProjectsΒΆ

This notebook demonstrates how to query and export metadata from multiple SRA projects at once.

[ ]:
# Install pysradb if not already installed
try:
    import pysradb

    print(f"pysradb {pysradb.__version__} is already installed")
except ImportError:
    print("Installing pysradb from GitHub...")
    import sys

    !{sys.executable} -m pip install -q git+https://github.com/saketkc/pysradb
    print("pysradb installed successfully!")
[1]:
# pip install git+https://github.com/saketkc/pysradb.git
[2]:
SRP_list = """ERP009675
ERP007116
ERP007115
ERP004563
ERP005660
ERP001266
ERP002072
ERP001882
ERP004883
ERP004508
ERP004393
ERP005409
ERP001464
ERP004042
ERP004375
ERP003293
ERP004689
ERP001094
ERP003728
ERP000730
ERP000411
ERP000319
SRP041183
SRP011912
SRP058392
SRP044705
SRP036841
SRP050120
ERP004116
SRP030662
SRP047217
SRP045505
ERP001556
ERP000546
SRP045252
SRP044714
DRP000524
SRP044907
SRP019970
SRP044131
SRP044042
SRP043602
SRP043523
SRP014570
SRP043067
SRP042370
SRP042360
SRP042159
SRP042085
SRP042053
SRP041992
SRP041738
SRP041679
SRP041669
SRP041622
SRP041182
SRP041377
SRP021009
SRP041216
SRP041129
SRP041119
SRP041044
SRP040761
SRP040479
SRP040072
SRP040070
SRP040121
SRP040044
SRP039841
SRP039779
SRP039717
SRP039699
SRP039672
SRP039661
SRP039646
SRP039634
SRP035451
SRP039551
SRP039478
SRP039440
SRP039448
SRP030474
SRP034507
SRP038004
SRP037780
SRP037583
SRP036068
SRP036637
SRP036632
SRP035368
SRP035278
SRP034930
SRP034844
ERP004159
SRP017087
SRP034444
SRP033229
SRP033198
SRP033021
ERP000964
ERP002429
SRP032928
SRP032833
SRP032792
SRP032766
ERP003855
ERP000904
SRP028229
SRP026361
SRP023111
SRP021139
SRP013319
SRP020006
SRP019994
SRP019500
SRP019241
SRP018672
SRP018358
SRP016875
SRP016501
SRP015460
SRP015370
SRP015135
SRP014437
SRP012378
SRP012018
SRP010103
SRP007831
SRP007412
SRP007400
SRP002090
SRP029153
SRP029445
SRP029427
SRP029380
SRP029330
SRP029333
ERP000606
ERP000415
ERP001977
ERP000373
SRP029172
SRP028766
ERP000668
ERP003627
SRP017364
SRP025757
SRP021189
SRP011154
SRP014574
SRP017935
SRP016889
SRP002016
SRP018826
SRP018753
SRP009821
SRP012925
SRP012850
SRP009870
SRP007799
SRP006748
SRP000373"""
SRP_list = SRP_list.split("\n")
[3]:
import sys
import time

from pysradb import SRAweb

db = SRAweb()

for srp in SRP_list:
    try:
        df = db.sra_metadata(srp)
        df.to_csv("{}.tsv".format(srp), sep="\t", index=False)
    except:
        sys.stderr.write("Error with {}\n".format(srp))
        time.sleep(0.5)
    time.sleep(0.5)
/home/saket/miniforge3/lib/python3.12/site-packages/pysradb/utils.py:14: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)
  from tqdm.autonotebook import tqdm
Error with SRP045252