Example #1
0
def test__rebuild_map(test_data):
    """
    Test private _rebuild_map method.
    """

    for d in test_data:

        gpm = GenotypePhenotypeMap(wildtype=d["wildtype"],
                                   genotype=d["genotype"])

        # Trash all the stuff that _rebuild_map builds from scratch
        gpm._encoding_table = None
        gpm._data = gpm.data.drop(["binary"], axis=1)
        gpm._mutant = None
        gpm._data = gpm.data.drop(["n_mutations"], axis=1)
        gpm._data = gpm.data.drop(["name"], axis=1)

        gpm._rebuild_map()

        # Lazy check of encoding table. The encoding table is a pretty
        # complicated object.  See test_utils.test_get_encoding_table for test
        # of its creation.
        assert type(gpm._encoding_table) is pd.DataFrame
        assert np.array_equal(d["binary"], gpm.binary)
        assert gpm.mutant == d["mutant"]
        assert np.array_equal(d["n_mutations"], gpm.n_mutations)
        assert np.array_equal(d["name"], gpm.name)
Example #2
0
def test__add_mutant(test_data):
    """
    Test private _add_mutant method.
    """

    for d in test_data:

        gpm = GenotypePhenotypeMap(wildtype=d["wildtype"],
                                   genotype=d["genotype"])

        # Get rid of the mutant
        gpm._mutant = None

        gpm._add_mutant()

        assert np.array_equal(gpm.mutant, d["mutant"])