# Path: pydigree/common.py
# def count(val, iterable):
# def table(seq):
# def mode(seq):
# def random_choice(iterable):
# def flatten(x):
# def grouper(iterable, n, fillvalue=None):
# def invert_dict(d):
# def merge_dicts(*args):
# def log_base_change(value, old, new):
# def product(iter):
# def cumsum(iter):
# 
# Path: pydigree/genotypes/genoabc.py
# class AlleleContainer(object):
#     " A base class for the interface allele containers object must implement"
# 
#     def empty_like(self):
#         raise NotImplementedError
# 
#     def copy_span(self, template, start, stop):
#         raise NotImplementedError
# 
#     def dtype(self):
#         raise NotImplementedError
# 
#     def __eq__(self, other):
#         raise NotImplementedError
# 
#     def __lt__(self, other):
#         raise NotMeaningfulError(
#             'Value comparisions not meaningful for genotypes')
# 
#     def __gt__(self, other):
#         raise NotMeaningfulError(
#             'Value comparisions not meaningful for genotypes')
# 
#     def __le__(self, other):
#         raise NotMeaningfulError(
#             'Value comparisions not meaningful for genotypes')
# 
#     def __ge__(self, other):
#         raise NotMeaningfulError(
#             'Value comparisions not meaningful for genotypes')
# 
#     def __delitem__(self, key):
#         raise NotMeaningfulError('Allele arrays are fixed size')


from pydigree.common import all_same_type
from .genoabc import AlleleContainer
        for span in self.spans:
            if span.contains(index):
                return span.ancestral_allele
        raise ValueError('Index out of bounds: {}'.format(index))

    def empty_like(self):
        return LabelledAlleles([], chromobj=self.chromobj, nmark=self.nmark)

    @property
    def dtype(self):
        return type(self)

    @staticmethod
    def founder_chromosome(ind, chromidx, hap, chromobj=None, nmark=None):
        n = nmark if not chromobj else chromobj.nmark()
        spans = [InheritanceSpan(ind, chromidx, hap, 0, n)]
        return LabelledAlleles(spans=spans, chromobj=chromobj, nmark=nmark)

    def add_span(self, new_span):
        if any(new_span.stop < x.stop for x in self.spans):
            raise ValueError('Overwriting not supported for LabelledAlleles')
        if len(self.spans) == 0 and new_span.start > 0:
            raise ValueError('Spans not contiguous')
        if len(self.spans) > 0 and (not new_span.start == self.spans[-1].stop):
            raise ValueError('Spans not contiguous')
        self.spans.append(new_span)

    def copy_span(self, template, copy_start, copy_stop):
        if not isinstance(template, LabelledAlleles):
            raise ValueError(

# Path: pydigree/common.py
# def count(val, iterable):
# def table(seq):
# def mode(seq):
# def random_choice(iterable):
# def flatten(x):
# def grouper(iterable, n, fillvalue=None):
# def invert_dict(d):
# def merge_dicts(*args):
# def log_base_change(value, old, new):
# def product(iter):
# def cumsum(iter):
# 
# Path: pydigree/genotypes/genoabc.py
# class AlleleContainer(object):
#     " A base class for the interface allele containers object must implement"
# 
#     def empty_like(self):
#         raise NotImplementedError
# 
#     def copy_span(self, template, start, stop):
#         raise NotImplementedError
# 
#     def dtype(self):
#         raise NotImplementedError
# 
#     def __eq__(self, other):
#         raise NotImplementedError
# 
#     def __lt__(self, other):
#         raise NotMeaningfulError(
#             'Value comparisions not meaningful for genotypes')
# 
#     def __gt__(self, other):
#         raise NotMeaningfulError(
#             'Value comparisions not meaningful for genotypes')
# 
#     def __le__(self, other):
#         raise NotMeaningfulError(
#             'Value comparisions not meaningful for genotypes')
# 
#     def __ge__(self, other):
#         raise NotMeaningfulError(
#             'Value comparisions not meaningful for genotypes')
# 
#     def __delitem__(self, key):
#         raise NotMeaningfulError('Allele arrays are fixed size')


# Path: pydigree/genotypes/labelledalleles.py
from pydigree.common import all_same_type
from .genoabc import AlleleContainer

        for span in self.spans:
            if span.contains(index):
                return span.ancestral_allele
        raise ValueError('Index out of bounds: {}'.format(index))

    def empty_like(self):
        return LabelledAlleles([], chromobj=self.chromobj, nmark=self.nmark)

    @property
    def dtype(self):
        return type(self)

    @staticmethod
    def founder_chromosome(ind, chromidx, hap, chromobj=None, nmark=None):
        n = nmark if not chromobj else chromobj.nmark()
        spans = [InheritanceSpan(ind, chromidx, hap, 0, n)]
        return LabelledAlleles(spans=spans, chromobj=chromobj, nmark=nmark)

    def add_span(self, new_span):
        if any(new_span.stop < x.stop for x in self.spans):
            raise ValueError('Overwriting not supported for LabelledAlleles')
        if len(self.spans) == 0 and new_span.start > 0:
            raise ValueError('Spans not contiguous')
        if len(self.spans) > 0 and (not new_span.start == self.spans[-1].stop):
            raise ValueError('Spans not contiguous')
        self.spans.append(new_span)

    def copy_span(self, template, copy_start, copy_stop):
        if not isinstance(template, LabelledAlleles):
            raise ValueError(

                'LabelledAlleles can only copy from other LabelledAlleles')