Did I find the right examples for you? yes no

# cogent.struct.knots.hydrogen_bonds

All Samples(12)  |  Call(10)  |  Derive(0)  |  Import(2)

```from cogent.util.dict2d import Dict2D
from cogent.struct.rna2d import Pairs
from cogent.struct.knots import PairedRegion, PairedRegionFromPairs,\
PairedRegions, PairedRegionsFromPairs, ConflictMatrix,\
opt_all, contains_true, empty_matrix,\
```
```    def test_hydrogen_bonds(self):
"""hydrogen_bonds: score GC, AU, and GU base pairs"""
f = hydrogen_bonds('UACGAAAUGCGUG')
pr1 = PairedRegion(0,12,5)
self.assertEqual(f(pr1),10)

f = hydrogen_bonds('UACGAAA') # sequence too short
```
```        obs_bps = opt_all(p, goal='max', scoring_function=num_bps)
obs_energy = opt_all(p, goal='max',\
scoring_function=hydrogen_bonds('CCCAAAUGGGGUCGUUC'))
exp_bps = [[(4,15),(5,14),(6,13)]]
exp_energy = [[(1,10),(2,9)],[(4,15),(5,14),(6,13)]]
```
```        obs_bps = opt_all(p, goal='max', scoring_function=num_bps)
obs_energy = opt_all(p, goal='max',\
scoring_function=hydrogen_bonds('CCCAAAAGGGUUUU'))
exp_bps = [[(0,9),(1,8),(2,7)],[(3,13),(4,12),(5,11)]]
exp_energy = [[(0,9),(1,8),(2,7)]]
```

```from cogent.util.dict2d import Dict2D
from cogent.struct.rna2d import Pairs
from cogent.struct.knots import PairedRegion, PairedRegionFromPairs,\
PairedRegions, PairedRegionsFromPairs, ConflictMatrix,\
opt_all, contains_true, empty_matrix,\
```
```    def test_hydrogen_bonds(self):
"""hydrogen_bonds: score GC, AU, and GU base pairs"""
f = hydrogen_bonds('UACGAAAUGCGUG')
pr1 = PairedRegion(0,12,5)
self.assertEqual(f(pr1),10)

f = hydrogen_bonds('UACGAAA') # sequence too short
```
```        obs_bps = opt_all(p, goal='max', scoring_function=num_bps)
obs_energy = opt_all(p, goal='max',\
scoring_function=hydrogen_bonds('CCCAAAUGGGGUCGUUC'))
exp_bps = [[(4,15),(5,14),(6,13)]]
exp_energy = [[(1,10),(2,9)],[(4,15),(5,14),(6,13)]]
```
```        obs_bps = opt_all(p, goal='max', scoring_function=num_bps)
obs_energy = opt_all(p, goal='max',\
scoring_function=hydrogen_bonds('CCCAAAAGGGUUUU'))
exp_bps = [[(0,9),(1,8),(2,7)],[(3,13),(4,12),(5,11)]]
exp_energy = [[(0,9),(1,8),(2,7)]]
```