biotite 0.41.2__cp312-cp312-macosx_11_0_arm64.whl → 1.0.0__cp312-cp312-macosx_11_0_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 (205) hide show
  1. biotite/__init__.py +2 -3
  2. biotite/application/__init__.py +1 -1
  3. biotite/application/application.py +20 -10
  4. biotite/application/autodock/__init__.py +1 -1
  5. biotite/application/autodock/app.py +74 -79
  6. biotite/application/blast/__init__.py +1 -1
  7. biotite/application/blast/alignment.py +19 -10
  8. biotite/application/blast/webapp.py +92 -85
  9. biotite/application/clustalo/__init__.py +1 -1
  10. biotite/application/clustalo/app.py +46 -61
  11. biotite/application/dssp/__init__.py +1 -1
  12. biotite/application/dssp/app.py +8 -11
  13. biotite/application/localapp.py +62 -60
  14. biotite/application/mafft/__init__.py +1 -1
  15. biotite/application/mafft/app.py +16 -22
  16. biotite/application/msaapp.py +78 -89
  17. biotite/application/muscle/__init__.py +1 -1
  18. biotite/application/muscle/app3.py +50 -64
  19. biotite/application/muscle/app5.py +23 -31
  20. biotite/application/sra/__init__.py +1 -1
  21. biotite/application/sra/app.py +64 -68
  22. biotite/application/tantan/__init__.py +1 -1
  23. biotite/application/tantan/app.py +22 -45
  24. biotite/application/util.py +7 -9
  25. biotite/application/viennarna/rnaalifold.py +34 -28
  26. biotite/application/viennarna/rnafold.py +24 -39
  27. biotite/application/viennarna/rnaplot.py +36 -21
  28. biotite/application/viennarna/util.py +17 -12
  29. biotite/application/webapp.py +13 -14
  30. biotite/copyable.py +13 -13
  31. biotite/database/__init__.py +1 -1
  32. biotite/database/entrez/__init__.py +1 -1
  33. biotite/database/entrez/check.py +2 -3
  34. biotite/database/entrez/dbnames.py +7 -5
  35. biotite/database/entrez/download.py +55 -49
  36. biotite/database/entrez/key.py +1 -1
  37. biotite/database/entrez/query.py +62 -23
  38. biotite/database/error.py +2 -1
  39. biotite/database/pubchem/__init__.py +1 -1
  40. biotite/database/pubchem/download.py +43 -45
  41. biotite/database/pubchem/error.py +2 -2
  42. biotite/database/pubchem/query.py +34 -31
  43. biotite/database/pubchem/throttle.py +3 -4
  44. biotite/database/rcsb/__init__.py +1 -1
  45. biotite/database/rcsb/download.py +44 -52
  46. biotite/database/rcsb/query.py +85 -80
  47. biotite/database/uniprot/check.py +6 -3
  48. biotite/database/uniprot/download.py +6 -11
  49. biotite/database/uniprot/query.py +115 -31
  50. biotite/file.py +12 -31
  51. biotite/sequence/__init__.py +3 -3
  52. biotite/sequence/align/__init__.py +2 -2
  53. biotite/sequence/align/alignment.py +99 -90
  54. biotite/sequence/align/banded.cpython-312-darwin.so +0 -0
  55. biotite/sequence/align/buckets.py +12 -10
  56. biotite/sequence/align/cigar.py +43 -52
  57. biotite/sequence/align/kmeralphabet.cpython-312-darwin.so +0 -0
  58. biotite/sequence/align/kmeralphabet.pyx +55 -51
  59. biotite/sequence/align/kmersimilarity.cpython-312-darwin.so +0 -0
  60. biotite/sequence/align/kmertable.cpython-312-darwin.so +0 -0
  61. biotite/sequence/align/kmertable.pyx +3 -2
  62. biotite/sequence/align/localgapped.cpython-312-darwin.so +0 -0
  63. biotite/sequence/align/localungapped.cpython-312-darwin.so +0 -0
  64. biotite/sequence/align/matrix.py +81 -82
  65. biotite/sequence/align/multiple.cpython-312-darwin.so +0 -0
  66. biotite/sequence/align/multiple.pyx +1 -1
  67. biotite/sequence/align/pairwise.cpython-312-darwin.so +0 -0
  68. biotite/sequence/align/permutation.cpython-312-darwin.so +0 -0
  69. biotite/sequence/align/permutation.pyx +12 -4
  70. biotite/sequence/align/selector.cpython-312-darwin.so +0 -0
  71. biotite/sequence/align/selector.pyx +52 -54
  72. biotite/sequence/align/statistics.py +32 -33
  73. biotite/sequence/align/tracetable.cpython-312-darwin.so +0 -0
  74. biotite/sequence/alphabet.py +51 -65
  75. biotite/sequence/annotation.py +78 -77
  76. biotite/sequence/codec.cpython-312-darwin.so +0 -0
  77. biotite/sequence/codon.py +90 -79
  78. biotite/sequence/graphics/__init__.py +1 -1
  79. biotite/sequence/graphics/alignment.py +184 -103
  80. biotite/sequence/graphics/colorschemes.py +10 -12
  81. biotite/sequence/graphics/dendrogram.py +79 -34
  82. biotite/sequence/graphics/features.py +133 -99
  83. biotite/sequence/graphics/logo.py +22 -28
  84. biotite/sequence/graphics/plasmid.py +229 -178
  85. biotite/sequence/io/fasta/__init__.py +1 -1
  86. biotite/sequence/io/fasta/convert.py +44 -33
  87. biotite/sequence/io/fasta/file.py +42 -55
  88. biotite/sequence/io/fastq/__init__.py +1 -1
  89. biotite/sequence/io/fastq/convert.py +11 -14
  90. biotite/sequence/io/fastq/file.py +68 -112
  91. biotite/sequence/io/genbank/__init__.py +2 -2
  92. biotite/sequence/io/genbank/annotation.py +12 -20
  93. biotite/sequence/io/genbank/file.py +74 -76
  94. biotite/sequence/io/genbank/metadata.py +74 -62
  95. biotite/sequence/io/genbank/sequence.py +13 -14
  96. biotite/sequence/io/general.py +39 -30
  97. biotite/sequence/io/gff/__init__.py +2 -2
  98. biotite/sequence/io/gff/convert.py +10 -15
  99. biotite/sequence/io/gff/file.py +81 -65
  100. biotite/sequence/phylo/__init__.py +1 -1
  101. biotite/sequence/phylo/nj.cpython-312-darwin.so +0 -0
  102. biotite/sequence/phylo/tree.cpython-312-darwin.so +0 -0
  103. biotite/sequence/phylo/upgma.cpython-312-darwin.so +0 -0
  104. biotite/sequence/profile.py +57 -28
  105. biotite/sequence/search.py +17 -15
  106. biotite/sequence/seqtypes.py +200 -164
  107. biotite/sequence/sequence.py +15 -17
  108. biotite/structure/__init__.py +3 -3
  109. biotite/structure/atoms.py +221 -235
  110. biotite/structure/basepairs.py +260 -271
  111. biotite/structure/bonds.cpython-312-darwin.so +0 -0
  112. biotite/structure/bonds.pyx +29 -32
  113. biotite/structure/box.py +67 -71
  114. biotite/structure/celllist.cpython-312-darwin.so +0 -0
  115. biotite/structure/chains.py +55 -39
  116. biotite/structure/charges.cpython-312-darwin.so +0 -0
  117. biotite/structure/compare.py +32 -32
  118. biotite/structure/density.py +13 -18
  119. biotite/structure/dotbracket.py +20 -22
  120. biotite/structure/error.py +10 -2
  121. biotite/structure/filter.py +82 -77
  122. biotite/structure/geometry.py +130 -119
  123. biotite/structure/graphics/atoms.py +60 -43
  124. biotite/structure/graphics/rna.py +81 -68
  125. biotite/structure/hbond.py +112 -93
  126. biotite/structure/info/__init__.py +0 -2
  127. biotite/structure/info/atoms.py +10 -11
  128. biotite/structure/info/bonds.py +41 -43
  129. biotite/structure/info/ccd.py +4 -5
  130. biotite/structure/info/groups.py +1 -3
  131. biotite/structure/info/masses.py +5 -10
  132. biotite/structure/info/misc.py +1 -1
  133. biotite/structure/info/radii.py +20 -20
  134. biotite/structure/info/standardize.py +15 -26
  135. biotite/structure/integrity.py +18 -71
  136. biotite/structure/io/__init__.py +3 -4
  137. biotite/structure/io/dcd/__init__.py +1 -1
  138. biotite/structure/io/dcd/file.py +22 -20
  139. biotite/structure/io/general.py +47 -61
  140. biotite/structure/io/gro/__init__.py +1 -1
  141. biotite/structure/io/gro/file.py +73 -72
  142. biotite/structure/io/mol/__init__.py +1 -1
  143. biotite/structure/io/mol/convert.py +8 -11
  144. biotite/structure/io/mol/ctab.py +37 -36
  145. biotite/structure/io/mol/header.py +14 -10
  146. biotite/structure/io/mol/mol.py +9 -53
  147. biotite/structure/io/mol/sdf.py +47 -50
  148. biotite/structure/io/netcdf/__init__.py +1 -1
  149. biotite/structure/io/netcdf/file.py +24 -23
  150. biotite/structure/io/pdb/__init__.py +1 -1
  151. biotite/structure/io/pdb/convert.py +32 -20
  152. biotite/structure/io/pdb/file.py +151 -172
  153. biotite/structure/io/pdb/hybrid36.cpython-312-darwin.so +0 -0
  154. biotite/structure/io/pdbqt/__init__.py +1 -1
  155. biotite/structure/io/pdbqt/convert.py +17 -11
  156. biotite/structure/io/pdbqt/file.py +128 -80
  157. biotite/structure/io/pdbx/__init__.py +1 -2
  158. biotite/structure/io/pdbx/bcif.py +36 -44
  159. biotite/structure/io/pdbx/cif.py +64 -62
  160. biotite/structure/io/pdbx/component.py +10 -16
  161. biotite/structure/io/pdbx/convert.py +235 -246
  162. biotite/structure/io/pdbx/encoding.cpython-312-darwin.so +0 -0
  163. biotite/structure/io/trajfile.py +76 -93
  164. biotite/structure/io/trr/__init__.py +1 -1
  165. biotite/structure/io/trr/file.py +12 -15
  166. biotite/structure/io/xtc/__init__.py +1 -1
  167. biotite/structure/io/xtc/file.py +11 -14
  168. biotite/structure/mechanics.py +9 -11
  169. biotite/structure/molecules.py +3 -4
  170. biotite/structure/pseudoknots.py +53 -67
  171. biotite/structure/rdf.py +23 -21
  172. biotite/structure/repair.py +137 -86
  173. biotite/structure/residues.py +26 -16
  174. biotite/structure/sasa.cpython-312-darwin.so +0 -0
  175. biotite/structure/{resutil.py → segments.py} +24 -23
  176. biotite/structure/sequence.py +10 -11
  177. biotite/structure/sse.py +100 -119
  178. biotite/structure/superimpose.py +39 -77
  179. biotite/structure/transform.py +97 -71
  180. biotite/structure/util.py +11 -13
  181. biotite/version.py +2 -2
  182. biotite/visualize.py +69 -55
  183. {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/METADATA +5 -5
  184. biotite-1.0.0.dist-info/RECORD +322 -0
  185. biotite/structure/io/ctab.py +0 -72
  186. biotite/structure/io/mmtf/__init__.py +0 -21
  187. biotite/structure/io/mmtf/assembly.py +0 -214
  188. biotite/structure/io/mmtf/convertarray.cpython-312-darwin.so +0 -0
  189. biotite/structure/io/mmtf/convertarray.pyx +0 -341
  190. biotite/structure/io/mmtf/convertfile.cpython-312-darwin.so +0 -0
  191. biotite/structure/io/mmtf/convertfile.pyx +0 -501
  192. biotite/structure/io/mmtf/decode.cpython-312-darwin.so +0 -0
  193. biotite/structure/io/mmtf/decode.pyx +0 -152
  194. biotite/structure/io/mmtf/encode.cpython-312-darwin.so +0 -0
  195. biotite/structure/io/mmtf/encode.pyx +0 -183
  196. biotite/structure/io/mmtf/file.py +0 -233
  197. biotite/structure/io/npz/__init__.py +0 -20
  198. biotite/structure/io/npz/file.py +0 -152
  199. biotite/structure/io/pdbx/legacy.py +0 -267
  200. biotite/structure/io/tng/__init__.py +0 -13
  201. biotite/structure/io/tng/file.py +0 -46
  202. biotite/temp.py +0 -86
  203. biotite-0.41.2.dist-info/RECORD +0 -340
  204. {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/WHEEL +0 -0
  205. {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/licenses/LICENSE.rst +0 -0
@@ -9,12 +9,12 @@ __all__ = ["RNAalifoldApp"]
9
9
  import copy
10
10
  from tempfile import NamedTemporaryFile
11
11
  import numpy as np
12
- from ..application import AppState, requires_state
13
- from ..localapp import LocalApp, cleanup_tempfile
14
- from ...sequence.io.fasta import FastaFile, set_alignment
15
- from ...structure.dotbracket import base_pairs_from_dot_bracket
16
- from ...structure.bonds import BondList
17
- from .util import build_constraint_string
12
+ from biotite.application.application import AppState, requires_state
13
+ from biotite.application.localapp import LocalApp, cleanup_tempfile
14
+ from biotite.application.viennarna.util import build_constraint_string
15
+ from biotite.sequence.io.fasta import FastaFile, set_alignment
16
+ from biotite.structure.bonds import BondList
17
+ from biotite.structure.dotbracket import base_pairs_from_dot_bracket
18
18
 
19
19
 
20
20
  class RNAalifoldApp(LocalApp):
@@ -45,9 +45,7 @@ class RNAalifoldApp(LocalApp):
45
45
  self._temperature = str(temperature)
46
46
  self._constraints = None
47
47
  self._enforce = None
48
- self._in_file = NamedTemporaryFile(
49
- "w", suffix=".fa", delete=False
50
- )
48
+ self._in_file = NamedTemporaryFile("w", suffix=".fa", delete=False)
51
49
  self._constraints_file = NamedTemporaryFile(
52
50
  "w+", suffix=".constraints", delete=False
53
51
  )
@@ -57,15 +55,17 @@ class RNAalifoldApp(LocalApp):
57
55
  # -> Extremely high value for characters per line
58
56
  fasta_file = FastaFile(chars_per_line=np.iinfo(np.int32).max)
59
57
  set_alignment(
60
- fasta_file, self._alignment,
61
- seq_names=[str(i) for i in range(len(self._alignment.sequences))]
58
+ fasta_file,
59
+ self._alignment,
60
+ seq_names=[str(i) for i in range(len(self._alignment.sequences))],
62
61
  )
63
62
  fasta_file.write(self._in_file)
64
63
  self._in_file.flush()
65
64
 
66
65
  options = [
67
66
  "--noPS",
68
- "-T", self._temperature,
67
+ "-T",
68
+ self._temperature,
69
69
  ]
70
70
  if self._enforce is True:
71
71
  options.append("--enforceConstraint")
@@ -78,7 +78,7 @@ class RNAalifoldApp(LocalApp):
78
78
 
79
79
  self.set_arguments(options + [self._in_file.name])
80
80
  super().run()
81
-
81
+
82
82
  def clean_up(self):
83
83
  super().clean_up()
84
84
  cleanup_tempfile(self._in_file)
@@ -97,7 +97,7 @@ class RNAalifoldApp(LocalApp):
97
97
  self._free_energy = float(energy_contributions[0])
98
98
  self._covariance_energy = float(energy_contributions[1])
99
99
  self._dotbracket = dotbracket
100
-
100
+
101
101
  @requires_state(AppState.CREATED)
102
102
  def set_temperature(self, temperature):
103
103
  """
@@ -110,10 +110,17 @@ class RNAalifoldApp(LocalApp):
110
110
  The temperature.
111
111
  """
112
112
  self._temperature = str(temperature)
113
-
113
+
114
114
  @requires_state(AppState.CREATED)
115
- def set_constraints(self, pairs=None, paired=None, unpaired=None,
116
- downstream=None, upstream=None, enforce=False):
115
+ def set_constraints(
116
+ self,
117
+ pairs=None,
118
+ paired=None,
119
+ unpaired=None,
120
+ downstream=None,
121
+ upstream=None,
122
+ enforce=False,
123
+ ):
117
124
  """
118
125
  Add constraints of known paired or unpaired bases to the folding
119
126
  algorithm.
@@ -138,15 +145,14 @@ class RNAalifoldApp(LocalApp):
138
145
  the respective base pairs must form.
139
146
  By default (false), a constraint does only forbid formation
140
147
  of a pair that would conflict with this constraint.
141
-
148
+
142
149
  Warnings
143
150
  --------
144
151
  If a constraint is given for a gap position in the consensus sequence,
145
152
  the software may find no base pairs at all.
146
153
  """
147
154
  self._constraints = build_constraint_string(
148
- len(self._alignment),
149
- pairs, paired, unpaired, downstream, upstream
155
+ len(self._alignment), pairs, paired, unpaired, downstream, upstream
150
156
  )
151
157
  self._enforce = enforce
152
158
 
@@ -160,19 +166,19 @@ class RNAalifoldApp(LocalApp):
160
166
  -------
161
167
  free_energy : float
162
168
  The free energy.
163
-
169
+
164
170
  Notes
165
171
  -----
166
172
  The total energy of the secondary structure regarding the
167
173
  minimization objective is the sum of the free energy and the
168
174
  covariance term.
169
-
175
+
170
176
  See also
171
177
  --------
172
178
  get_covariance_energy
173
179
  """
174
180
  return self._free_energy
175
-
181
+
176
182
  @requires_state(AppState.JOINED)
177
183
  def get_covariance_energy(self):
178
184
  """
@@ -183,19 +189,19 @@ class RNAalifoldApp(LocalApp):
183
189
  -------
184
190
  covariance_energy : float
185
191
  The energy of the covariance term.
186
-
192
+
187
193
  Notes
188
194
  -----
189
195
  The total energy of the secondary structure regarding the
190
196
  minimization objective is the sum of the free energy and the
191
197
  covariance term.
192
-
198
+
193
199
  See also
194
200
  --------
195
201
  get_free_energy
196
202
  """
197
203
  return self._covariance_energy
198
-
204
+
199
205
  @requires_state(AppState.JOINED)
200
206
  def get_consensus_sequence_string(self):
201
207
  """
@@ -265,7 +271,7 @@ class RNAalifoldApp(LocalApp):
265
271
  pair_list = pair_list[trace != -1]
266
272
  # Convert back to array of base pairs,
267
273
  # remove unused BondType column
268
- base_pairs = pair_list.as_array()[:,:2]
274
+ base_pairs = pair_list.as_array()[:, :2]
269
275
  return base_pairs
270
276
 
271
277
  @staticmethod
@@ -300,5 +306,5 @@ class RNAalifoldApp(LocalApp):
300
306
  return (
301
307
  app.get_dot_bracket(),
302
308
  app.get_free_energy(),
303
- app.get_covariance_energy()
309
+ app.get_covariance_energy(),
304
310
  )
@@ -6,14 +6,13 @@ __name__ = "biotite.application.viennarna"
6
6
  __author__ = "Tom David Müller, Patrick Kunzmann"
7
7
  __all__ = ["RNAfoldApp"]
8
8
 
9
- import warnings
10
9
  from tempfile import NamedTemporaryFile
11
10
  import numpy as np
12
- from ..application import AppState, requires_state
13
- from ..localapp import LocalApp, cleanup_tempfile
14
- from ...sequence.io.fasta import FastaFile, set_sequence
15
- from ...structure.dotbracket import base_pairs_from_dot_bracket
16
- from .util import build_constraint_string
11
+ from biotite.application.application import AppState, requires_state
12
+ from biotite.application.localapp import LocalApp, cleanup_tempfile
13
+ from biotite.application.viennarna.util import build_constraint_string
14
+ from biotite.sequence.io.fasta import FastaFile, set_sequence
15
+ from biotite.structure.dotbracket import base_pairs_from_dot_bracket
17
16
 
18
17
 
19
18
  class RNAfoldApp(LocalApp):
@@ -51,9 +50,7 @@ class RNAfoldApp(LocalApp):
51
50
  self._temperature = str(temperature)
52
51
  self._constraints = None
53
52
  self._enforce = None
54
- self._in_file = NamedTemporaryFile(
55
- "w", suffix=".fa", delete=False
56
- )
53
+ self._in_file = NamedTemporaryFile("w", suffix=".fa", delete=False)
57
54
  super().__init__(bin_path)
58
55
 
59
56
  def run(self):
@@ -65,10 +62,11 @@ class RNAfoldApp(LocalApp):
65
62
  fasta_file.lines.append(self._constraints)
66
63
  fasta_file.write(self._in_file)
67
64
  self._in_file.flush()
68
-
65
+
69
66
  options = [
70
67
  "--noPS",
71
- "-T", self._temperature,
68
+ "-T",
69
+ self._temperature,
72
70
  ]
73
71
  if self._enforce is True:
74
72
  options.append("--enforceConstraint")
@@ -87,11 +85,11 @@ class RNAfoldApp(LocalApp):
87
85
 
88
86
  self._free_energy = free_energy
89
87
  self._dotbracket = dotbracket
90
-
88
+
91
89
  def clean_up(self):
92
90
  super().clean_up()
93
91
  cleanup_tempfile(self._in_file)
94
-
92
+
95
93
  @requires_state(AppState.CREATED)
96
94
  def set_temperature(self, temperature):
97
95
  """
@@ -104,10 +102,17 @@ class RNAfoldApp(LocalApp):
104
102
  The temperature.
105
103
  """
106
104
  self._temperature = str(temperature)
107
-
105
+
108
106
  @requires_state(AppState.CREATED)
109
- def set_constraints(self, pairs=None, paired=None, unpaired=None,
110
- downstream=None, upstream=None, enforce=False):
107
+ def set_constraints(
108
+ self,
109
+ pairs=None,
110
+ paired=None,
111
+ unpaired=None,
112
+ downstream=None,
113
+ upstream=None,
114
+ enforce=False,
115
+ ):
111
116
  """
112
117
  Add constraints of known paired or unpaired bases to the folding
113
118
  algorithm.
@@ -134,11 +139,10 @@ class RNAfoldApp(LocalApp):
134
139
  of a pair that would conflict with this constraint.
135
140
  """
136
141
  self._constraints = build_constraint_string(
137
- len(self._sequence),
138
- pairs, paired, unpaired, downstream, upstream
142
+ len(self._sequence), pairs, paired, unpaired, downstream, upstream
139
143
  )
140
144
  self._enforce = enforce
141
-
145
+
142
146
  @requires_state(AppState.JOINED)
143
147
  def get_free_energy(self):
144
148
  """
@@ -162,25 +166,6 @@ class RNAfoldApp(LocalApp):
162
166
  """
163
167
  return self._free_energy
164
168
 
165
- @requires_state(AppState.JOINED)
166
- def get_mfe(self):
167
- """
168
- Get the free energy (kcal/mol) of the suggested
169
- secondary structure.
170
-
171
- DEPRECATED: Use :meth:`get_free_energy()` instead.
172
-
173
- Returns
174
- -------
175
- mfe : float
176
- The minimum free energy.
177
- """
178
- warnings.warn(
179
- "'get_mfe()' is deprecated, use 'get_free_energy()' instead",
180
- DeprecationWarning
181
- )
182
- return self.get_free_energy()
183
-
184
169
  @requires_state(AppState.JOINED)
185
170
  def get_dot_bracket(self):
186
171
  """
@@ -243,7 +228,7 @@ class RNAfoldApp(LocalApp):
243
228
  @staticmethod
244
229
  def compute_secondary_structure(sequence, bin_path="RNAfold"):
245
230
  """
246
- Compute the minimum free energy secondary structure of a
231
+ Compute the minimum free energy secondary structure of a
247
232
  ribonucleic acid sequence using *ViennaRNA's* *RNAfold* software.
248
233
 
249
234
  This is a convenience function, that wraps the
@@ -6,13 +6,14 @@ __name__ = "biotite.application.viennarna"
6
6
  __author__ = "Tom David Müller"
7
7
  __all__ = ["RNAplotApp"]
8
8
 
9
- import numpy as np
10
- from tempfile import NamedTemporaryFile
11
- from os import remove
12
9
  from enum import IntEnum
13
- from ..localapp import LocalApp, cleanup_tempfile
14
- from ..application import AppState, requires_state
15
- from ...structure.dotbracket import dot_bracket as dot_bracket_
10
+ from os import remove
11
+ from tempfile import NamedTemporaryFile
12
+ import numpy as np
13
+ from biotite.application.application import AppState, requires_state
14
+ from biotite.application.localapp import LocalApp, cleanup_tempfile
15
+ from biotite.structure.dotbracket import dot_bracket as dot_bracket_
16
+
16
17
 
17
18
  class RNAplotApp(LocalApp):
18
19
  """
@@ -60,21 +61,28 @@ class RNAplotApp(LocalApp):
60
61
  This enum type represents the layout type of the plot according
61
62
  to the official *RNAplot* orientation.
62
63
  """
63
- RADIAL = 0,
64
- NAVIEW = 1,
65
- CIRCULAR = 2,
66
- RNATURTLE = 3,
64
+
65
+ RADIAL = (0,)
66
+ NAVIEW = (1,)
67
+ CIRCULAR = (2,)
68
+ RNATURTLE = (3,)
67
69
  RNAPUZZLER = 4
68
70
 
69
- def __init__(self, dot_bracket=None, base_pairs=None, length=None,
70
- layout_type=Layout.NAVIEW, bin_path="RNAplot"):
71
+ def __init__(
72
+ self,
73
+ dot_bracket=None,
74
+ base_pairs=None,
75
+ length=None,
76
+ layout_type=Layout.NAVIEW,
77
+ bin_path="RNAplot",
78
+ ):
71
79
  super().__init__(bin_path)
72
80
 
73
81
  if dot_bracket is not None:
74
82
  self._dot_bracket = dot_bracket
75
83
  elif (base_pairs is not None) and (length is not None):
76
84
  self._dot_bracket = dot_bracket_(
77
- base_pairs, length, max_pseudoknot_order = 0
85
+ base_pairs, length, max_pseudoknot_order=0
78
86
  )[0]
79
87
  else:
80
88
  raise ValueError(
@@ -84,10 +92,10 @@ class RNAplotApp(LocalApp):
84
92
 
85
93
  # Get the value of the enum type
86
94
  self._layout_type = str(int(layout_type))
87
- self._in_file = NamedTemporaryFile("w", suffix=".fold", delete=False)
95
+ self._in_file = NamedTemporaryFile("w", suffix=".fold", delete=False)
88
96
 
89
97
  def run(self):
90
- self._in_file.write("N"*len(self._dot_bracket) + "\n")
98
+ self._in_file.write("N" * len(self._dot_bracket) + "\n")
91
99
  self._in_file.write(self._dot_bracket)
92
100
  self._in_file.flush()
93
101
  self.set_arguments(
@@ -146,8 +154,11 @@ class RNAplotApp(LocalApp):
146
154
 
147
155
  @staticmethod
148
156
  def compute_coordinates(
149
- dot_bracket=None, base_pairs=None, length=None,
150
- layout_type=Layout.NAVIEW, bin_path="RNAplot"
157
+ dot_bracket=None,
158
+ base_pairs=None,
159
+ length=None,
160
+ layout_type=Layout.NAVIEW,
161
+ bin_path="RNAplot",
151
162
  ):
152
163
  """
153
164
  Get coordinates for a 2D representation of any unknotted RNA
@@ -179,9 +190,13 @@ class RNAplotApp(LocalApp):
179
190
  The 2D coordinates. Each row represents the *x* and *y*
180
191
  coordinates for a total sequence length of *n*.
181
192
  """
182
- app = RNAplotApp(dot_bracket=dot_bracket, base_pairs=base_pairs,
183
- length=length, layout_type=layout_type,
184
- bin_path=bin_path)
193
+ app = RNAplotApp(
194
+ dot_bracket=dot_bracket,
195
+ base_pairs=base_pairs,
196
+ length=length,
197
+ layout_type=layout_type,
198
+ bin_path=bin_path,
199
+ )
185
200
  app.start()
186
201
  app.join()
187
- return app.get_coordinates()
202
+ return app.get_coordinates()
@@ -7,12 +7,17 @@ __author__ = "Patrick Kunzmann"
7
7
  __all__ = ["build_constraint_string"]
8
8
 
9
9
  import numpy as np
10
- from ...structure.pseudoknots import pseudoknots
10
+ from biotite.structure.pseudoknots import pseudoknots
11
11
 
12
12
 
13
- def build_constraint_string(sequence_length,
14
- pairs=None, paired=None, unpaired=None,
15
- downstream=None, upstream=None):
13
+ def build_constraint_string(
14
+ sequence_length,
15
+ pairs=None,
16
+ paired=None,
17
+ unpaired=None,
18
+ downstream=None,
19
+ upstream=None,
20
+ ):
16
21
  """
17
22
  Build a ViennaRNA constraint string.
18
23
 
@@ -30,7 +35,7 @@ def build_constraint_string(sequence_length,
30
35
  Positions of bases that are paired with any downstream base.
31
36
  upstream : ndarray, shape=(n,), dtype=int or dtype=bool, optional
32
37
  Positions of bases that are paired with any upstream base.
33
-
38
+
34
39
  Returns
35
40
  -------
36
41
  constraints : str
@@ -45,21 +50,21 @@ def build_constraint_string(sequence_length,
45
50
  raise ValueError("Given pairs include pseudoknots")
46
51
  # Ensure the lower base comes first for each pair
47
52
  pairs = np.sort(pairs, axis=-1)
48
- _set_constraints(constraints, pairs[:,0], "(")
49
- _set_constraints(constraints, pairs[:,1], ")")
53
+ _set_constraints(constraints, pairs[:, 0], "(")
54
+ _set_constraints(constraints, pairs[:, 1], ")")
50
55
 
51
56
  _set_constraints(constraints, paired, "|")
52
57
  _set_constraints(constraints, unpaired, "x")
53
58
  _set_constraints(constraints, downstream, "<")
54
59
  _set_constraints(constraints, upstream, ">")
55
-
60
+
56
61
  return "".join(constraints)
57
-
62
+
58
63
 
59
64
  def _set_constraints(constraints, index, character):
60
65
  if index is None:
61
66
  return
62
-
67
+
63
68
  # Search for conflicts with other constraints
64
69
  potential_conflict_indices = np.where(constraints[index] != ".")[0]
65
70
  if len(potential_conflict_indices) > 0:
@@ -68,5 +73,5 @@ def _set_constraints(constraints, index, character):
68
73
  f"Constraint '{character}' at position {conflict_i} "
69
74
  f"conflicts with existing constraint '{constraints[conflict_i]}'"
70
75
  )
71
-
72
- constraints[index] = character
76
+
77
+ constraints[index] = character
@@ -7,22 +7,22 @@ __author__ = "Patrick Kunzmann"
7
7
  __all__ = ["WebApp", "RuleViolationError"]
8
8
 
9
9
  import abc
10
- from .application import Application
10
+ from biotite.application.application import Application
11
11
 
12
12
 
13
13
  class WebApp(Application, metaclass=abc.ABCMeta):
14
14
  """
15
15
  The base class for all web based applications.
16
-
16
+
17
17
  It allows for getting and setting the URL of the app and raises
18
18
  an :class:`RuleViolationError` when a subclass calls
19
19
  :func:`violate_rule()`
20
20
  (e.g. when the server was contacted too often.)
21
-
21
+
22
22
  Be careful, when calling func:`get_app_state()`. This may involve a
23
23
  server contact and therefore frequent calls may raise a
24
24
  :class:`RuleViolationError`.
25
-
25
+
26
26
  Parameters
27
27
  ----------
28
28
  app_url : str
@@ -31,19 +31,19 @@ class WebApp(Application, metaclass=abc.ABCMeta):
31
31
  If true, the application raises an :class:`RuleViolationError`, if
32
32
  the server rules are violated. (Default: True)
33
33
  """
34
-
34
+
35
35
  def __init__(self, app_url, obey_rules=True):
36
36
  super().__init__()
37
37
  self._obey_rules = obey_rules
38
38
  self._app_url = app_url
39
-
39
+
40
40
  def violate_rule(self, msg=None):
41
41
  """
42
42
  Indicate that a server rule was violated, i.e. this raises a
43
43
  :class:`RuleViolationError` unless `obey_rules` is false.
44
-
44
+
45
45
  PROTECTED: Do not call from outside.
46
-
46
+
47
47
  Parameters
48
48
  ----------
49
49
  msg : str, optional
@@ -51,16 +51,14 @@ class WebApp(Application, metaclass=abc.ABCMeta):
51
51
  """
52
52
  if self._obey_rules:
53
53
  if msg is None:
54
- raise RuleViolationError(
55
- "The user guidelines would be violated"
56
- )
54
+ raise RuleViolationError("The user guidelines would be violated")
57
55
  else:
58
56
  raise RuleViolationError(msg)
59
-
57
+
60
58
  def app_url(self):
61
59
  """
62
60
  Get the URL of the web app.
63
-
61
+
64
62
  Returns
65
63
  -------
66
64
  url : str
@@ -74,4 +72,5 @@ class RuleViolationError(Exception):
74
72
  Indicates that the user guidelines of the web application would be
75
73
  violated, if the program continued.
76
74
  """
77
- pass
75
+
76
+ pass
biotite/copyable.py CHANGED
@@ -12,22 +12,22 @@ import abc
12
12
  class Copyable(metaclass=abc.ABCMeta):
13
13
  """
14
14
  Base class for all objects, that should be copyable.
15
-
15
+
16
16
  The public method `copy()` first creates a fresh instance of the
17
17
  class of the instance, that is copied via the `__copy_create__()`
18
18
  method. All variables, that could not be set via the constructor,
19
19
  are then copied via `__copy_fill__()`, starting with the method in
20
20
  the uppermost base class and ending with the class of the instance
21
21
  to be copied.
22
-
22
+
23
23
  This approach solves the problem of encapsulated variables in
24
24
  superclasses.
25
25
  """
26
-
26
+
27
27
  def copy(self):
28
28
  """
29
29
  Create a deep copy of this object.
30
-
30
+
31
31
  Returns
32
32
  -------
33
33
  copy
@@ -36,36 +36,36 @@ class Copyable(metaclass=abc.ABCMeta):
36
36
  clone = self.__copy_create__()
37
37
  self.__copy_fill__(clone)
38
38
  return clone
39
-
39
+
40
40
  def __copy_create__(self):
41
41
  """
42
42
  Instantiate a new object of this class.
43
-
43
+
44
44
  Only the constructor should be called in this method.
45
45
  All further attributes, that need to be copied are handled
46
46
  in `__copy_fill__()`
47
-
47
+
48
48
  Do not call the `super()` method here.
49
-
49
+
50
50
  This method must be overridden, if the constructor takes
51
51
  parameters.
52
-
52
+
53
53
  Returns
54
54
  -------
55
55
  copy
56
56
  A freshly instantiated copy of *self*.
57
57
  """
58
58
  return type(self)()
59
-
59
+
60
60
  def __copy_fill__(self, clone):
61
61
  """
62
62
  Copy all necessary attributes to the new object.
63
-
63
+
64
64
  Always call the `super()` method as first statement.
65
-
65
+
66
66
  Parameters
67
67
  ----------
68
68
  clone
69
69
  The freshly instantiated copy of *self*.
70
70
  """
71
- pass
71
+ pass
@@ -20,4 +20,4 @@ download the associated files.
20
20
  __name__ = "biotite.database"
21
21
  __author__ = "Patrick Kunzmann"
22
22
 
23
- from .error import *
23
+ from .error import *
@@ -11,5 +11,5 @@ __author__ = "Patrick Kunzmann"
11
11
 
12
12
  from .dbnames import *
13
13
  from .download import *
14
+ from .key import *
14
15
  from .query import *
15
- from .key import *
@@ -7,8 +7,7 @@ __author__ = "Patrick Kunzmann, Maximilian Dombrowsky"
7
7
  __all__ = ["check_for_errors"]
8
8
 
9
9
  import json
10
- from ..error import RequestError
11
-
10
+ from biotite.database.error import RequestError
12
11
 
13
12
  # Taken from https://github.com/kblin/ncbi-entrez-error-messages
14
13
  _error_messages = [
@@ -58,4 +57,4 @@ def check_for_errors(message):
58
57
  for error_msg in _error_messages:
59
58
  # Often whitespace is also replaced by '+' in error message
60
59
  if error_msg.replace(" ", "") in message_end:
61
- raise RequestError(error_msg)
60
+ raise RequestError(error_msg)
@@ -7,6 +7,7 @@ __author__ = "Patrick Kunzmann"
7
7
  __all__ = ["get_database_name"]
8
8
 
9
9
 
10
+ # fmt: off
10
11
  _db_names = {
11
12
  "BioProject" : "bioproject",
12
13
  "BioSample" : "biosample",
@@ -45,26 +46,27 @@ _db_names = {
45
46
  "UniGene" : "unigene",
46
47
  "UniSTS" : "unists"
47
48
  }
49
+ # fmt: on
48
50
 
49
51
 
50
52
  def get_database_name(database):
51
53
  """
52
54
  Map a common NCBI Entrez database name to an E-utility database
53
55
  name.
54
-
56
+
55
57
  Parameters
56
58
  ----------
57
59
  database : str
58
60
  Entrez database name.
59
-
61
+
60
62
  Returns
61
63
  -------
62
64
  name : str
63
65
  E-utility database name.
64
-
66
+
65
67
  Examples
66
68
  --------
67
-
69
+
68
70
  >>> print(get_database_name("Nucleotide"))
69
71
  nuccore
70
72
  """
@@ -86,4 +88,4 @@ def sanitize_database_name(db_name):
86
88
  # Is already E-utility database name
87
89
  return db_name
88
90
  else:
89
- raise ValueError("Database '{db_name}' is not existing")
91
+ raise ValueError("Database '{db_name}' is not existing")