Did I find the right examples for you? yes no

# cogent.struct.rna2d.Pairs

All Samples(534)  |  Call(498)  |  Derive(0)  |  Import(36)

```from random import choice
from numpy import sum, average, zeros
from cogent.struct.rna2d import Pairs
from cogent.util.dict2d import Dict2D

```
```        self.Length = Length
self.Id = Id
self.Pairs = Pairs()
for i in range(self.Length):
self.Pairs.append((self.Start+i, self.End-i))
```
```        raise ValueError("PairedRegion should contain at least one pair")
# preprocess
raw_pairs = Pairs(pairs)
if raw_pairs.hasConflicts():
raise ValueError("Cannot handle pairs with conflicts")
```
```            in the result. The resulting Pairs object is sorted.
"""
result = Pairs()
for pr in self:
result.extend(pr.Pairs)
```
```        ID 1, etc.
"""
p = Pairs(pairs)
if not p:
return PairedRegions()
```

```from random import choice
from numpy import sum, average, zeros
from cogent.struct.rna2d import Pairs
from cogent.util.dict2d import Dict2D

```
```        self.Length = Length
self.Id = Id
self.Pairs = Pairs()
for i in range(self.Length):
self.Pairs.append((self.Start+i, self.End-i))
```
```        raise ValueError("PairedRegion should contain at least one pair")
# preprocess
raw_pairs = Pairs(pairs)
if raw_pairs.hasConflicts():
raise ValueError("Cannot handle pairs with conflicts")
```
```            in the result. The resulting Pairs object is sorted.
"""
result = Pairs()
for pr in self:
result.extend(pr.Pairs)
```
```        ID 1, etc.
"""
p = Pairs(pairs)
if not p:
return PairedRegions()
```

```from string import strip
from numpy import array, sqrt, searchsorted, flatnonzero, take, sum
from cogent.struct.rna2d import Pairs
from cogent.parse.fasta import MinimalFastaParser

```
```    if not isinstance(offset, int):
result = Pairs()
for x, y in pairs:
if x is not None:
```
```        want to degap it, use a mapping from gapped to ungapped.
"""
result = Pairs()
for x,y in pairs:
if x is None:
```
```    """
if not gap_list:
result = Pairs()
result.extend(pairs)
return result

g = array(gap_list)
result = Pairs()
```

```from string import strip
from numpy import array, sqrt, searchsorted, flatnonzero, take, sum
from cogent.struct.rna2d import Pairs
from cogent.parse.fasta import MinimalFastaParser

```
```    if not isinstance(offset, int):
result = Pairs()
for x, y in pairs:
if x is not None:
```
```        want to degap it, use a mapping from gapped to ungapped.
"""
result = Pairs()
for x,y in pairs:
if x is None:
```
```    """
if not gap_list:
result = Pairs()
result.extend(pairs)
return result

g = array(gap_list)
result = Pairs()
```

```"""
from cogent.util.transform import make_trans
from cogent.struct.rna2d   import Pairs
from cogent.struct.knots   import opt_single_random
from string                import index
```
```                key = tuple(block[-1])

winner = Pairs(key)
indx = tmp_list.index(winner)-1
result.append([tmp_list[indx],winner]) #adds the most common structure first
del frequency[key]
for i in frequency.keys(): #rest of structures added
i = Pairs(i)
```
```            pairs.extend(zip(oL,cL.__reversed__()))

yield Pairs(pairs),Fseq

```

```"""
from cogent.util.transform import make_trans
from cogent.struct.rna2d   import Pairs
from cogent.struct.knots   import opt_single_random
from string                import index
```
```                key = tuple(block[-1])

winner = Pairs(key)
indx = tmp_list.index(winner)-1
result.append([tmp_list[indx],winner]) #adds the most common structure first
del frequency[key]
for i in frequency.keys(): #rest of structures added
i = Pairs(i)
```
```            pairs.extend(zip(oL,cL.__reversed__()))

yield Pairs(pairs),Fseq

```

```#!/usr/bin/env python

from string                import strip,split,atof
from cogent.util.transform import make_trans
from cogent.struct.rna2d   import Pairs,ViennaStructure
```
```    for line in lines:
if line.startswith('Error'):#Error no structure found
result = [Pairs([])] #return empty pairs list
return result
if line.startswith('Sequence and a Minimum Energy Structure'):
```

```#!/usr/bin/env python

from string                import strip,split,atof
from cogent.util.transform import make_trans
from cogent.struct.rna2d   import Pairs,ViennaStructure
```
```    for line in lines:
if line.startswith('Error'):#Error no structure found
result = [Pairs([])] #return empty pairs list
return result
if line.startswith('Sequence and a Minimum Energy Structure'):
```

```from __future__ import division
from string import strip
from cogent.struct.rna2d import Vienna, Pairs
from cogent.struct.knots import opt_single_random
from cogent.core.info import Info
```
```    #create dictionary/list for sequence and structure
seq_dict = {}
pairs = Pairs()

for line in residue_lines:
```

```#!/usr/bin/env python