{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example of using PySpark to find polymer interaction fingerprint\n", "\n", "Demo how to calculate polymer interaction data and maps it to polymer chains." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Imports and variables" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "scrolled": true }, "outputs": [], "source": [ "from pyspark import SparkConf, SparkContext \n", "from mmtfPyspark.io import mmtfReader\n", "from mmtfPyspark.interactions import InteractionFilter, InteractionFingerprinter\n", " \n", "# Create variables \n", "APP_NAME = \"MMTF_Spark\" \n", "\n", "# Configure Spark \n", "conf = SparkConf().setAppName(APP_NAME).setMaster(\"local[*]\") \n", "sc = SparkContext(conf=conf) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download 1OHR structure" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "pdb = mmtfReader.download_mmtf_files(['1OHR'], sc)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Find ASP-ARG salt bridges" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
structureChainIdqueryChainIdtargetChainIdgroupNumberssequenceIndicessequence
01OHR.ABA[8][7]PQITLWQRPLVTIKIGGQLKEALLDTGADDTVLEEMSLPGRWKPKM...
11OHR.BAB[8][7]PQITLWQRPLVTIKIGGQLKEALLDTGADDTVLEEMSLPGRWKPKM...
\n", "
" ], "text/plain": [ " structureChainId queryChainId targetChainId groupNumbers sequenceIndices \\\n", "0 1OHR.A B A [8] [7] \n", "1 1OHR.B A B [8] [7] \n", "\n", " sequence \n", "0 PQITLWQRPLVTIKIGGQLKEALLDTGADDTVLEEMSLPGRWKPKM... \n", "1 PQITLWQRPLVTIKIGGQLKEALLDTGADDTVLEEMSLPGRWKPKM... " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "interactionFilter = InteractionFilter(distanceCutoff=3.5, minInteractions=1)\n", "interactionFilter.set_query_groups(True, \"ASP\")\n", "interactionFilter.set_query_atom_names(True, ['OD1','OD2'])\n", "interactionFilter.set_target_groups(True, \"ARG\")\n", "interactionFilter.set_target_atom_names(True, ['NH1','NH2'])\n", "\n", "interactions = InteractionFingerprinter.get_polymer_interactions(pdb, interactionFilter)\n", "interactions.toPandas().head(10) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Terminate Spark" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sc.stop()" ] }, { "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.6.0" } }, "nbformat": 4, "nbformat_minor": 2 }