Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "## Jupyter notebook\n",
  8. "\n",
  9. "..."
  10. ]
  11. },
  12. {
  13. "cell_type": "code",
  14. "execution_count": 17,
  15. "metadata": {},
  16. "outputs": [],
  17. "source": [
  18. "from Bio import SeqIO"
  19. ]
  20. },
  21. {
  22. "cell_type": "code",
  23. "execution_count": 18,
  24. "metadata": {},
  25. "outputs": [],
  26. "source": [
  27. "with open(\"test.gb\") as h:\n",
  28. " seq = SeqIO.read(h, format=\"gb\")"
  29. ]
  30. },
  31. {
  32. "cell_type": "code",
  33. "execution_count": 19,
  34. "metadata": {},
  35. "outputs": [
  36. {
  37. "data": {
  38. "text/plain": [
  39. "SeqRecord(seq=Seq('GATC', IUPACAmbiguousDNA()), id='test', name='test', description='', dbxrefs=[])"
  40. ]
  41. },
  42. "execution_count": 19,
  43. "metadata": {},
  44. "output_type": "execute_result"
  45. }
  46. ],
  47. "source": [
  48. "seq"
  49. ]
  50. },
  51. {
  52. "cell_type": "code",
  53. "execution_count": 27,
  54. "metadata": {},
  55. "outputs": [
  56. {
  57. "name": "stdout",
  58. "output_type": "stream",
  59. "text": [
  60. "LOCUS test 4 bp ds-DNA linear UNK 10-JUL-2019\n",
  61. "DEFINITION .\n",
  62. "ACCESSION test\n",
  63. "VERSION test\n",
  64. "KEYWORDS .\n",
  65. "SOURCE \n",
  66. " ORGANISM .\n",
  67. " .\n",
  68. "COMMENT \n",
  69. " \n",
  70. " ApEinfo:methylated:1\n",
  71. "FEATURES Location/Qualifiers\n",
  72. " misc_feature 2..3\n",
  73. " /locus_tag=\"MyFeature\"\n",
  74. " /label=\"MyFeature\"\n",
  75. " /ApEinfo_label=\"MyFeature\"\n",
  76. " /ApEinfo_fwdcolor=\"cyan\"\n",
  77. " /ApEinfo_revcolor=\"green\"\n",
  78. " /ApEinfo_graphicformat=\"arrow_data {{0 1 2 0 0 -1} {} 0}\n",
  79. " width 5 offset 0\"\n",
  80. "ORIGIN\n",
  81. " 1 gatc\n",
  82. "//\n",
  83. "\n"
  84. ]
  85. }
  86. ],
  87. "source": [
  88. "print(seq.format(\"gb\"))"
  89. ]
  90. },
  91. {
  92. "cell_type": "code",
  93. "execution_count": 20,
  94. "metadata": {},
  95. "outputs": [
  96. {
  97. "data": {
  98. "text/plain": [
  99. "Bio.SeqRecord.SeqRecord"
  100. ]
  101. },
  102. "execution_count": 20,
  103. "metadata": {},
  104. "output_type": "execute_result"
  105. }
  106. ],
  107. "source": [
  108. "type(seq)"
  109. ]
  110. },
  111. {
  112. "cell_type": "code",
  113. "execution_count": 21,
  114. "metadata": {},
  115. "outputs": [],
  116. "source": [
  117. "from pydna.seqrecord import SeqRecord"
  118. ]
  119. },
  120. {
  121. "cell_type": "code",
  122. "execution_count": 22,
  123. "metadata": {},
  124. "outputs": [],
  125. "source": [
  126. "seq2 = SeqRecord(str(seq.seq))"
  127. ]
  128. },
  129. {
  130. "cell_type": "code",
  131. "execution_count": 23,
  132. "metadata": {},
  133. "outputs": [],
  134. "source": [
  135. "seq2.__dict__.update(seq.__dict__)"
  136. ]
  137. },
  138. {
  139. "cell_type": "code",
  140. "execution_count": 24,
  141. "metadata": {},
  142. "outputs": [
  143. {
  144. "data": {
  145. "text/plain": [
  146. "pydna.seqrecord.SeqRecord"
  147. ]
  148. },
  149. "execution_count": 24,
  150. "metadata": {},
  151. "output_type": "execute_result"
  152. }
  153. ],
  154. "source": [
  155. "type(seq2)"
  156. ]
  157. },
  158. {
  159. "cell_type": "code",
  160. "execution_count": 25,
  161. "metadata": {},
  162. "outputs": [
  163. {
  164. "data": {
  165. "text/plain": [
  166. "+-----+---------------+-----+-----+-----+-----+--------------+------+\n",
  167. "| Ft# | Label or Note | Dir | Sta | End | Len | type | orf? |\n",
  168. "+-----+---------------+-----+-----+-----+-----+--------------+------+\n",
  169. "| 0 | L:MyFeature | --> | 1 | 3 | 2 | misc_feature | no |\n",
  170. "+-----+---------------+-----+-----+-----+-----+--------------+------+"
  171. ]
  172. },
  173. "execution_count": 25,
  174. "metadata": {},
  175. "output_type": "execute_result"
  176. }
  177. ],
  178. "source": [
  179. "seq2.list_features()"
  180. ]
  181. },
  182. {
  183. "cell_type": "code",
  184. "execution_count": null,
  185. "metadata": {},
  186. "outputs": [],
  187. "source": []
  188. }
  189. ],
  190. "metadata": {
  191. "anaconda-cloud": {},
  192. "kernelspec": {
  193. "display_name": "Python [conda env:bjorn37]",
  194. "language": "python",
  195. "name": "conda-env-bjorn37-py"
  196. },
  197. "language_info": {
  198. "codemirror_mode": {
  199. "name": "ipython",
  200. "version": 3
  201. },
  202. "file_extension": ".py",
  203. "mimetype": "text/x-python",
  204. "name": "python",
  205. "nbconvert_exporter": "python",
  206. "pygments_lexer": "ipython3",
  207. "version": "3.7.3"
  208. }
  209. },
  210. "nbformat": 4,
  211. "nbformat_minor": 2
  212. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement