Skip to content

Commit

Permalink
Adopted doctests for new NumPy float formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
padix-key committed Mar 18, 2019
1 parent d0424a3 commit 69f2d60
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 60 deletions.
8 changes: 4 additions & 4 deletions src/biotite/sequence/align/multiple.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ def align_multiple(sequences, matrix, gap_penalty=-10, terminal_penalty=True,
BIQT-ITE
TITANITE
>>> print(distances)
[[-0. 1.0340737 0.3819849 0.5604919]
[ 1.0340737 -0. 0.9231636 1.1316341]
[ 0.3819849 0.9231636 -0. 0.6316943]
[ 0.5604919 1.1316341 0.6316943 -0. ]]
[[-0.000 1.034 0.382 0.560]
[ 1.034 -0.000 0.923 1.132]
[ 0.382 0.923 -0.000 0.632]
[ 0.560 1.132 0.632 -0.000]]
>>>
>>> print(tree.to_newick(
... labels=["seq1", "seq2", "seq3", "seq4"], include_distance=False
Expand Down
8 changes: 4 additions & 4 deletions src/biotite/structure/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,10 @@ def coord_to_fraction(coord, box):
[-5. 2. 1.]]
>>> fractions = coord_to_fraction(coord, box)
>>> print(fractions)
[[ 0.2 0. 0.2]
[ 2. 0. 0. ]
[ 0. -2. 2. ]
[-1. 0.2 0.2]]
[[ 0.2 0.0 0.2]
[ 2.0 0.0 0.0]
[ 0.0 -2.0 2.0]
[-1.0 0.2 0.2]]
"""
return np.matmul(coord, linalg.inv(box))

Expand Down
40 changes: 20 additions & 20 deletions src/biotite/structure/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,26 +515,26 @@ def dihedral_backbone(atom_array, chain_id):
>>> phi, psi, omega = dihedral_backbone(atom_array, "A")
>>> print(np.stack([phi * 360/(2*np.pi), psi * 360/(2*np.pi)]).T)
[[ nan -56.14491122]
[ -43.98001079 -51.30875902]
[ -66.46585868 -30.89801505]
[ -65.21943089 -45.94467406]
[ -64.74659263 -30.346291 ]
[ -73.13553596 -43.42456851]
[ -64.88203916 -43.25451315]
[ -59.50867772 -25.69819463]
[ -77.98930479 -8.82307681]
[ 110.78405639 8.07924448]
[ 55.24420794 -124.37141223]
[ -57.98304696 -28.76563093]
[ -81.83404402 19.12508041]
[-124.05653736 13.40120726]
[ 67.93147348 25.21773833]
[-143.95159184 131.29701851]
[ -70.10004605 160.06790798]
[ -69.48368612 145.66883187]
[ -77.26416822 124.22289316]
[ -78.10009149 nan]]
[[ nan -56.145]
[ -43.980 -51.309]
[ -66.466 -30.898]
[ -65.219 -45.945]
[ -64.747 -30.346]
[ -73.136 -43.425]
[ -64.882 -43.255]
[ -59.509 -25.698]
[ -77.989 -8.823]
[ 110.784 8.079]
[ 55.244 -124.371]
[ -57.983 -28.766]
[ -81.834 19.125]
[-124.057 13.401]
[ 67.931 25.218]
[-143.952 131.297]
[ -70.100 160.068]
[ -69.484 145.669]
[ -77.264 124.223]
[ -78.100 nan]]
"""
# Filter all backbone atoms
bb_coord = atom_array[...,
Expand Down
12 changes: 4 additions & 8 deletions src/biotite/structure/hbond.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,9 @@ def hbond_frequency(mask):
>>> triplets, mask = hbond(atom_array_stack)
>>> freq = hbond_frequency(mask)
>>> print(freq)
[0.26315789 0.28947368 0.10526316 0.10526316 0.23684211 0.23684211
0.02631579 0.05263158 0.39473684 1. 1. 1.
0.02631579 0.42105263 0.02631579 0.02631579 0.31578947 0.81578947
0.02631579 0.92105263 0.02631579 0.34210526 0.02631579 0.10526316
0.02631579 0.13157895 0.05263158 0.02631579 0.15789474 0.02631579
0.86842105 0.21052632 0.02631579 0.92105263 0.31578947 0.07894737
0.23684211 0.10526316 0.42105263 0.07894737 0.02631579 1.
0.05263158 0.13157895 0.02631579 0.18421053]
[0.263 0.289 0.105 0.105 0.237 0.237 0.026 0.053 0.395 1.000 1.000 1.000
0.026 0.421 0.026 0.026 0.316 0.816 0.026 0.921 0.026 0.342 0.026 0.105
0.026 0.132 0.053 0.026 0.158 0.026 0.868 0.211 0.026 0.921 0.316 0.079
0.237 0.105 0.421 0.079 0.026 1.000 0.053 0.132 0.026 0.184]
"""
return mask.sum(axis=0)/len(mask)
47 changes: 23 additions & 24 deletions src/biotite/structure/residues.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,9 @@ def apply_residue_wise(array, data, function, axis=None):
>>> print(len(sasa_per_residue))
20
>>> print(sasa_per_residue)
[157.97867 117.136475 94.98269 115.485115 113.58283
23.470863 93.0127 144.17316 61.561058 38.885334
0.79210365 114.05285 108.56837 27.887915 83.58345
113.01639 114.31787 74.28113 47.810623 172.03488 ]
[157.979 117.136 94.983 115.485 113.583 23.471 93.013 144.173 61.561
38.885 0.792 114.053 108.568 27.888 83.583 113.016 114.318 74.281
47.811 172.035]
Calculate the centroids of each residue for the same peptide.
Expand All @@ -135,26 +134,26 @@ def apply_residue_wise(array, data, function, axis=None):
>>> print(len(centroids))
20
>>> print(centroids)
[[-9.581938 3.3778126 -2.0728126 ]
[-4.6695266 5.815737 -1.8598946 ]
[-2.4608097 3.0596666 3.0760477 ]
[-7.2108426 -0.39636838 1.0131578 ]
[-4.6978235 -1.0804706 -4.284117 ]
[ 1.1721249 0.20641668 1.038375 ]
[-2.1600525 -2.2449472 3.5405266 ]
[-3.6823182 -5.5397725 -2.8952727 ]
[ 0.71108335 -5.4094167 -2.5495 ]
[ 2.0024288 -6.321715 1.6952857 ]
[ 2.7985713 -3.1399999 2.3274286 ]
[ 5.9007144 -2.4889286 4.844571 ]
[ 6.7537274 -6.7123637 3.0941818 ]
[ 5.6992726 -5.100636 -1.2091817 ]
[ 9.295427 -2.9695716 -1.8352858 ]
[ 5.517959 -1.5212501 -3.472667 ]
[ 7.218929 3.6732144 -0.6843571 ]
[ 4.006643 4.3640003 2.673857 ]
[ 0.34114286 5.575286 -0.25428572]
[ 1.194 10.416249 1.1301666 ]]
[[-9.582 3.378 -2.073]
[-4.670 5.816 -1.860]
[-2.461 3.060 3.076]
[-7.211 -0.396 1.013]
[-4.698 -1.080 -4.284]
[ 1.172 0.206 1.038]
[-2.160 -2.245 3.541]
[-3.682 -5.540 -2.895]
[ 0.711 -5.409 -2.549]
[ 2.002 -6.322 1.695]
[ 2.799 -3.140 2.327]
[ 5.901 -2.489 4.845]
[ 6.754 -6.712 3.094]
[ 5.699 -5.101 -1.209]
[ 9.295 -2.970 -1.835]
[ 5.518 -1.521 -3.473]
[ 7.219 3.673 -0.684]
[ 4.007 4.364 2.674]
[ 0.341 5.575 -0.254]
[ 1.194 10.416 1.130]]
"""
# The exclusive stop is appended to the residue starts
starts = np.append(get_residue_starts(array), [array.array_length()])
Expand Down

0 comments on commit 69f2d60

Please sign in to comment.