{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem-2\n", "Calculate the average number of groups (residues) for protein chains." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from pyspark.sql import SparkSession\n", "from mmtfPyspark.io import mmtfReader\n", "from mmtfPyspark.filters import ContainsLProteinChain\n", "from mmtfPyspark.mappers import StructureToPolymerChains" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Configure Spark" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "spark = SparkSession.builder.appName(\"Solution-2\").getOrCreate()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Read PDB structures" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "path = \"../resources/mmtf_reduced_sample/\"\n", "pdb = mmtfReader.read_sequence_file(path)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TODO-1: Create an RDD of protein chains" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "prot_chains = ... your code here ..." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Map and Reduce" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TODO-2: Calculate the total number of groups (use num_groups)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "total_groups = ... your code here ..." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TODO-3: Calculate the average number of groups per protein chain" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "197.10918825374506" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "... your code here ..." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "spark.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.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }