{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import collections\n", "import requests\n", "import re\n", "import os\n", "import csv" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# url of a search through MeSH which has empty terms\n", "MeSH_url = 'http://www.nlm.nih.gov/cgi/mesh/2015/MB_cgi?mode=&term='" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Function (MeSH_match) to take a single disease MeSH name, search the 2014\n", "# MeSH database, and extract the unique MeSH ID associated with that disease.\n", "# Returns a two membered list including the disease name, followed by the unique MeSH ID\n", "def MeSH_match(disease):\n", " disease_edit = disease.replace(' ', '+')\n", " url = MeSH_url + disease_edit\n", " returned = requests.get(url)\n", " returned = returned.text\n", " sub_returned = re.search('Unique ID