biotite 0.41.1__cp312-cp312-macosx_10_16_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of biotite might be problematic. Click here for more details.

Files changed (340) hide show
  1. biotite/__init__.py +19 -0
  2. biotite/application/__init__.py +43 -0
  3. biotite/application/application.py +265 -0
  4. biotite/application/autodock/__init__.py +12 -0
  5. biotite/application/autodock/app.py +505 -0
  6. biotite/application/blast/__init__.py +14 -0
  7. biotite/application/blast/alignment.py +83 -0
  8. biotite/application/blast/webapp.py +421 -0
  9. biotite/application/clustalo/__init__.py +12 -0
  10. biotite/application/clustalo/app.py +238 -0
  11. biotite/application/dssp/__init__.py +12 -0
  12. biotite/application/dssp/app.py +152 -0
  13. biotite/application/localapp.py +306 -0
  14. biotite/application/mafft/__init__.py +12 -0
  15. biotite/application/mafft/app.py +122 -0
  16. biotite/application/msaapp.py +374 -0
  17. biotite/application/muscle/__init__.py +13 -0
  18. biotite/application/muscle/app3.py +254 -0
  19. biotite/application/muscle/app5.py +171 -0
  20. biotite/application/sra/__init__.py +18 -0
  21. biotite/application/sra/app.py +456 -0
  22. biotite/application/tantan/__init__.py +12 -0
  23. biotite/application/tantan/app.py +222 -0
  24. biotite/application/util.py +59 -0
  25. biotite/application/viennarna/__init__.py +18 -0
  26. biotite/application/viennarna/rnaalifold.py +304 -0
  27. biotite/application/viennarna/rnafold.py +269 -0
  28. biotite/application/viennarna/rnaplot.py +187 -0
  29. biotite/application/viennarna/util.py +72 -0
  30. biotite/application/webapp.py +77 -0
  31. biotite/copyable.py +71 -0
  32. biotite/database/__init__.py +23 -0
  33. biotite/database/entrez/__init__.py +15 -0
  34. biotite/database/entrez/check.py +61 -0
  35. biotite/database/entrez/dbnames.py +89 -0
  36. biotite/database/entrez/download.py +223 -0
  37. biotite/database/entrez/key.py +44 -0
  38. biotite/database/entrez/query.py +223 -0
  39. biotite/database/error.py +15 -0
  40. biotite/database/pubchem/__init__.py +21 -0
  41. biotite/database/pubchem/download.py +260 -0
  42. biotite/database/pubchem/error.py +20 -0
  43. biotite/database/pubchem/query.py +827 -0
  44. biotite/database/pubchem/throttle.py +99 -0
  45. biotite/database/rcsb/__init__.py +13 -0
  46. biotite/database/rcsb/download.py +167 -0
  47. biotite/database/rcsb/query.py +959 -0
  48. biotite/database/uniprot/__init__.py +13 -0
  49. biotite/database/uniprot/check.py +32 -0
  50. biotite/database/uniprot/download.py +134 -0
  51. biotite/database/uniprot/query.py +209 -0
  52. biotite/file.py +251 -0
  53. biotite/sequence/__init__.py +73 -0
  54. biotite/sequence/align/__init__.py +49 -0
  55. biotite/sequence/align/alignment.py +658 -0
  56. biotite/sequence/align/banded.cpython-312-darwin.so +0 -0
  57. biotite/sequence/align/banded.pyx +652 -0
  58. biotite/sequence/align/buckets.py +69 -0
  59. biotite/sequence/align/cigar.py +434 -0
  60. biotite/sequence/align/kmeralphabet.cpython-312-darwin.so +0 -0
  61. biotite/sequence/align/kmeralphabet.pyx +574 -0
  62. biotite/sequence/align/kmersimilarity.cpython-312-darwin.so +0 -0
  63. biotite/sequence/align/kmersimilarity.pyx +233 -0
  64. biotite/sequence/align/kmertable.cpython-312-darwin.so +0 -0
  65. biotite/sequence/align/kmertable.pyx +3400 -0
  66. biotite/sequence/align/localgapped.cpython-312-darwin.so +0 -0
  67. biotite/sequence/align/localgapped.pyx +892 -0
  68. biotite/sequence/align/localungapped.cpython-312-darwin.so +0 -0
  69. biotite/sequence/align/localungapped.pyx +279 -0
  70. biotite/sequence/align/matrix.py +405 -0
  71. biotite/sequence/align/matrix_data/BLOSUM100.mat +31 -0
  72. biotite/sequence/align/matrix_data/BLOSUM30.mat +31 -0
  73. biotite/sequence/align/matrix_data/BLOSUM35.mat +31 -0
  74. biotite/sequence/align/matrix_data/BLOSUM40.mat +31 -0
  75. biotite/sequence/align/matrix_data/BLOSUM45.mat +31 -0
  76. biotite/sequence/align/matrix_data/BLOSUM50.mat +31 -0
  77. biotite/sequence/align/matrix_data/BLOSUM50_13p.mat +25 -0
  78. biotite/sequence/align/matrix_data/BLOSUM50_14.3.mat +25 -0
  79. biotite/sequence/align/matrix_data/BLOSUM50_5.0.mat +25 -0
  80. biotite/sequence/align/matrix_data/BLOSUM55.mat +31 -0
  81. biotite/sequence/align/matrix_data/BLOSUM60.mat +31 -0
  82. biotite/sequence/align/matrix_data/BLOSUM62.mat +31 -0
  83. biotite/sequence/align/matrix_data/BLOSUM62_13p.mat +25 -0
  84. biotite/sequence/align/matrix_data/BLOSUM62_14.3.mat +25 -0
  85. biotite/sequence/align/matrix_data/BLOSUM62_5.0.mat +25 -0
  86. biotite/sequence/align/matrix_data/BLOSUM65.mat +31 -0
  87. biotite/sequence/align/matrix_data/BLOSUM70.mat +31 -0
  88. biotite/sequence/align/matrix_data/BLOSUM75.mat +31 -0
  89. biotite/sequence/align/matrix_data/BLOSUM80.mat +31 -0
  90. biotite/sequence/align/matrix_data/BLOSUM85.mat +31 -0
  91. biotite/sequence/align/matrix_data/BLOSUM90.mat +31 -0
  92. biotite/sequence/align/matrix_data/BLOSUMN.mat +31 -0
  93. biotite/sequence/align/matrix_data/CorBLOSUM49_5.0.mat +25 -0
  94. biotite/sequence/align/matrix_data/CorBLOSUM57_13p.mat +25 -0
  95. biotite/sequence/align/matrix_data/CorBLOSUM57_14.3.mat +25 -0
  96. biotite/sequence/align/matrix_data/CorBLOSUM61_5.0.mat +25 -0
  97. biotite/sequence/align/matrix_data/CorBLOSUM66_13p.mat +25 -0
  98. biotite/sequence/align/matrix_data/CorBLOSUM67_14.3.mat +25 -0
  99. biotite/sequence/align/matrix_data/DAYHOFF.mat +32 -0
  100. biotite/sequence/align/matrix_data/GONNET.mat +26 -0
  101. biotite/sequence/align/matrix_data/IDENTITY.mat +25 -0
  102. biotite/sequence/align/matrix_data/MATCH.mat +25 -0
  103. biotite/sequence/align/matrix_data/NUC.mat +25 -0
  104. biotite/sequence/align/matrix_data/PAM10.mat +34 -0
  105. biotite/sequence/align/matrix_data/PAM100.mat +34 -0
  106. biotite/sequence/align/matrix_data/PAM110.mat +34 -0
  107. biotite/sequence/align/matrix_data/PAM120.mat +34 -0
  108. biotite/sequence/align/matrix_data/PAM130.mat +34 -0
  109. biotite/sequence/align/matrix_data/PAM140.mat +34 -0
  110. biotite/sequence/align/matrix_data/PAM150.mat +34 -0
  111. biotite/sequence/align/matrix_data/PAM160.mat +34 -0
  112. biotite/sequence/align/matrix_data/PAM170.mat +34 -0
  113. biotite/sequence/align/matrix_data/PAM180.mat +34 -0
  114. biotite/sequence/align/matrix_data/PAM190.mat +34 -0
  115. biotite/sequence/align/matrix_data/PAM20.mat +34 -0
  116. biotite/sequence/align/matrix_data/PAM200.mat +34 -0
  117. biotite/sequence/align/matrix_data/PAM210.mat +34 -0
  118. biotite/sequence/align/matrix_data/PAM220.mat +34 -0
  119. biotite/sequence/align/matrix_data/PAM230.mat +34 -0
  120. biotite/sequence/align/matrix_data/PAM240.mat +34 -0
  121. biotite/sequence/align/matrix_data/PAM250.mat +34 -0
  122. biotite/sequence/align/matrix_data/PAM260.mat +34 -0
  123. biotite/sequence/align/matrix_data/PAM270.mat +34 -0
  124. biotite/sequence/align/matrix_data/PAM280.mat +34 -0
  125. biotite/sequence/align/matrix_data/PAM290.mat +34 -0
  126. biotite/sequence/align/matrix_data/PAM30.mat +34 -0
  127. biotite/sequence/align/matrix_data/PAM300.mat +34 -0
  128. biotite/sequence/align/matrix_data/PAM310.mat +34 -0
  129. biotite/sequence/align/matrix_data/PAM320.mat +34 -0
  130. biotite/sequence/align/matrix_data/PAM330.mat +34 -0
  131. biotite/sequence/align/matrix_data/PAM340.mat +34 -0
  132. biotite/sequence/align/matrix_data/PAM350.mat +34 -0
  133. biotite/sequence/align/matrix_data/PAM360.mat +34 -0
  134. biotite/sequence/align/matrix_data/PAM370.mat +34 -0
  135. biotite/sequence/align/matrix_data/PAM380.mat +34 -0
  136. biotite/sequence/align/matrix_data/PAM390.mat +34 -0
  137. biotite/sequence/align/matrix_data/PAM40.mat +34 -0
  138. biotite/sequence/align/matrix_data/PAM400.mat +34 -0
  139. biotite/sequence/align/matrix_data/PAM410.mat +34 -0
  140. biotite/sequence/align/matrix_data/PAM420.mat +34 -0
  141. biotite/sequence/align/matrix_data/PAM430.mat +34 -0
  142. biotite/sequence/align/matrix_data/PAM440.mat +34 -0
  143. biotite/sequence/align/matrix_data/PAM450.mat +34 -0
  144. biotite/sequence/align/matrix_data/PAM460.mat +34 -0
  145. biotite/sequence/align/matrix_data/PAM470.mat +34 -0
  146. biotite/sequence/align/matrix_data/PAM480.mat +34 -0
  147. biotite/sequence/align/matrix_data/PAM490.mat +34 -0
  148. biotite/sequence/align/matrix_data/PAM50.mat +34 -0
  149. biotite/sequence/align/matrix_data/PAM500.mat +34 -0
  150. biotite/sequence/align/matrix_data/PAM60.mat +34 -0
  151. biotite/sequence/align/matrix_data/PAM70.mat +34 -0
  152. biotite/sequence/align/matrix_data/PAM80.mat +34 -0
  153. biotite/sequence/align/matrix_data/PAM90.mat +34 -0
  154. biotite/sequence/align/matrix_data/RBLOSUM52_5.0.mat +25 -0
  155. biotite/sequence/align/matrix_data/RBLOSUM59_13p.mat +25 -0
  156. biotite/sequence/align/matrix_data/RBLOSUM59_14.3.mat +25 -0
  157. biotite/sequence/align/matrix_data/RBLOSUM64_5.0.mat +25 -0
  158. biotite/sequence/align/matrix_data/RBLOSUM69_13p.mat +25 -0
  159. biotite/sequence/align/matrix_data/RBLOSUM69_14.3.mat +25 -0
  160. biotite/sequence/align/multiple.cpython-312-darwin.so +0 -0
  161. biotite/sequence/align/multiple.pyx +620 -0
  162. biotite/sequence/align/pairwise.cpython-312-darwin.so +0 -0
  163. biotite/sequence/align/pairwise.pyx +587 -0
  164. biotite/sequence/align/permutation.cpython-312-darwin.so +0 -0
  165. biotite/sequence/align/permutation.pyx +305 -0
  166. biotite/sequence/align/primes.txt +821 -0
  167. biotite/sequence/align/selector.cpython-312-darwin.so +0 -0
  168. biotite/sequence/align/selector.pyx +956 -0
  169. biotite/sequence/align/statistics.py +265 -0
  170. biotite/sequence/align/tracetable.cpython-312-darwin.so +0 -0
  171. biotite/sequence/align/tracetable.pxd +64 -0
  172. biotite/sequence/align/tracetable.pyx +370 -0
  173. biotite/sequence/alphabet.py +566 -0
  174. biotite/sequence/annotation.py +829 -0
  175. biotite/sequence/codec.cpython-312-darwin.so +0 -0
  176. biotite/sequence/codec.pyx +155 -0
  177. biotite/sequence/codon.py +466 -0
  178. biotite/sequence/codon_tables.txt +202 -0
  179. biotite/sequence/graphics/__init__.py +33 -0
  180. biotite/sequence/graphics/alignment.py +1034 -0
  181. biotite/sequence/graphics/color_schemes/autumn.json +51 -0
  182. biotite/sequence/graphics/color_schemes/blossom.json +51 -0
  183. biotite/sequence/graphics/color_schemes/clustalx_dna.json +11 -0
  184. biotite/sequence/graphics/color_schemes/clustalx_protein.json +28 -0
  185. biotite/sequence/graphics/color_schemes/flower.json +51 -0
  186. biotite/sequence/graphics/color_schemes/jalview_buried.json +31 -0
  187. biotite/sequence/graphics/color_schemes/jalview_hydrophobicity.json +31 -0
  188. biotite/sequence/graphics/color_schemes/jalview_prop_helix.json +31 -0
  189. biotite/sequence/graphics/color_schemes/jalview_prop_strand.json +31 -0
  190. biotite/sequence/graphics/color_schemes/jalview_prop_turn.json +31 -0
  191. biotite/sequence/graphics/color_schemes/jalview_taylor.json +28 -0
  192. biotite/sequence/graphics/color_schemes/jalview_zappo.json +28 -0
  193. biotite/sequence/graphics/color_schemes/ocean.json +51 -0
  194. biotite/sequence/graphics/color_schemes/pb_flower.json +39 -0
  195. biotite/sequence/graphics/color_schemes/rainbow_dna.json +11 -0
  196. biotite/sequence/graphics/color_schemes/rainbow_protein.json +30 -0
  197. biotite/sequence/graphics/color_schemes/spring.json +51 -0
  198. biotite/sequence/graphics/color_schemes/sunset.json +51 -0
  199. biotite/sequence/graphics/color_schemes/wither.json +51 -0
  200. biotite/sequence/graphics/colorschemes.py +139 -0
  201. biotite/sequence/graphics/dendrogram.py +184 -0
  202. biotite/sequence/graphics/features.py +510 -0
  203. biotite/sequence/graphics/logo.py +110 -0
  204. biotite/sequence/graphics/plasmid.py +661 -0
  205. biotite/sequence/io/__init__.py +12 -0
  206. biotite/sequence/io/fasta/__init__.py +22 -0
  207. biotite/sequence/io/fasta/convert.py +273 -0
  208. biotite/sequence/io/fasta/file.py +278 -0
  209. biotite/sequence/io/fastq/__init__.py +19 -0
  210. biotite/sequence/io/fastq/convert.py +120 -0
  211. biotite/sequence/io/fastq/file.py +551 -0
  212. biotite/sequence/io/genbank/__init__.py +17 -0
  213. biotite/sequence/io/genbank/annotation.py +277 -0
  214. biotite/sequence/io/genbank/file.py +575 -0
  215. biotite/sequence/io/genbank/metadata.py +324 -0
  216. biotite/sequence/io/genbank/sequence.py +172 -0
  217. biotite/sequence/io/general.py +192 -0
  218. biotite/sequence/io/gff/__init__.py +26 -0
  219. biotite/sequence/io/gff/convert.py +133 -0
  220. biotite/sequence/io/gff/file.py +434 -0
  221. biotite/sequence/phylo/__init__.py +36 -0
  222. biotite/sequence/phylo/nj.cpython-312-darwin.so +0 -0
  223. biotite/sequence/phylo/nj.pyx +221 -0
  224. biotite/sequence/phylo/tree.cpython-312-darwin.so +0 -0
  225. biotite/sequence/phylo/tree.pyx +1169 -0
  226. biotite/sequence/phylo/upgma.cpython-312-darwin.so +0 -0
  227. biotite/sequence/phylo/upgma.pyx +164 -0
  228. biotite/sequence/profile.py +456 -0
  229. biotite/sequence/search.py +116 -0
  230. biotite/sequence/seqtypes.py +556 -0
  231. biotite/sequence/sequence.py +374 -0
  232. biotite/structure/__init__.py +132 -0
  233. biotite/structure/atoms.py +1455 -0
  234. biotite/structure/basepairs.py +1415 -0
  235. biotite/structure/bonds.cpython-312-darwin.so +0 -0
  236. biotite/structure/bonds.pyx +1933 -0
  237. biotite/structure/box.py +592 -0
  238. biotite/structure/celllist.cpython-312-darwin.so +0 -0
  239. biotite/structure/celllist.pyx +849 -0
  240. biotite/structure/chains.py +298 -0
  241. biotite/structure/charges.cpython-312-darwin.so +0 -0
  242. biotite/structure/charges.pyx +520 -0
  243. biotite/structure/compare.py +274 -0
  244. biotite/structure/density.py +114 -0
  245. biotite/structure/dotbracket.py +216 -0
  246. biotite/structure/error.py +31 -0
  247. biotite/structure/filter.py +585 -0
  248. biotite/structure/geometry.py +697 -0
  249. biotite/structure/graphics/__init__.py +13 -0
  250. biotite/structure/graphics/atoms.py +226 -0
  251. biotite/structure/graphics/rna.py +282 -0
  252. biotite/structure/hbond.py +409 -0
  253. biotite/structure/info/__init__.py +25 -0
  254. biotite/structure/info/atom_masses.json +121 -0
  255. biotite/structure/info/atoms.py +82 -0
  256. biotite/structure/info/bonds.py +145 -0
  257. biotite/structure/info/ccd/README.rst +8 -0
  258. biotite/structure/info/ccd/amino_acids.txt +1663 -0
  259. biotite/structure/info/ccd/carbohydrates.txt +1135 -0
  260. biotite/structure/info/ccd/components.bcif +0 -0
  261. biotite/structure/info/ccd/nucleotides.txt +798 -0
  262. biotite/structure/info/ccd.py +95 -0
  263. biotite/structure/info/groups.py +90 -0
  264. biotite/structure/info/masses.py +123 -0
  265. biotite/structure/info/misc.py +144 -0
  266. biotite/structure/info/radii.py +197 -0
  267. biotite/structure/info/standardize.py +196 -0
  268. biotite/structure/integrity.py +268 -0
  269. biotite/structure/io/__init__.py +30 -0
  270. biotite/structure/io/ctab.py +72 -0
  271. biotite/structure/io/dcd/__init__.py +13 -0
  272. biotite/structure/io/dcd/file.py +65 -0
  273. biotite/structure/io/general.py +257 -0
  274. biotite/structure/io/gro/__init__.py +14 -0
  275. biotite/structure/io/gro/file.py +343 -0
  276. biotite/structure/io/mmtf/__init__.py +21 -0
  277. biotite/structure/io/mmtf/assembly.py +214 -0
  278. biotite/structure/io/mmtf/convertarray.cpython-312-darwin.so +0 -0
  279. biotite/structure/io/mmtf/convertarray.pyx +341 -0
  280. biotite/structure/io/mmtf/convertfile.cpython-312-darwin.so +0 -0
  281. biotite/structure/io/mmtf/convertfile.pyx +501 -0
  282. biotite/structure/io/mmtf/decode.cpython-312-darwin.so +0 -0
  283. biotite/structure/io/mmtf/decode.pyx +152 -0
  284. biotite/structure/io/mmtf/encode.cpython-312-darwin.so +0 -0
  285. biotite/structure/io/mmtf/encode.pyx +183 -0
  286. biotite/structure/io/mmtf/file.py +233 -0
  287. biotite/structure/io/mol/__init__.py +20 -0
  288. biotite/structure/io/mol/convert.py +115 -0
  289. biotite/structure/io/mol/ctab.py +414 -0
  290. biotite/structure/io/mol/header.py +116 -0
  291. biotite/structure/io/mol/mol.py +193 -0
  292. biotite/structure/io/mol/sdf.py +916 -0
  293. biotite/structure/io/netcdf/__init__.py +13 -0
  294. biotite/structure/io/netcdf/file.py +63 -0
  295. biotite/structure/io/npz/__init__.py +20 -0
  296. biotite/structure/io/npz/file.py +152 -0
  297. biotite/structure/io/pdb/__init__.py +20 -0
  298. biotite/structure/io/pdb/convert.py +293 -0
  299. biotite/structure/io/pdb/file.py +1240 -0
  300. biotite/structure/io/pdb/hybrid36.cpython-312-darwin.so +0 -0
  301. biotite/structure/io/pdb/hybrid36.pyx +242 -0
  302. biotite/structure/io/pdbqt/__init__.py +15 -0
  303. biotite/structure/io/pdbqt/convert.py +107 -0
  304. biotite/structure/io/pdbqt/file.py +640 -0
  305. biotite/structure/io/pdbx/__init__.py +23 -0
  306. biotite/structure/io/pdbx/bcif.py +648 -0
  307. biotite/structure/io/pdbx/cif.py +1032 -0
  308. biotite/structure/io/pdbx/component.py +246 -0
  309. biotite/structure/io/pdbx/convert.py +1597 -0
  310. biotite/structure/io/pdbx/encoding.cpython-312-darwin.so +0 -0
  311. biotite/structure/io/pdbx/encoding.pyx +950 -0
  312. biotite/structure/io/pdbx/legacy.py +267 -0
  313. biotite/structure/io/tng/__init__.py +13 -0
  314. biotite/structure/io/tng/file.py +46 -0
  315. biotite/structure/io/trajfile.py +710 -0
  316. biotite/structure/io/trr/__init__.py +13 -0
  317. biotite/structure/io/trr/file.py +46 -0
  318. biotite/structure/io/xtc/__init__.py +13 -0
  319. biotite/structure/io/xtc/file.py +46 -0
  320. biotite/structure/mechanics.py +75 -0
  321. biotite/structure/molecules.py +353 -0
  322. biotite/structure/pseudoknots.py +642 -0
  323. biotite/structure/rdf.py +243 -0
  324. biotite/structure/repair.py +253 -0
  325. biotite/structure/residues.py +562 -0
  326. biotite/structure/resutil.py +178 -0
  327. biotite/structure/sasa.cpython-312-darwin.so +0 -0
  328. biotite/structure/sasa.pyx +322 -0
  329. biotite/structure/sequence.py +112 -0
  330. biotite/structure/sse.py +327 -0
  331. biotite/structure/superimpose.py +727 -0
  332. biotite/structure/transform.py +504 -0
  333. biotite/structure/util.py +98 -0
  334. biotite/temp.py +86 -0
  335. biotite/version.py +16 -0
  336. biotite/visualize.py +251 -0
  337. biotite-0.41.1.dist-info/METADATA +187 -0
  338. biotite-0.41.1.dist-info/RECORD +340 -0
  339. biotite-0.41.1.dist-info/WHEEL +4 -0
  340. biotite-0.41.1.dist-info/licenses/LICENSE.rst +30 -0
