def validate(self, counts, model=None):

        missing = set(self.samples).difference(set(counts.table.columns))
        if len(missing) > 0:
            raise ValueError("following samples in design table are missing"
                             " from counts table: %s" % ", ".join(missing))

        if model is not None:

            model_terms = splitModel(model)

            # check all model terms exist
            missing = set(model_terms).difference(
                set(self.table.columns.tolist()))

            if len(missing) > 0:
                raise ValueError("following terms in the model are missing"
                                 " from the design table: %s" %
                                 ", ".join(missing))

            # check there are at least two values for each level
            for term in model_terms:
                levels = set(self.factors.ix[:, term])
                if len(levels) < 2:
                    raise ValueError("term '%s' in the model has less "
                                     "than two levels (%s) in the "
                                     " design table" %
                                     (term, ", ".join(levels)))
dataset/ETHPy150Open CGATOxford/cgat/CGAT/Expression.py/ExperimentalDesign.validate/original