{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Use Pubmed-Sieve to build a PubMed query and RSS Feed from a Google Sheet.\n",
    "\n",
    "**Tutorial Here:**: https://hershbhargava.com/writing/adaptively-following-the-scientific-literature/\n",
    "\n",
    "**Example Google Sheet Here:** https://docs.google.com/spreadsheets/d/1HD52dXGvVEHbBejDzUAzVhsvi_T3RT99uNhGzHZlQjo\n",
    "\n",
    "**Google Sheet Template Here (File > Make a Copy):** https://docs.google.com/spreadsheets/d/181rDSN6aB1zjKiPIP4Ai6bRNnnXx6GTPqNsVxNk1kB8\n",
    "\n",
    "<span style=\"color: red;\">**_Make sure your sheet permissions are set to 'Anyone with the Link can View'_**</span>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Paste your sheet URL in place of mine below.\n",
    "\n",
    "then run all cells to get your output."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "url = \"https://docs.google.com/spreadsheets/d/1HD52dXGvVEHbBejDzUAzVhsvi_T3RT99uNhGzHZlQjo\"\n",
    "\n",
    "feed_name = 'Your Pubmed-Sieve Feed'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pubmed-sieve parsed spreadsheet with id: 1HD52dXGvVEHbBejDzUAzVhsvi_T3RT99uNhGzHZlQjo\n",
      "pubmed-sieve building query with 25 authors, 11 keywords, and 32 journals.\n",
      "\n",
      "Pubmed RSS Feed URL: https://pubmed.ncbi.nlm.nih.gov/rss/search/14CrWYUMC68Pd_R7Pp4qfdfHrf0Eawoet00pbnX1DsFraUssB3/?limit=100&utm_campaign=pubmed-2&fc=20230810141542\n",
      "\n",
      "Raw Pubmed Query String (try pasting it here: https://pubmed.ncbi.nlm.nih.gov/): \n",
      "\n",
      "(((Aviv Regev[FAU] AND (Regev A[1au] OR Regev A[lastau]))) OR ((Carl H June[FAU] AND June CH[lastau])) OR ((Crystal L Mackall[FAU])) OR ((David Baker[FAU] AND (Baker D[1au] OR Baker D[lastau])) AND (University of Washington[affil])) OR ((David R Liu[FAU] AND Liu DR[1au]) AND (Harvard[affil])) OR ((Edward S Boyden[FAU])) OR ((Feng Zhang[FAU]) AND (Massachusetts Institute[affil] OR 0000-0003-0178-7995[auid])) OR ((George M Church[FAU] AND Church GM[lastau])) OR ((Hana El-Samad[FAU])) OR ((Ira Mellman[FAU])) OR ((James A Wells[FAU])) OR ((James E Ferrell[FAU])) OR ((James J Collins[FAU])) OR ((James P Allison[FAU])) OR ((Jennifer Doudna[FAU])) OR ((Karl Deisseroth[FAU])) OR ((Kevan M Shokat[FAU])) OR ((Lei Stanley Qi[FAU])) OR ((Michael B Elowitz[FAU])) OR ((Michel Sadelain[FAU])) OR ((Ronald D Vale[FAU])) OR ((Steven A Rosenberg[FAU] AND Rosenberg SA[lastau])) OR ((Uri Alon[FAU])) OR ((Wendell A Lim[FAU])) OR ((Hersh K Bhargava[FAU])) AND hasabstract) OR (((\"chimeric antigen receptor\"[tiab]) OR (\"car-t\"[tiab]) OR (\"car t\"[tiab]) OR (\"synnotch\"[tiab]) OR (\"synthetic notch\"[tiab]) OR (\"cell therapy\"[tiab]) OR (\"cell engineering\"[tiab]) OR (\"IL-2\"[tiab]) OR (\"interleukin-2\"[tiab]) OR (\"interleukin 2\"[tiab]) OR (\"cd25\"[tiab])) AND ((\"Cell\"[journal]) OR (\"Science\"[journal]) OR (\"Nature*\"[journal]) OR (\"N Engl J Med\"[journal]) OR (\"Lancet*\"[journal]) OR (\"JAMA*\"[journal]) OR (\"Blood Adv\"[journal]) OR (\"Blood\"[journal]) OR (\"Proc Natl Acad Sci U S A\"[journal]) OR (\"J Clin Oncol\"[journal]) OR (\"PLoS Computational Biology\"[journal]) OR (\"PLoS Biology\"[journal]) OR (\"Science Advances\"[journal]) OR (\"Neuron\"[journal]) OR (\"ACS Synthetic Biology\"[journal]) OR (\"Cell Reports\"[journal]) OR (\"Cell Systems\"[journal]) OR (\"Science Signaling\"[journal]) OR (\"Science Immunology\"[journal]) OR (\"Front Immunol\"[journal]) OR (\"Science Translational Medicine\"[journal]) OR (\"J Clin Invest\"[journal]) OR (\"J Immunol\"[journal]) OR (\"Elife\"[journal]) OR (\"bioRxiv\"[journal]) OR (\"Cancer Research\"[journal]) OR (\"Clin Cancer Res\"[journal]) OR (\"Immunity\"[journal]) OR (\"J Theor Biol\"[journal]) OR (\"Cancer Cell\"[journal]) OR (\"Annu Rev*\"[journal]) OR (\"Blood Rev\"[journal])) AND hasabstract)\n"
     ]
    }
   ],
   "source": [
    "import pubmed_sieve as sieve\n",
    "\n",
    "# Generate the query\n",
    "query = sieve.build_query_from_spreadsheet_url(url)\n",
    "\n",
    "# Generate the RSS link (requires Chromium browser)\n",
    "rss_url = sieve.gen_pubmed_rss_link_for_query(feed_name=feed_name, query_string=query)\n",
    "\n",
    "print('\\nPubmed RSS Feed URL: %s' % rss_url)\n",
    "print('\\nRaw Pubmed Query String (try pasting it here: https://pubmed.ncbi.nlm.nih.gov/): \\n\\n%s' % query)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "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.11.2"
  },
  "vscode": {
   "interpreter": {
    "hash": "1ee38ef4a5a9feb55287fd749643f13d043cb0a7addaab2a9c224cbe137c0062"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}