@@ -0,0 +1,510 @@
1
+ # This source code is part of the Biotite package and is distributed
2
+ # under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
3
+ # information.
4
+
5
+ __name__ = "biotite.sequence.graphics"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["plot_feature_map", "FeaturePlotter", "MiscFeaturePlotter",
8
+ "CodingPlotter", "PromoterPlotter", "TerminatorPlotter",
9
+ "RBSPlotter"]
10
+
11
+ import copy
12
+ import abc
13
+ import numpy as np
14
+ from ...visualize import colors, AdaptiveFancyArrow
15
+ from ..annotation import Annotation, Feature, Location
16
+
17
+
18
+ def plot_feature_map(axes, annotation, loc_range=None,
19
+ multi_line=True, symbols_per_line=1000,
20
+ show_numbers=False, number_size=None, line_width=0.05,
21
+ show_line_position=False, spacing=0.25,
22
+ feature_plotters=None, style_param=None):
23
+ """
24
+ Plot a sequence annotation, by showing the range of each feature
25
+ on one or multiple position depicting line(s).
26
+
27
+ This function uses :class:`FeaturePlotter` objects to draw the
28
+ features.
29
+ This function internally uses a list of plotters, where the
30
+ first plotter in the list, that supports a feature, is used to draw
31
+ that feature.
32
+ The amount of features that can be visualized by default is limited.
33
+ Features, that are not supported otherwise, are visualized as simple
34
+ rectangles.
35
+ Additional :class:`FeaturePlotter` objects, that are supplied in the
36
+ `feature_plotters` parameters, can be used to add support for
37
+ further features or to customize the appearance of certain features.
38
+
39
+ Parameters
40
+ ----------
41
+ axes : Axes
42
+ A *Matplotlib* axes, that is used as plotting area.
43
+ annotation : Annotation
44
+ The annotation to be visualized.
45
+ loc_range : tuple (int, int), optional
46
+ The start and exclusive stop location that is visualized.
47
+ By default, the location range starts from the first
48
+ base/residue and ends at the last base/residue of all features,
49
+ ensuring that the entire annotation is drawn.
50
+ multi_line : bool, optional
51
+ If true, the annotation is segmented into multiple lines with a
52
+ line break all `symbols_per_line` lines.
53
+ Otherwise, the entire location range is put into a single line.
54
+ symbols_per_line : int, optional
55
+ The amount of
56
+ Does not have an effect, if `multi_line` is false.
57
+ show_numbers : bool, optional
58
+ If true, the sequence position the base/residue of a line is
59
+ shown on the right side of the plot.
60
+ number_size : float, optional
61
+ The font size of the position numbers
62
+ line_width : float, optional
63
+ The size of the continuous line as fraction of the height of
64
+ the drawn features.
65
+ show_line_position : bool, optional
66
+ If true the position within a line is plotted.
67
+ spacing : float, optional
68
+ The size of the spacing between the lines as fraction of the
69
+ height of the drawn features.
70
+ feature_plotters : list of FeaturePlotter, optional
71
+ Custom plotters for features.
72
+ The list is iterated from the beginning until a
73
+ :class:`FeaturePlotter` matches the respective feature
74
+ (`FeaturePlotter.matches()` returns `True`).
75
+ This :class:`FeaturePlotter` is then used to draw the feature.
76
+ Therefore, the :class:`FeaturePlotter` instances in the list
77
+ have descending priority.
78
+ The default plotters are appended after this supplied list,
79
+ i.e. the default plotters have a lower priority.
80
+ style_param : dict
81
+ Additional style parameters that are given to the
82
+ :class:`FeaturePlotter` objects.
83
+
84
+ Notes
85
+ -----
86
+ Good visulation results are obtained only for non-overlapping
87
+ features.
88
+ When two features overlap, their drawing area does also overlap.
89
+ """
90
+ from matplotlib.transforms import Bbox
91
+ from matplotlib.patches import Rectangle
92
+
93
+ if loc_range is None:
94
+ loc_range = annotation.get_location_range()
95
+ loc_range_length = loc_range[1] - loc_range[0]
96
+ if multi_line:
97
+ symbols_per_line = symbols_per_line
98
+ else:
99
+ # Line length covers the entire location range
100
+ symbols_per_line = loc_range_length
101
+
102
+ plotters = [
103
+ PromoterPlotter(),
104
+ TerminatorPlotter(),
105
+ RBSPlotter(),
106
+ CodingPlotter(),
107
+ MiscFeaturePlotter()
108
+ ]
109
+ if feature_plotters is not None:
110
+ plotters = list(feature_plotters) + plotters
111
+
112
+ style_param = {} if style_param is None else style_param
113
+
114
+ line_count = loc_range_length // symbols_per_line
115
+ # Only extend line count by 1 if there is a remainder
116
+ if loc_range_length % symbols_per_line != 0:
117
+ line_count += 1
118
+
119
+
120
+ ### Draw lines ###
121
+ remaining_symbols = loc_range_length
122
+ y = 0.5
123
+ while remaining_symbols > 0:
124
+ if remaining_symbols > symbols_per_line:
125
+ # Line spans the entire plot (horizontally)
126
+ line_length = symbols_per_line
127
+ else:
128
+ # Last line -> Line spans to end of annotation
129
+ line_length = remaining_symbols
130
+ axes.add_patch(Rectangle(
131
+ (0, y-line_width/2), line_length, line_width,
132
+ color="gray", linewidth=0
133
+ ))
134
+ # Increment by spacing and width (=1) of feature
135
+ y += spacing + 1
136
+ remaining_symbols -= symbols_per_line
137
+
138
+ ### Draw features ###
139
+ line_start_loc = loc_range[0]
140
+ y = 0
141
+ while line_start_loc < loc_range[1]:
142
+ annotation_for_line = annotation[
143
+ line_start_loc : line_start_loc + symbols_per_line
144
+ ]
145
+ for feature in annotation_for_line:
146
+ plotter = None
147
+ # Identify fitting plotter
148
+ for potentail_plotter in plotters:
149
+ if potentail_plotter.matches(feature):
150
+ # Take first fitting plotter in list
151
+ plotter = potentail_plotter
152
+ break
153
+ if plotter is not None:
154
+ for loc in feature.locs:
155
+ loc_len = loc.last - loc.first + 1
156
+ # Get start location realtive to start if line
157
+ loc_in_line = loc.first - line_start_loc
158
+ x = loc_in_line
159
+ # Line width multiplied by percentage of line
160
+ width = loc_len
161
+ height = 1
162
+ bbox = Bbox.from_bounds(x, y, width, height)
163
+ plotter.draw(
164
+ axes, feature, bbox, loc,
165
+ style_param=style_param
166
+ )
167
+ # Increment by spacing and width (=1) of feature
168
+ y += spacing + 1
169
+ remaining_symbols += symbols_per_line
170
+ line_start_loc += symbols_per_line
171
+
172
+ ### Draw position numbers ###
173
+ ticks = []
174
+ tick_labels = []
175
+ if show_numbers:
176
+ # Numbers at center height of each feature line -> 0.5
177
+ y = 0.5
178
+ for i in range(line_count):
179
+ if i == line_count-1:
180
+ # Last line -> get number of last column in trace
181
+ loc = loc_range[1] -1
182
+ else:
183
+ loc = loc_range[0] + ((i+1) * symbols_per_line) -1
184
+ ticks.append(y)
185
+ tick_labels.append(str(loc))
186
+ # Increment by spacing and width of feature (1)
187
+ y += spacing + 1
188
+ axes.set_yticks(ticks)
189
+ axes.set_yticklabels(tick_labels)
190
+
191
+
192
+ axes.set_xlim(0, symbols_per_line)
193
+ # Y-axis starts from top
194
+ axes.set_ylim(1*line_count + spacing*(line_count-1), 0)
195
+ axes.set_frame_on(False)
196
+ # Draw location numbers on right side
197
+ axes.get_yaxis().set_tick_params(
198
+ left=False, right=False, labelleft=False, labelright=True
199
+ )
200
+ # Remove ticks and set number font size
201
+ axes.yaxis.set_tick_params(
202
+ left=False, right=False, labelsize=number_size
203
+ )
204
+
205
+ if show_line_position:
206
+ axes.xaxis.set_tick_params(
207
+ top=False, bottom=True, labeltop=False, labelbottom=True
208
+ )
209
+ else:
210
+ axes.xaxis.set_tick_params(
211
+ top=False, bottom=False, labeltop=False, labelbottom=False
212
+ )
213
+
214
+
215
+ class FeaturePlotter(metaclass=abc.ABCMeta):
216
+ """
217
+ A :class:`FeaturePlotter` is an object, that 'knows' how to draw a
218
+ certain type of sequence feature onto a :class:`matplotlib.Axes`.
219
+
220
+ Whether the :class:`FeaturePlotter` is able to draw a feature, is
221
+ checked via the :func:`matches()` method.
222
+ The visualization of a compatible feature is conducted in the
223
+ :func:`draw()` method.
224
+ """
225
+
226
+ def __init__(self):
227
+ pass
228
+
229
+ @abc.abstractmethod
230
+ def matches(self, feature):
231
+ """
232
+ Check, whether this object is able to draw a given sequence
233
+ feature.
234
+
235
+ Parameters
236
+ ----------
237
+ feature : Feature
238
+ The sequence feature to be checked.
239
+
240
+ Returns
241
+ -------
242
+ compatibility : bool
243
+ True, if this object is able to draw the given `feature`,
244
+ false otherwise.
245
+ """
246
+ pass
247
+
248
+ @abc.abstractmethod
249
+ def draw(self, axes, feature, bbox, location, style_param):
250
+ """
251
+ Draw a feature onto an axes.
252
+
253
+ Parameters
254
+ ----------
255
+ axes : Axes
256
+ A *Matplotlib* axes, that is used as plotting area.
257
+ feature : Feature
258
+ The feature to be drawn.
259
+ bbox : Bbox
260
+ The bounding box, that describes the area on the `axes`,
261
+ where the feature should be drawn.
262
+ location : int
263
+ The location of the feature, that should be drawn.
264
+ Might be useful, when the visualization is dependent
265
+ on e.g. location defects.
266
+ style_param : dict
267
+ Additional style parameters.
268
+ """
269
+ pass
270
+
271
+
272
+ class CodingPlotter(FeaturePlotter):
273
+ """
274
+ A plotter for the *CDS* and *gene* features.
275
+
276
+ Draws an arrow with a 90 degrees tip.
277
+
278
+ Parameters
279
+ ----------
280
+ tail_width : float, optional
281
+ The width of the arrow tail
282
+ as fraction of the feature drawing area height.
283
+ head_width : float, optional
284
+ The width of the arrow head
285
+ as fraction of the feature drawing area height.
286
+ """
287
+
288
+ def __init__(self, tail_width=0.5, head_width=0.8):
289
+ self._tail_width = tail_width
290
+ self._head_width = head_width
291
+
292
+ def matches(self, feature):
293
+ if feature.key in ["CDS", "gene"]:
294
+ return True
295
+ else:
296
+ return False
297
+
298
+ def draw(self, axes, feature, bbox, loc, style_param):
299
+ y = bbox.y0 + bbox.height/2
300
+ dy = 0
301
+ if loc.strand == Location.Strand.FORWARD:
302
+ x = bbox.x0
303
+ dx = bbox.width
304
+ else:
305
+ x = bbox.x1
306
+ dx = -bbox.width
307
+
308
+ if (
309
+ loc.strand == Location.Strand.FORWARD
310
+ and loc.defect & Location.Defect.MISS_RIGHT
311
+ ) or (
312
+ loc.strand == Location.Strand.REVERSE
313
+ and loc.defect & Location.Defect.MISS_LEFT
314
+ ):
315
+ # If the feature extends into the prevoius or next line
316
+ # do not draw an arrow head
317
+ draw_head = False
318
+ else:
319
+ draw_head = True
320
+
321
+ # Create head with 90 degrees tip -> head width/length ratio = 1/2
322
+ axes.add_patch(AdaptiveFancyArrow(
323
+ x, y, dx, dy, self._tail_width, self._head_width, head_ratio=0.5,
324
+ draw_head=draw_head, color=colors["dimgreen"], linewidth=0
325
+ ))
326
+
327
+ if feature.key == "CDS":
328
+ if "product" not in feature.qual:
329
+ label = None
330
+ elif feature.qual["product"] == "hypothetical protein":
331
+ label = None
332
+ else:
333
+ label = feature.qual["product"]
334
+ elif feature.key == "gene":
335
+ if "gene" not in feature.qual:
336
+ label = None
337
+ else:
338
+ label = feature.qual["gene"]
339
+
340
+ if label is not None:
341
+ center_x = bbox.x0 + bbox.width/2
342
+ center_y = bbox.y0 + bbox.height/2
343
+ axes.text(
344
+ center_x, center_y, label, color="black",
345
+ ha="center", va="center", size=11)
346
+
347
+
348
+ class MiscFeaturePlotter(FeaturePlotter):
349
+ """
350
+ A plotter that matches any feature.
351
+
352
+ Draws a simple Rectangle.
353
+
354
+ Parameters
355
+ ----------
356
+ height : float, optional
357
+ The width of the rectangle
358
+ as fraction of the feature drawing area height.
359
+ """
360
+
361
+ def __init__(self, height=0.4):
362
+ self._height = height
363
+
364
+ def matches(self, feature):
365
+ return True
366
+
367
+ def draw(self, axes, feature, bbox, loc, style_param):
368
+ from matplotlib.patches import Rectangle
369
+
370
+ rect = Rectangle(
371
+ (bbox.x0, bbox.y0 + bbox.height/2 * (1-self._height)),
372
+ bbox.width, bbox.height*self._height,
373
+ color=colors["dimorange"], linewidth=0
374
+ )
375
+ axes.add_patch(rect)
376
+
377
+ class PromoterPlotter(FeaturePlotter):
378
+ """
379
+ A plotter for *regulatory* features with the *promoter* or
380
+ *TATA_box* class.
381
+
382
+ Draws a simple curved thin black arrow.
383
+
384
+ Parameters
385
+ ----------
386
+ line_width : float, optional
387
+ The width of the curved arrow tail.
388
+ head_width : float, optional
389
+ The width of the arrow head
390
+ head_length : float, optional
391
+ The length of the arrow.
392
+ head_height : float, optional
393
+ The Y-position of the arrow head
394
+ as fraction of the halffeature drawing area height.
395
+ """
396
+
397
+ def __init__(self, line_width=2, head_width=2,
398
+ head_length=6, head_height=0.8):
399
+ self._line_width = line_width
400
+ self._head_width = head_width
401
+ self._head_length = head_length
402
+ self._head_height = head_height
403
+
404
+ def matches(self, feature):
405
+ if feature.key == "regulatory":
406
+ if "regulatory_class" in feature.qual:
407
+ if feature.qual["regulatory_class"] in ["promoter","TATA_box"]:
408
+ return True
409
+ return False
410
+
411
+ def draw(self, axes, feature, bbox, loc, style_param):
412
+ from matplotlib.patches import FancyArrowPatch, ArrowStyle
413
+ from matplotlib.path import Path
414
+
415
+ x_center = bbox.x0 + bbox.width/2
416
+ y_center = bbox.y0 + bbox.height/2
417
+
418
+ path = Path(
419
+ vertices=[
420
+ (bbox.x0, y_center),
421
+ (bbox.x0, y_center - bbox.height/2 * self._head_height),
422
+ (bbox.x1, y_center - bbox.height/2 * self._head_height),
423
+ ],
424
+ codes=[
425
+ Path.MOVETO,
426
+ Path.CURVE3,
427
+ Path.CURVE3
428
+ ]
429
+ )
430
+ style = ArrowStyle.CurveFilledB(
431
+ head_width=self._head_width, head_length=self._head_length
432
+ )
433
+ arrow = FancyArrowPatch(
434
+ path=path, arrowstyle=style, linewidth=self._line_width,
435
+ color="black"
436
+ )
437
+ axes.add_patch(arrow)
438
+
439
+ if "note" in feature.qual:
440
+ axes.text(
441
+ x_center, y_center + bbox.height/4, feature.qual["note"],
442
+ color="black", ha="center", va="center",
443
+ size=9
444
+ )
445
+
446
+
447
+ class TerminatorPlotter(FeaturePlotter):
448
+ """
449
+ A plotter for *regulatory* features with the *terminator* class.
450
+
451
+ Draws a vertical bar.
452
+
453
+ Parameters
454
+ ----------
455
+ bar_width : float, optional
456
+ The width of the line representing the bar.
457
+ """
458
+
459
+ def __init__(self, bar_width=5):
460
+ self._bar_width = bar_width
461
+
462
+ def matches(self, feature):
463
+ if feature.key == "regulatory":
464
+ if "regulatory_class" in feature.qual:
465
+ if feature.qual["regulatory_class"] == "terminator":
466
+ return True
467
+ return False
468
+
469
+ def draw(self, axes, feature, bbox, loc, style_param):
470
+
471
+ x = bbox.x0 + bbox.width/2
472
+
473
+ axes.plot(
474
+ (x, x), (bbox.y0, bbox.y1), color="black",
475
+ linestyle="-", linewidth=self._bar_width, marker="None"
476
+ )
477
+
478
+
479
+ class RBSPlotter(FeaturePlotter):
480
+ """
481
+ A plotter for *regulatory* features with the
482
+ *ribosome_binding_site* class.
483
+
484
+ Draws an ellipse.
485
+
486
+ Parameters
487
+ ----------
488
+ height : float, optional
489
+ The width of the ellipse
490
+ as fraction of the feature drawing area height.
491
+ """
492
+
493
+ def __init__(self, height=0.4):
494
+ self._height = height
495
+
496
+ def matches(self, feature):
497
+ if feature.key == "regulatory":
498
+ if "regulatory_class" in feature.qual:
499
+ if feature.qual["regulatory_class"] == "ribosome_binding_site":
500
+ return True
501
+ return False
502
+
503
+ def draw(self, axes, feature, bbox, loc, style_param):
504
+ from matplotlib.patches import Ellipse
505
+
506
+ ellipse = Ellipse(
507
+ (bbox.x0 + bbox.width/2, bbox.y0 + bbox.height/2),
508
+ bbox.width, self._height*bbox.height,
509
+ color=colors["dimorange"], linewidth=0)
510
+ axes.add_patch(ellipse)
@@ -0,0 +1,110 @@
1
+ # This source code is part of the Biotite package and is distributed
2
+ # under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
3
+ # information.
4
+
5
+ __name__ = "biotite.sequence.graphics"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["plot_sequence_logo"]
8
+
9
+ import numpy as np
10
+ from ...visualize import set_font_size_in_coord
11
+ from ..alphabet import LetterAlphabet
12
+ from .colorschemes import get_color_scheme
13
+ import warnings
14
+ from ..align import Alignment
15
+ from .. import SequenceProfile
16
+
17
+
18
+ def plot_sequence_logo(axes, profile, scheme=None, **kwargs):
19
+ """
20
+ Create a sequence logo. :footcite:`Schneider1990`
21
+
22
+ A sequence logo is visualizes the positional composition and
23
+ conservation of a profile encoded in the size of the letters.
24
+ Each position displays all symbols that are occurring at this
25
+ position stacked on each other, with their relative heights depicting
26
+ their relative frequency.
27
+ The height of such a stack depicts its conservation.
28
+ It is the maximum possible Shannon entropy of the alphabet
29
+ subtracted by the positional entropy.
30
+
31
+ Parameters
32
+ ----------
33
+ axes : Axes
34
+ The axes to draw the logo one.
35
+ profile: SequenceProfile
36
+ The logo is created based on this profile.
37
+ scheme : str or list of (tuple or str)
38
+ Either a valid color scheme name
39
+ (e.g. ``"rainbow"``, ``"clustalx"``, ``blossom``, etc.)
40
+ or a list of *Matplotlib* compatible colors.
41
+ The list length must be at least as long as the
42
+ length of the alphabet used by the `profile`.
43
+ **kwargs
44
+ Additional `text parameters <https://matplotlib.org/api/text_api.html#matplotlib.text.Text>`_.
45
+
46
+ References
47
+ ----------
48
+
49
+ .. footbibliography::
50
+ """
51
+ from matplotlib.text import Text
52
+
53
+ if isinstance(profile, Alignment):
54
+ warnings.warn("Using an alignment for this method is deprecated; use a profile instead", DeprecationWarning)
55
+ profile = SequenceProfile.from_alignment(profile)
56
+
57
+ alphabet = profile.alphabet
58
+ if not isinstance(alphabet, LetterAlphabet):
59
+ raise TypeError("The sequences' alphabet must be a letter alphabet")
60
+
61
+ if scheme is None:
62
+ colors = get_color_scheme("rainbow", alphabet)
63
+ elif isinstance(scheme, str):
64
+ colors = get_color_scheme(scheme, alphabet)
65
+ else:
66
+ colors = scheme
67
+
68
+ # 'color' and 'size' property is not passed on to text
69
+ kwargs.pop("color", None)
70
+ kwargs.pop("size", None)
71
+
72
+ frequencies, entropies, max_entropy = _get_entropy(profile)
73
+ stack_heights = (max_entropy - entropies)
74
+ symbols_heights = stack_heights[:, np.newaxis] * frequencies
75
+ index_order = np.argsort(symbols_heights, axis=1)
76
+ for i in range(symbols_heights.shape[0]):
77
+ # Iterate over the alignment columns
78
+ index_order = np.argsort(symbols_heights)
79
+ start_height = 0
80
+ for j in index_order[i]:
81
+ # Stack the symbols at position on top of the preceeding one
82
+ height = symbols_heights[i,j]
83
+ if height > 0:
84
+ symbol = alphabet.decode(j)
85
+ text = axes.text(
86
+ i+0.5, start_height, symbol,
87
+ ha="left", va="bottom", color=colors[j],
88
+ # Best results are obtained with this font size
89
+ size=1,
90
+ **kwargs
91
+ )
92
+ text.set_clip_on(True)
93
+ set_font_size_in_coord(text, width=1, height=height)
94
+ start_height += height
95
+
96
+ axes.set_xlim(0.5, len(profile.symbols)+0.5)
97
+ axes.set_ylim(0, max_entropy)
98
+
99
+
100
+ def _get_entropy(profile):
101
+ freq = profile.symbols
102
+ freq = freq / np.sum(freq, axis=1)[:, np.newaxis]
103
+ # 0 * log2(0) = 0 -> Convert NaN to 0
104
+ no_zeros = freq != 0
105
+ pre_entropies = np.zeros(freq.shape)
106
+ pre_entropies[no_zeros] \
107
+ = freq[no_zeros] * np.log2(freq[no_zeros])
108
+ entropies = -np.sum(pre_entropies, axis=1)
109
+ max_entropy = np.log2(len(profile.alphabet))
110
+ return freq, entropies, max_entropy