{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/saketkc/pysradb/blob/develop/notebooks/06.Multiple_SRPs.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Querying Multiple Projects\n", "\n", "This notebook demonstrates how to query and export metadata from multiple SRA projects at once." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Install pysradb if not already installed\n", "try:\n", " import pysradb\n", "\n", " print(f\"pysradb {pysradb.__version__} is already installed\")\n", "except ImportError:\n", " print(\"Installing pysradb from GitHub...\")\n", " import sys\n", "\n", " !{sys.executable} -m pip install -q git+https://github.com/saketkc/pysradb\n", " print(\"pysradb installed successfully!\")" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 401 }, "colab_type": "code", "id": "kPEeKLC38WGX", "outputId": "45055cff-1f41-4b1d-f67f-0a4dc37a8333" }, "outputs": [], "source": [ "# pip install git+https://github.com/saketkc/pysradb.git" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": {}, "colab_type": "code", "id": "n-lUysUE8edh" }, "outputs": [], "source": [ "SRP_list = \"\"\"ERP009675\n", "ERP007116\n", "ERP007115\n", "ERP004563\n", "ERP005660\n", "ERP001266\n", "ERP002072\n", "ERP001882\n", "ERP004883\n", "ERP004508\n", "ERP004393\n", "ERP005409\n", "ERP001464\n", "ERP004042\n", "ERP004375\n", "ERP003293\n", "ERP004689\n", "ERP001094\n", "ERP003728\n", "ERP000730\n", "ERP000411\n", "ERP000319\n", "SRP041183\n", "SRP011912\n", "SRP058392\n", "SRP044705\n", "SRP036841\n", "SRP050120\n", "ERP004116\n", "SRP030662\n", "SRP047217\n", "SRP045505\n", "ERP001556\n", "ERP000546\n", "SRP045252\n", "SRP044714\n", "DRP000524\n", "SRP044907\n", "SRP019970\n", "SRP044131\n", "SRP044042\n", "SRP043602\n", "SRP043523\n", "SRP014570\n", "SRP043067\n", "SRP042370\n", "SRP042360\n", "SRP042159\n", "SRP042085\n", "SRP042053\n", "SRP041992\n", "SRP041738\n", "SRP041679\n", "SRP041669\n", "SRP041622\n", "SRP041182\n", "SRP041377\n", "SRP021009\n", "SRP041216\n", "SRP041129\n", "SRP041119\n", "SRP041044\n", "SRP040761\n", "SRP040479\n", "SRP040072\n", "SRP040070\n", "SRP040121\n", "SRP040044\n", "SRP039841\n", "SRP039779\n", "SRP039717\n", "SRP039699\n", "SRP039672\n", "SRP039661\n", "SRP039646\n", "SRP039634\n", "SRP035451\n", "SRP039551\n", "SRP039478\n", "SRP039440\n", "SRP039448\n", "SRP030474\n", "SRP034507\n", "SRP038004\n", "SRP037780\n", "SRP037583\n", "SRP036068\n", "SRP036637\n", "SRP036632\n", "SRP035368\n", "SRP035278\n", "SRP034930\n", "SRP034844\n", "ERP004159\n", "SRP017087\n", "SRP034444\n", "SRP033229\n", "SRP033198\n", "SRP033021\n", "ERP000964\n", "ERP002429\n", "SRP032928\n", "SRP032833\n", "SRP032792\n", "SRP032766\n", "ERP003855\n", "ERP000904\n", "SRP028229\n", "SRP026361\n", "SRP023111\n", "SRP021139\n", "SRP013319\n", "SRP020006\n", "SRP019994\n", "SRP019500\n", "SRP019241\n", "SRP018672\n", "SRP018358\n", "SRP016875\n", "SRP016501\n", "SRP015460\n", "SRP015370\n", "SRP015135\n", "SRP014437\n", "SRP012378\n", "SRP012018\n", "SRP010103\n", "SRP007831\n", "SRP007412\n", "SRP007400\n", "SRP002090\n", "SRP029153\n", "SRP029445\n", "SRP029427\n", "SRP029380\n", "SRP029330\n", "SRP029333\n", "ERP000606\n", "ERP000415\n", "ERP001977\n", "ERP000373\n", "SRP029172\n", "SRP028766\n", "ERP000668\n", "ERP003627\n", "SRP017364\n", "SRP025757\n", "SRP021189\n", "SRP011154\n", "SRP014574\n", "SRP017935\n", "SRP016889\n", "SRP002016\n", "SRP018826\n", "SRP018753\n", "SRP009821\n", "SRP012925\n", "SRP012850\n", "SRP009870\n", "SRP007799\n", "SRP006748\n", "SRP000373\"\"\"\n", "SRP_list = SRP_list.split(\"\\n\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 72 }, "colab_type": "code", "id": "1CWmd5rF8yny", "outputId": "519c91be-e3b9-48a3-fd47-fbe415bd0b2a" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/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)\n", " from tqdm.autonotebook import tqdm\n", "Error with SRP045252\n" ] } ], "source": [ "import sys\n", "import time\n", "\n", "from pysradb import SRAweb\n", "\n", "db = SRAweb()\n", "\n", "for srp in SRP_list:\n", " try:\n", " df = db.sra_metadata(srp)\n", " df.to_csv(\"{}.tsv\".format(srp), sep=\"\\t\", index=False)\n", " except:\n", " sys.stderr.write(\"Error with {}\\n\".format(srp))\n", " time.sleep(0.5)\n", " time.sleep(0.5)" ] } ], "metadata": { "colab": { "authorship_tag": "ABX9TyMmcvA8kJPyf4bhs59mCISs", "include_colab_link": true, "mount_file_id": "1pNeuZJjjHliYFk582kGNRpGJ1Fa2h9cn", "name": "07.Multiple_SRPs", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.11" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }