{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Map To Protein Dimers Demo\n", "\n", "Example demonstrating how to extract protein dimers from PDB entries. This example uses a flatMap function to transform a strucure to its dimers.\n", "\n", "![Protein Dimers](https://upload.wikimedia.org/wikipedia/commons/thumb/c/ce/Galactose-1-phosphate_uridylyltransferase_1GUP.png/220px-Galactose-1-phosphate_uridylyltransferase_1GUP.png)\n", "\n", "## Imports" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from pyspark import SparkConf, SparkContext\n", "from mmtfPyspark.io import mmtfReader\n", "from mmtfPyspark.mappers import StructureToProteinDimers, StructureToBioassembly" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Configure Spark" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "conf = SparkConf().setMaster(\"local[*]\") \\\n", " .setAppName(\"MapToProteinDimersDemo\")\n", "sc = SparkContext(conf = conf)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download Protein *1STP* in MMTF format" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "protein = mmtfReader.download_mmtf_files([\"1STP\"], sc)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Map protein structure to Bioassembly, then map to protein dimers" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "cutoffDistance = 8.0\n", "contacts = 20\n", "useAllAtoms = False\n", "exclusive = True\n", "\n", "dimers = protein.flatMap(StructureToBioassembly()) \\\n", " .flatMap(StructureToProteinDimers(cutoffDistance, contacts, useAllAtoms, exclusive))\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Count number of structures" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of structures : 2\n" ] } ], "source": [ "print(f\"Number of structures : {dimers.count()}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Terminate Spark" ] }, { "cell_type": "code", "execution_count": 6, "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 }