37
37
from numpy.random import randint, permutation
39
39
from cogent.util.dict2d import Dict2D
41
LOG = logging.getLogger('cogent.data')
43
41
from copy import copy
44
42
from cogent.core.profile import Profile
49
47
"Jeremy Widmann", "Catherine Lozupone", "Matthew Wakefield",
50
48
"Micah Hamady", "Daniel McDonald"]
51
49
__license__ = "GPL"
53
51
__maintainer__ = "Rob Knight"
54
52
__email__ = "rob@spot.colorado.edu"
55
53
__status__ = "Production"
1679
1677
sample = Map(positions, parent_length=len(self))
1680
1678
return self.gappedByMap(sample, Info=self.Info)
1682
def slidingWindows(self, window, step):
1680
def slidingWindows(self, window, step, start=None, end=None):
1683
1681
"""Generator yielding new Alignments of given length and interval.
1686
1684
- window: The length of each returned alignment.
1687
1685
- step: The interval between the start of the successive
1688
1686
alignment objects returned.
1687
- start: first window start position
1688
- end: last window start position
1690
for pos in range(0, len(self)-window+1,step):
1691
yield self[pos:pos+window]
1690
start = [start, 0][start is None]
1691
end = [end, len(self)-window+1][end is None]
1692
end = min(len(self)-window+1, end)
1693
if start < end and len(self)-end >= window-1:
1694
for pos in xrange(start, end, step):
1695
yield self[pos:pos+window]
1693
1699
def aln_from_array(a, array_type=None, Alphabet=None):
1694
1700
"""Alignment from array of pos x seq: no change, names are integers.