# Path: epistasis/matrix.py
# def get_model_matrix(binary_genotypes, sites, model_type='global'):
#     """Get a model matrix for a given set of genotypes and coefficients.
# 
#     Parameters
#     ----------
#     binary_genotypes : list or array
#         List of genotypes in their binary representation (see
#         gpmap.utils.genotypes_to_binary)
# 
#     sites : list
#         List of epistatic interaction sites.
# 
#     model_type : string
#         Type of epistasis model (global/Hadamard, local/Biochemical).
#     """
#     # Convert sites to array of arrays
#     sites = np.array([np.array(s) for s in sites],dtype=object)
#     
#     # Encode genotypes
#     encoded_vector = encode_vectors(binary_genotypes, model_type=model_type)
# 
#     # Build matrix.
#     X = build_model_matrix(encoded_vector, sites)
#     return X
# 
# Path: epistasis/models/utils.py
# class XMatrixException(Exception):
#     """Exception Subclass for X matrix errors."""


import numpy as np
from gpmap.gpm import GenotypePhenotypeMap
from gpmap import utils
from epistasis.mapping import (encoding_to_sites, assert_epistasis)
from .mapping import SimulatedEpistasisMap
from epistasis.matrix import get_model_matrix
from epistasis.utils import extract_mutations_from_genotypes
from epistasis.models.utils import XMatrixException
        elif type(X) == np.ndarray or type(X) == pd.DataFrame:
            # Set key
            if key is None:
                raise Exception("A key must be given to store.")

            # Store Xmatrix.
            self.Xbuilt[key] = X

        else:
            raise XMatrixException("X must be one of the following: 'obs',"
                                   " 'complete', "
                                   "numpy.ndarray, or pandas.DataFrame.")

        X_built = self.Xbuilt[key]
        return X_built

    def set_coefs_order(self, order):
        """Construct a set of epistatic coefficients given the epistatic
        order."""
        # Attach an epistasis model.
        self.order = order
        self.add_epistasis()
        self.epistasis.data.values = np.zeros(self.epistasis.n)
        self.epistasis.data.values[0] = 1
        return self

    def set_coefs_sites(self, sites):
        """Construct a set of epistatic coefficients given a list of
        coefficient sites."""
        self.order = max([len(s) for s in sites])

# Path: epistasis/matrix.py
# def get_model_matrix(binary_genotypes, sites, model_type='global'):
#     """Get a model matrix for a given set of genotypes and coefficients.
# 
#     Parameters
#     ----------
#     binary_genotypes : list or array
#         List of genotypes in their binary representation (see
#         gpmap.utils.genotypes_to_binary)
# 
#     sites : list
#         List of epistatic interaction sites.
# 
#     model_type : string
#         Type of epistasis model (global/Hadamard, local/Biochemical).
#     """
#     # Convert sites to array of arrays
#     sites = np.array([np.array(s) for s in sites],dtype=object)
#     
#     # Encode genotypes
#     encoded_vector = encode_vectors(binary_genotypes, model_type=model_type)
# 
#     # Build matrix.
#     X = build_model_matrix(encoded_vector, sites)
#     return X
# 
# Path: epistasis/models/utils.py
# class XMatrixException(Exception):
#     """Exception Subclass for X matrix errors."""


# Path: epistasis/simulate/base.py
import numpy as np
from gpmap.gpm import GenotypePhenotypeMap
from gpmap import utils
from epistasis.mapping import (encoding_to_sites, assert_epistasis)
from .mapping import SimulatedEpistasisMap
from epistasis.matrix import get_model_matrix
from epistasis.utils import extract_mutations_from_genotypes
from epistasis.models.utils import XMatrixException

        elif type(X) == np.ndarray or type(X) == pd.DataFrame:
            # Set key
            if key is None:
                raise Exception("A key must be given to store.")

            # Store Xmatrix.
            self.Xbuilt[key] = X

        else:
            raise XMatrixException("X must be one of the following: 'obs',"
                                   " 'complete', "
                                   "numpy.ndarray, or pandas.DataFrame.")

        X_built = self.Xbuilt[key]
        return X_built

    def set_coefs_order(self, order):
        """Construct a set of epistatic coefficients given the epistatic
        order."""
        # Attach an epistasis model.
        self.order = order
        self.add_epistasis()
        self.epistasis.data.values = np.zeros(self.epistasis.n)
        self.epistasis.data.values[0] = 1
        return self

    def set_coefs_sites(self, sites):
        """Construct a set of epistatic coefficients given a list of
        coefficient sites."""
        self.order = max([len(s) for s in sites])

        self.add_epistasis()