Beispiel #1
0
    def test_has(self):
        """querying whether a value has been set."""

        rr = Representation(dict(xyz=0.2))
        rr.set("bob", 0.4)
        self.assertTrue(rr.has("xyz"), "set in constructor")
        self.assertTrue(rr.has("bob"), "set manually")
        self.assertFalse(rr.has("alice"), "not set")
Beispiel #2
0
def make_target_reference(reference, oomap, oo_median=None):
    """convert a single representation from one ontology to another."""

    result = Representation(name=reference.name)
    result.title = reference.title

    for phenotype, value in reference.data.items():
        for oo_phenotype, oo_score in oomap[phenotype]:
            # perhaps compute a rescaled oo value
            newvalue = value
            if oo_median is not None:
                newvalue = value * tanh(oo_score / oo_median)
            # always take the larger value if previously set
            if result.has(oo_phenotype):
                newvalue = max(newvalue, result.get(oo_phenotype))
            result.set(oo_phenotype, newvalue)

    return result