Beispiel #1
0
    def test_remove_pathway(self):
        source = os.path.join(os.path.dirname(__file__), "testfiles")
        gene_set = fetch_reactome_geneset(source=source, species="H**o sapiens")

        org_count = len(gene_set.gene_sets)
        gene_set.remove_pathways(["R-HSA-2029481"])
        self.assertEqual(org_count - 1, len(gene_set.gene_sets))
Beispiel #2
0
    def test_build_from_url(self):
        source = "https://reactome.org/download/current"

        gene_set = fetch_reactome_geneset(source=source, species="H**o sapiens")

        self.assertTrue("R-HSA-1980143" in gene_set.gene_sets)
        self.assertEqual(150, len(gene_set.gene_sets["R-HSA-1980143"]))
Beispiel #3
0
    def test_add_gene_set_interactors(self):
        source = os.path.join(os.path.dirname(__file__), "testfiles")
        gene_set = fetch_reactome_geneset(source=source, species="H**o sapiens")
        filename = os.path.join(os.path.dirname(__file__), "testfiles", "IntAct_Static_100.txt")
        interactors = load_reactome_interactors(filename)

        org_gene_set = gene_set.copy()
        gene_set.add_interactors(interactors)

        # no change detectable with test files
        self.assertEqual(len(gene_set.gene_sets["R-HSA-2029481"]), len(org_gene_set.gene_sets["R-HSA-2029481"]))
Beispiel #4
0
    def test_build_from_file(self):
        source = os.path.join(os.path.dirname(__file__), "testfiles")

        gene_set = fetch_reactome_geneset(source=source, species="H**o sapiens")

        self.assertTrue("R-HSA-2029481" in gene_set.gene_sets)
        self.assertEqual(4, len(gene_set.gene_sets["R-HSA-2029481"]))

        # make sure there is a name for every pathway
        for gene_set_id in gene_set.gene_sets:
            self.assertIsNotNone(gene_set.gene_set_names[gene_set_id])
    def _get_gene_set(self):
        # load the gene set
        gene_set_file = os.path.join(gettempdir(), "test_gene_set.pkl")

        if os.path.isfile(gene_set_file):
            gene_set = geneset_builder.GeneSet.create_from_file(gene_set_file)
        else:
            gene_set = geneset_builder.fetch_reactome_geneset(source="https://reactome.org/download/current/",
                                                              species="H**o sapiens")
            gene_set.save(gene_set_file)

        return gene_set
Beispiel #6
0
    def test_load_save(self):
        source = os.path.join(os.path.dirname(__file__), "testfiles")
        gene_set = fetch_reactome_geneset(source=source, species="H**o sapiens")

        filename = os.path.join(gettempdir(), "reactome_human.pikl")

        if os.path.isfile(filename):
            os.unlink(filename)

        gene_set.save(filename)

        loaded_set = GeneSet.create_from_file(filename)

        self.assertEqual(len(gene_set.gene_sets), len(loaded_set.gene_sets))
        self.assertEqual(len(gene_set.gene_set_names), len(loaded_set.gene_set_names))