Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.41 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "<table>\n",
  8. "<tr>\n",
  9. "<th>dna_seq</th>\n",
  10. "<th>length</th>\n",
  11. "</tr>\n",
  12. "<tr>\n",
  13. "<td><span style = \"color: blue;\">A</span><span style = \"color: red;\">C</span><span style = \"color: green;\">G</span><span style = \"color: yellow;\">T</span><span style = \"color: green;\">G</span><span style = \"color: red;\">C</span><span style = \"color: blue;\">A</span></td>\n",
  14. "<td>7</td>\n",
  15. "</tr>\n",
  16. "<tr>\n",
  17. "<td><span style = \"color: blue;\">A</span><span style = \"color: red;\">C</span><span style = \"color: red;\">C</span></td>\n",
  18. "<td>3</td>\n",
  19. "</tr>\n",
  20. "</table>\n"
  21. ]
  22. },
  23. {
  24. "cell_type": "code",
  25. "execution_count": 29,
  26. "metadata": {
  27. "collapsed": false
  28. },
  29. "outputs": [
  30. {
  31. "data": {
  32. "text/html": [
  33. "<div>\n",
  34. "<table border=\"0\" class=\"dataframe\">\n",
  35. " <thead>\n",
  36. " <tr style=\"text-align: right;\">\n",
  37. " <th></th>\n",
  38. " <th>dna_seq</th>\n",
  39. " <th>length</th>\n",
  40. " </tr>\n",
  41. " </thead>\n",
  42. " <tbody>\n",
  43. " <tr>\n",
  44. " <th>0</th>\n",
  45. " <td>ACGTGCA</td>\n",
  46. " <td>7</td>\n",
  47. " </tr>\n",
  48. " <tr>\n",
  49. " <th>1</th>\n",
  50. " <td>ACC</td>\n",
  51. " <td>3</td>\n",
  52. " </tr>\n",
  53. " </tbody>\n",
  54. "</table>\n",
  55. "</div>"
  56. ],
  57. "text/plain": [
  58. " dna_seq length\n",
  59. "0 ACGTGCA 7\n",
  60. "1 ACC 3"
  61. ]
  62. },
  63. "execution_count": 29,
  64. "metadata": {},
  65. "output_type": "execute_result"
  66. }
  67. ],
  68. "source": [
  69. "df = pd.DataFrame({\"dna_seq\": [\"ACGTGCA\", \"ACC\"],\n",
  70. " \"length\": [7, 3]})\n",
  71. "df"
  72. ]
  73. },
  74. {
  75. "cell_type": "code",
  76. "execution_count": 28,
  77. "metadata": {
  78. "collapsed": false
  79. },
  80. "outputs": [
  81. {
  82. "data": {
  83. "text/html": [
  84. "\n",
  85. " <style type=\"text/css\" >\n",
  86. " \n",
  87. " \n",
  88. " </style>\n",
  89. "\n",
  90. " <table id=\"T_4b732318_54c9_11e6_b822_a45e60bd97fb\" None>\n",
  91. " \n",
  92. "\n",
  93. " <thead>\n",
  94. " \n",
  95. " <tr>\n",
  96. " \n",
  97. " <th class=\"blank\">\n",
  98. " \n",
  99. " <th class=\"col_heading level0 col0\">dna_seq\n",
  100. " \n",
  101. " <th class=\"col_heading level0 col1\">length\n",
  102. " \n",
  103. " </tr>\n",
  104. " \n",
  105. " </thead>\n",
  106. " <tbody>\n",
  107. " \n",
  108. " <tr>\n",
  109. " \n",
  110. " <th id=\"T_4b732318_54c9_11e6_b822_a45e60bd97fb\" class=\"row_heading level1 row0\">\n",
  111. " 0\n",
  112. " \n",
  113. " <td id=\"T_4b732318_54c9_11e6_b822_a45e60bd97fbrow0_col0\" class=\"data row0 col0\">\n",
  114. " <span style=\"color: blue\">A</span><span style=\"color: red\">C</span><span style=\"color: green\">G</span><span style=\"color: yellow\">T</span><span style=\"color: green\">G</span><span style=\"color: red\">C</span><span style=\"color: blue\">A</span>\n",
  115. " \n",
  116. " <td id=\"T_4b732318_54c9_11e6_b822_a45e60bd97fbrow0_col1\" class=\"data row0 col1\">\n",
  117. " 7\n",
  118. " \n",
  119. " </tr>\n",
  120. " \n",
  121. " <tr>\n",
  122. " \n",
  123. " <th id=\"T_4b732318_54c9_11e6_b822_a45e60bd97fb\" class=\"row_heading level1 row1\">\n",
  124. " 1\n",
  125. " \n",
  126. " <td id=\"T_4b732318_54c9_11e6_b822_a45e60bd97fbrow1_col0\" class=\"data row1 col0\">\n",
  127. " <span style=\"color: blue\">A</span><span style=\"color: red\">C</span><span style=\"color: red\">C</span>\n",
  128. " \n",
  129. " <td id=\"T_4b732318_54c9_11e6_b822_a45e60bd97fbrow1_col1\" class=\"data row1 col1\">\n",
  130. " 3\n",
  131. " \n",
  132. " </tr>\n",
  133. " \n",
  134. " </tbody>\n",
  135. " </table>\n",
  136. " "
  137. ],
  138. "text/plain": [
  139. "<pandas.formats.style.Styler at 0x10b31f358>"
  140. ]
  141. },
  142. "execution_count": 28,
  143. "metadata": {},
  144. "output_type": "execute_result"
  145. }
  146. ],
  147. "source": [
  148. "def formatter(v):\n",
  149. " cmap = {\"A\": \"blue\", \"C\": \"red\", \"G\": \"green\", \"T\": \"yellow\"}\n",
  150. " return ''.join(['<span style=\"color: {}\">{}</span>'.format(cmap[s], s)\n",
  151. " for s in v])\n",
  152. " \n",
  153. "\n",
  154. "df.style.format({\"dna_seq\": formatter})"
  155. ]
  156. }
  157. ],
  158. "metadata": {
  159. "kernelspec": {
  160. "display_name": "Python 3",
  161. "language": "python",
  162. "name": "python3"
  163. },
  164. "language_info": {
  165. "codemirror_mode": {
  166. "name": "ipython",
  167. "version": 3
  168. },
  169. "file_extension": ".py",
  170. "mimetype": "text/x-python",
  171. "name": "python",
  172. "nbconvert_exporter": "python",
  173. "pygments_lexer": "ipython3",
  174. "version": "3.5.2"
  175. }
  176. },
  177. "nbformat": 4,
  178. "nbformat_minor": 0
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement