{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Wild Type Query Demo\n", "\n", "This demo selects protein sequences that do not contain mutations in comparison with the reference UniProt sequences.\n", "\n", "Expression tags: Some PDB entries include expression tags that were added during the experiment. Select \"No\" to filter out sequences with expression tags. Percent coverage of UniProt sequence: PDB entries may contain only a portion of the referenced UniProt sequence. The \"Percent coverage of UniProt sequence\" option defines how much of a UniProt sequence needs to be contained in a PDB entry.\n", "\n", "\n", "## Imports" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from pyspark import SparkConf, SparkContext\n", "from mmtfPyspark.io import mmtfReader\n", "from mmtfPyspark.webfilters import WildTypeQuery" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Configure Spark" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "conf = SparkConf().setMaster(\"local[*]\") \\\n", " .setAppName(\"wildTypeQuery\")\n", "sc = SparkContext(conf = conf)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read in Hadoop Sequence Files and filter by WildType" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "path = \"../../resources/mmtf_reduced_sample/\"\n", "\n", "pdb = mmtfReader.read_sequence_file(path, sc) \\\n", " .filter(WildTypeQuery(includeExpressionTags = True, percentSequenceCoverage = WildTypeQuery.SEQUENCE_COVERAGE_95))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Count results and show top 5 structures" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of structures after filtering : 1440\n" ] }, { "data": { "text/plain": [ "[('1GBS', ),\n", " ('1GAX', ),\n", " ('1GAR', ),\n", " ('1GAL', ),\n", " ('1GAJ', )]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "count = pdb.count()\n", "\n", "print(f\"Number of structures after filtering : {count}\")\n", "\n", "pdb.top(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Terminate Spark" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "sc.stop()" ] } ], "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.6.0" } }, "nbformat": 4, "nbformat_minor": 2 }