Ejemplo n.º 1
0
    def tfunc_areabetween(self,
                          func_name: str,
                          f1: callable,
                          f2: callable,
                          are_intersects: bool = True,
                          maxerr: float = 0.001,
                          draw=False):
        if (draw):
            p_x = np.arange(0, 100)
            p_y = f1(p_x) - f2(p_x)
            plt.plot(p_x, p_y)
            plt.show()

        ass3 = Assignment3()
        r = ass3.areabetween(f1, f2)

        intersections = assignment2.Assignment2().intersections(f1, f2, 1, 100)
        if ((not are_intersects)):
            self.assertTrue(np.isnan(r))
        if (len(intersections) < 2):
            self.assertTrue(np.isnan(r))
        else:
            expect_area = 0
            for i in range(0, len(intersections) - 1):
                expect_area = expect_area + abs(
                    integrate.quad(lambda x: f1(x) - f2(x), intersections[i],
                                   intersections[i + 1])[0])
            # print(f"{expect_aera} {r}")
            self.assertEqual(r.dtype, np.float32)
            self.assertGreaterEqual(
                maxerr, abs((r - expect_area) / expect_area),
                f"\n{func_name}\n\t relative: {abs((r - expect_area) / expect_area)}\n\t actual {r}\n\t expect {expect_area}"
            )
Ejemplo n.º 2
0
    def tfunc_integrate(self,
                        func_name: str,
                        f1: callable,
                        s: float,
                        to: float,
                        n: int,
                        maxerr: float = 0.001,
                        draw=False):
        if (draw):
            p_x = np.arange(s * 1.1, to * 1.1, 0.1)
            p_y = f1(p_x)
            plt.plot(p_x, p_y)
            plt.show()

        expect_area = integrate.quad(lambda x: f1(x), s, to)
        f1 = RESTRICT_INVOCATIONS(n)(f1)
        ass3 = Assignment3()
        r = ass3.integrate(f1, s, to, n)
        # print(integrate.simps(f1(points), points))
        # print(f"{expect_aera} {r}")
        self.assertEqual(r.dtype, np.float32)
        self.assertGreaterEqual(maxerr,
                                abs((r - expect_area[0]) / expect_area[0]),
                                f"{func_name}, {r}, {expect_area}")
def test_get_list_of_genes():
    a3 = Assignment3()
    assert os.path.exists(
        "annotation_result.json"), "The annotation JSON file does not exist"
    assert a3.get_list_of_genes() == 21 or len(a3.get_list_of_genes()) == 21
def test_get_number_of_annotated_variants():
    a3 = Assignment3()
    assert a3.get_number_of_annotated_variants() == 900
def test_view_vcf_in_browser():
    a3 = Assignment3()
    assert os.path.exists(
        "annotation_result.json"), "The annotation JSON file does not exist"
    assert "vcf.iobio.io" in a3.view_vcf_in_browser()
def test_get_num_variants_with_mutationtaster_annotation():
    a3 = Assignment3()
    assert os.path.exists(
        "annotation_result.json"), "The annotation JSON file does not exist"
    assert a3.get_num_variants_with_mutationtaster_annotation() == 5
def test_get_num_variants_modifier():
    a3 = Assignment3()
    assert os.path.exists(
        "annotation_result.json"), "The annotation JSON file does not exist"
    assert a3.get_num_variants_modifier() == 67
Ejemplo n.º 8
0
    def test_integrate_float32(self):
        ass3 = Assignment3()
        f1 = np.poly1d([-1, 0, 1])
        r = ass3.integrate(f1, -1, 1, 10)

        self.assertEqual(r.dtype, np.float32)