Пример #1
0
 def test_plot_leafs(self, small_tree):
     tree = small_tree['tree']
     ss_props = list()
     for i in range(tree.nleafs):
         seq = ''.join(random.sample(1000*SSP.dssp_codes, 42))
         ss_props.append(SSP().from_dssp_sequence(seq))
     ps.propagator_size_weighted_sum(ss_props, tree)
     tree.root['ss'].plot('leafs')
Пример #2
0
 def test_instance_decorated_as_node_property(self):
     ss = 'GTEL'
     v = np.random.rand(len(ss), SSP.n_codes)
     v /= np.sum(v, axis=1)[:, np.newaxis]  # normalize rows
     profile_prop = SSP(name='foo', aa=ss, profile=v, errors=0.1*v)
     assert profile_prop.name == 'foo'
     assert np.array_equal(profile_prop.x, ss)
     assert np.array_equal(profile_prop.y, v)
     assert np.array_equal(profile_prop.e, 0.1*v)
Пример #3
0
 def test_propagator_size_weighted_sum(self, small_tree):
     r"""Create random secondary sequences by shufling all codes and
     assign to the leafs of the tree. Then, propagate the profiles up
     the tree hiearchy. Finally, compare the profile of the root with
     expected profile.
     """
     tree = small_tree['tree']
     ss_props = list()
     for i in range(tree.nleafs):
         seq = ''.join(random.sample(SSP.dssp_codes, SSP.n_codes))
         ss_props.append(SSP().from_dssp_sequence(seq))
     ps.propagator_size_weighted_sum(ss_props, tree)
     # Manually calculate the average profile for the last residue
     y = np.asarray([ss_props[i].y for i in range(tree.nleafs)])
     average_profile = np.mean(y, axis=0)
     np.testing.assert_array_almost_equal(average_profile,
                                          tree.root['ss'].y, decimal=12)
Пример #4
0
 def test_plot_node(self):
     profile = np.random.rand(42, SSP.n_codes)  # not normalized
     profile /= np.sum(profile, axis=1)[:, np.newaxis]  # normalized
     prop = SSP(profile=profile)
     prop.plot('node')
Пример #5
0
 def test_disparity(self):
     p = np.random.rand(42, SSP.n_codes)  # not normalized
     o = np.zeros((42, SSP.n_codes))
     pr = SSP(profile=p)
     assert pr.disparity(SSP(profile=-p)) == 4 * \
         pr.disparity(SSP(profile=o))
Пример #6
0
 def test_collapse(self):
     profile = np.random.rand(42, SSP.n_codes)  # not normalized
     prop = SSP(profile=profile)
     c = prop.collapsed
     assert c[0] == np.argmax(profile[0])
Пример #7
0
 def test_fractions(self):
     profile = np.random.rand(42, SSP.n_codes)  # not normalized
     prop = SSP(profile=profile)
     f = prop.fractions
     assert f['H'] == np.sum(profile, axis=0)[0] / 42
Пример #8
0
 def test_from_dssp_pdb(self, ss_benchmark):
     name = ss_benchmark['pdb_file']
     ss_prop = SSP().from_dssp_pdb(name)
     np.testing.assert_array_equal(ss_prop.y[-1], SSP.code2profile(' '))
Пример #9
0
 def test_from_dssp_sequence(self):
     seq = ''.join(random.sample(SSP.dssp_codes, SSP.n_codes))
     ss_prop = SSP().from_dssp_sequence(seq)
     np.testing.assert_array_equal(ss_prop.y[-1], SSP.code2profile(seq[-1]))
Пример #10
0
 def test_default_name(self):
     ss_prop = SSP()
     assert ss_prop.name == 'ss'