Created
March 18, 2016 12:17
-
-
Save Swarchal/c4ea4a1e2092218dfead to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "# Calculate the mass of a protein\n", | |
| "\n", | |
| "Given a sequence of $\\alpha \\alpha$, return the protein mass. Borin' 'ell." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "97162.90325\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "p_mass = {\n", | |
| " 'A' : 71.03711,\n", | |
| " 'C' : 103.00919,\n", | |
| " 'D' : 115.02694,\n", | |
| " 'E' : 129.04259,\n", | |
| " 'F' : 147.06841,\n", | |
| " 'G' : 57.02146,\n", | |
| " 'H' : 137.05891,\n", | |
| " 'I' : 113.08406,\n", | |
| " 'K' : 128.09496,\n", | |
| " 'L' : 113.08406,\n", | |
| " 'M' : 131.04049,\n", | |
| " 'N' : 114.04293,\n", | |
| " 'P' : 97.05276,\n", | |
| " 'Q' : 128.05858,\n", | |
| " 'R' : 156.10111,\n", | |
| " 'S' : 87.03203,\n", | |
| " 'T' : 101.04768,\n", | |
| " 'V' : 99.06841,\n", | |
| " 'W' : 186.07931,\n", | |
| " 'Y' : 163.06333\n", | |
| "}\n", | |
| "\n", | |
| "def protein_mass(path):\n", | |
| " aa = open(path).read().strip()\n", | |
| " return sum([p_mass[i] for i in aa])\n", | |
| "\n", | |
| "print protein_mass(\"rosalind_prtm.txt\")" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 2", | |
| "language": "python", | |
| "name": "python2" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 2 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython2", | |
| "version": "2.7.6" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment