Ejemplo n.º 1
0
    def setUp(self):
        self.engine = sqlalchemy.create_engine(ENGINE_STRING, echo=False)
        test_db_utils.create_empty_test_db()

        phage_data1 = test_data_utils.get_trixie_phage_data()
        phage_data1["PhageID"] = "Trixie"
        phage_data1["HostGenus"] = "Mycobacterium"
        phage_data1["Accession"] = "ABC123"
        phage_data1["Cluster"] = "A"
        phage_data1["Subcluster"] = "A1"
        phage_data1["Sequence"] = "atcg"
        phage_data1["Length"] = 6
        phage_data1["DateLastModified"] = constants.EMPTY_DATE
        test_db_utils.insert_data(PHAGE, phage_data1)

        gene_data1 = test_data_utils.get_trixie_gene_data()
        gene_data2 = test_data_utils.get_trixie_gene_data()

        gene_data1["PhageID"] = "Trixie"
        gene_data2["PhageID"] = "Trixie"

        gene_data1["GeneID"] = "Trixie_1"
        gene_data2["GeneID"] = "Trixie_2"

        test_db_utils.insert_data(GENE, gene_data1)
        test_db_utils.insert_data(GENE, gene_data2)
Ejemplo n.º 2
0
    def setUp(self):
        self.engine = sqlalchemy.create_engine(engine_string1, echo=False)
        test_db_utils.create_empty_test_db()

        phage_data1 = test_data_utils.get_trixie_phage_data()
        phage_data1["PhageID"] = "Trixie"
        phage_data1["HostGenus"] = "Mycobacterium"
        phage_data1["Accession"] = "ABC123"
        phage_data1["Cluster"] = "A"
        phage_data1["Subcluster"] = "A1"
        phage_data1["Sequence"] = "atcg"
        phage_data1["Length"] = 6
        phage_data1["DateLastModified"] = constants.EMPTY_DATE
        test_db_utils.insert_phage_data(phage_data1)

        gene_data1 = test_data_utils.get_trixie_gene_data()
        gene_data2 = test_data_utils.get_trixie_gene_data()

        gene_data1["PhageID"] = "Trixie"
        gene_data2["PhageID"] = "Trixie"

        gene_data1["GeneID"] = "Trixie_1"
        gene_data2["GeneID"] = "Trixie_2"

        test_db_utils.insert_gene_data(gene_data1)
        test_db_utils.insert_gene_data(gene_data2)

        self.phage_query = "SELECT * FROM phage where PhageID = 'Trixie'"
        self.gene_query = "SELECT * FROM gene where PhageID = 'Trixie'"
Ejemplo n.º 3
0
    def setUp(self):
        test_db_utils.create_empty_test_db()
        test_db_utils.insert_phage_data(
            test_data_utils.get_trixie_phage_data())
        test_db_utils.insert_gene_data(test_data_utils.get_trixie_gene_data())

        self.engine = sqlalchemy.create_engine(engine_string, echo=False)
        self.connection = self.engine.connect()
Ejemplo n.º 4
0
    def test_create_update_4(self):
        """Verify Gene table statement is created correctly."""
        # First add gene Trixie_1 to the database.
        gene_data = test_data_utils.get_trixie_gene_data()
        gene_data["PhageID"] = "Trixie"
        gene_data["Notes"] = "none"
        gene_data["GeneID"] = "Trixie_1"
        test_db_utils.insert_gene_data(gene_data)

        # Second run the update statement.
        statement = mysqldb.create_update("gene", "Notes", "Repressor",
                                          "GeneID", "Trixie_1")
        test_db_utils.execute(statement)
        result = test_db_utils.get_data(self.gene_query)
        results = result[0]
        exp = "UPDATE gene SET Notes = 'Repressor' WHERE GeneID = 'Trixie_1';"
        with self.subTest():
            self.assertEqual(statement, exp)
        with self.subTest():
            self.assertEqual(results["Notes"].decode("utf-8"), "Repressor")
Ejemplo n.º 5
0
    def setUpClass(self):
        test_db_utils.create_empty_test_db(db=DB2) 
        test_db_utils.create_empty_test_db()
        

        phage_data1 = test_data_utils.get_trixie_phage_data()
        phage_data2 = test_data_utils.get_trixie_phage_data()
        phage_data3 = test_data_utils.get_trixie_phage_data()

        phage_data1["PhageID"] = "L5"
        phage_data2["PhageID"] = "Trixie"
        phage_data3["PhageID"] = "D29"

        phage_data1["HostGenus"] = "Mycobacterium"
        phage_data2["HostGenus"] = "Mycobacterium"
        phage_data3["HostGenus"] = "Gordonia"

        phage_data1["Accession"] = "ABC123"
        phage_data2["Accession"] = "XYZ456"
        phage_data3["Accession"] = ""

        phage_data1["Cluster"] = "A"
        phage_data2["Cluster"] = "B"
        phage_data3["Cluster"] = "NULL"

        phage_data1["Subcluster"] = "A1"
        phage_data2["Subcluster"] = "NULL"
        phage_data3["Subcluster"] = "NULL"

        phage_data1["Sequence"] = "atcg"
        phage_data2["Sequence"] = "AATT"
        phage_data3["Sequence"] = "GGCC"

        phage_data1["Length"] = 6
        phage_data2["Length"] = 4
        phage_data3["Length"] = 5

        phage_data1["DateLastModified"] = constants.EMPTY_DATE
        phage_data2["DateLastModified"] = constants.EMPTY_DATE
        phage_data3["DateLastModified"] = constants.EMPTY_DATE

        phage_data_list = [phage_data1, phage_data2, phage_data3]
        for phage_data in phage_data_list:
            test_db_utils.insert_data(PHAGE, phage_data)

        gene_data1 = test_data_utils.get_trixie_gene_data()
        gene_data2 = test_data_utils.get_trixie_gene_data()
        gene_data3 = test_data_utils.get_trixie_gene_data()
        gene_data4 = test_data_utils.get_trixie_gene_data()

        gene_data1["PhageID"] = "Trixie"
        gene_data2["PhageID"] = "Trixie"
        gene_data3["PhageID"] = "Trixie"
        gene_data4["PhageID"] = "D29"

        gene_data1["GeneID"] = "Trixie_1"
        gene_data2["GeneID"] = "Trixie_2"
        gene_data3["GeneID"] = "Trixie_3"
        gene_data4["GeneID"] = "D29_1"

        gene_data_list = [gene_data1, gene_data2, gene_data3, gene_data4]
        for gene_data in gene_data_list:
            test_db_utils.insert_data(GENE, gene_data)
Ejemplo n.º 6
0
    def setUp(self):
        self.engine = sqlalchemy.create_engine(engine_string1, echo=False)
        test_db_utils.create_empty_test_db()
        phage_data1 = test_data_utils.get_trixie_phage_data()
        phage_data2 = test_data_utils.get_trixie_phage_data()
        phage_data3 = test_data_utils.get_trixie_phage_data()

        phage_data1["PhageID"] = "L5"
        phage_data2["PhageID"] = "Trixie"
        phage_data3["PhageID"] = "D29"

        phage_data1["HostGenus"] = "Mycobacterium"
        phage_data2["HostGenus"] = "Mycobacterium"
        phage_data3["HostGenus"] = "Gordonia"

        phage_data1["Accession"] = "ABC123"
        phage_data2["Accession"] = "XYZ456"
        phage_data3["Accession"] = ""

        phage_data1["Cluster"] = "A"
        phage_data2["Cluster"] = "B"
        phage_data3["Cluster"] = "NULL"

        phage_data1["Subcluster"] = "A1"
        phage_data2["Subcluster"] = "NULL"
        phage_data3["Subcluster"] = "NULL"

        phage_data1["Sequence"] = "atcg"
        phage_data2["Sequence"] = "AATT"
        phage_data3["Sequence"] = "GGCC"

        phage_data1["Length"] = 6
        phage_data2["Length"] = 4
        phage_data3["Length"] = 5

        phage_data1["DateLastModified"] = constants.EMPTY_DATE
        phage_data2["DateLastModified"] = constants.EMPTY_DATE
        phage_data3["DateLastModified"] = constants.EMPTY_DATE

        phage_data_list = [phage_data1, phage_data2, phage_data3]
        for phage_data in phage_data_list:
            test_db_utils.insert_phage_data(phage_data)

        gene_data1 = test_data_utils.get_trixie_gene_data()
        gene_data2 = test_data_utils.get_trixie_gene_data()
        gene_data3 = test_data_utils.get_trixie_gene_data()
        gene_data4 = test_data_utils.get_trixie_gene_data()

        gene_data1["PhageID"] = "Trixie"
        gene_data2["PhageID"] = "Trixie"
        gene_data3["PhageID"] = "Trixie"
        gene_data4["PhageID"] = "D29"

        gene_data1["GeneID"] = "Trixie_1"
        gene_data2["GeneID"] = "Trixie_2"
        gene_data3["GeneID"] = "Trixie_3"
        gene_data4["GeneID"] = "D29_1"

        gene_data_list = [gene_data1, gene_data2, gene_data3, gene_data4]
        for gene_data in gene_data_list:
            test_db_utils.insert_gene_data(gene_data)

        self.phage_query = "SELECT * FROM phage"
        self.gene_query = "SELECT * FROM gene"
Ejemplo n.º 7
0
    def setUp(self):
        test_db_utils.create_empty_test_db(db=DB2)
        self.alchemist2 = AlchemyHandler(database=DB2,
                                         username=USER,
                                         password=PWD)
        self.alchemist2.build_engine()
        self.engine2 = self.alchemist2.engine

        test_db_utils.create_empty_test_db()
        self.alchemist1 = AlchemyHandler(database=DB,
                                         username=USER,
                                         password=PWD)
        self.alchemist1.build_engine()
        self.engine1 = self.alchemist1.engine

        phage_data1 = test_data_utils.get_trixie_phage_data()
        phage_data2 = test_data_utils.get_trixie_phage_data()
        phage_data3 = test_data_utils.get_trixie_phage_data()

        phage_data1["PhageID"] = "L5"
        phage_data2["PhageID"] = "Trixie"
        phage_data3["PhageID"] = "D29"

        phage_data1["HostGenus"] = "Mycobacterium"
        phage_data2["HostGenus"] = "Mycobacterium"
        phage_data3["HostGenus"] = "Gordonia"

        phage_data1["Accession"] = "ABC123"
        phage_data2["Accession"] = "XYZ456"
        phage_data3["Accession"] = ""

        phage_data1["Cluster"] = "A"
        phage_data2["Cluster"] = "B"
        phage_data3["Cluster"] = "NULL"

        phage_data1["Subcluster"] = "A1"
        phage_data2["Subcluster"] = "NULL"
        phage_data3["Subcluster"] = "NULL"

        phage_data1["Sequence"] = "atcg"
        phage_data2["Sequence"] = "AATT"
        phage_data3["Sequence"] = "GGCC"

        phage_data1["Length"] = 6
        phage_data2["Length"] = 4
        phage_data3["Length"] = 5

        phage_data1["DateLastModified"] = constants.EMPTY_DATE
        phage_data2["DateLastModified"] = constants.EMPTY_DATE
        phage_data3["DateLastModified"] = constants.EMPTY_DATE

        phage_data_list = [phage_data1, phage_data2, phage_data3]
        for phage_data in phage_data_list:
            test_db_utils.insert_data(PHAGE, phage_data)

        gene_data1 = test_data_utils.get_trixie_gene_data()
        gene_data2 = test_data_utils.get_trixie_gene_data()
        gene_data3 = test_data_utils.get_trixie_gene_data()
        gene_data4 = test_data_utils.get_trixie_gene_data()

        gene_data1["PhageID"] = "Trixie"
        gene_data2["PhageID"] = "Trixie"
        gene_data3["PhageID"] = "Trixie"
        gene_data4["PhageID"] = "D29"

        gene_data1["GeneID"] = "Trixie_1"
        gene_data2["GeneID"] = "Trixie_2"
        gene_data3["GeneID"] = "Trixie_3"
        gene_data4["GeneID"] = "D29_1"

        gene_data_list = [gene_data1, gene_data2, gene_data3, gene_data4]
        for gene_data in gene_data_list:
            test_db_utils.insert_data(GENE, gene_data)
Ejemplo n.º 8
0
    def setUp(self):
        self.engine = sqlalchemy.create_engine(ENGINE_STRING, echo=False)
        test_db_utils.create_empty_test_db()
        phage_data1 = test_data_utils.get_trixie_phage_data()
        phage_data2 = test_data_utils.get_trixie_phage_data()
        phage_data3 = test_data_utils.get_trixie_phage_data()

        phage_data1["PhageID"] = "L5"
        phage_data2["PhageID"] = "Trixie"
        phage_data3["PhageID"] = "D29"

        phage_data1["HostGenus"] = "Mycobacterium"
        phage_data2["HostGenus"] = "Mycobacterium"
        phage_data3["HostGenus"] = "Gordonia"

        phage_data1["Accession"] = "ABC123"
        phage_data2["Accession"] = "XYZ456"
        phage_data3["Accession"] = ""

        phage_data1["Cluster"] = "A"
        phage_data2["Cluster"] = "B"
        phage_data3["Cluster"] = "NULL"

        phage_data1["Subcluster"] = "A1"
        phage_data2["Subcluster"] = "NULL"
        phage_data3["Subcluster"] = "NULL"

        phage_data1["Sequence"] = "atcg"
        phage_data2["Sequence"] = "AATT"
        phage_data3["Sequence"] = "GGCC"

        phage_data1["Length"] = 6
        phage_data2["Length"] = 4
        phage_data3["Length"] = 5

        phage_data1["DateLastModified"] = constants.EMPTY_DATE
        phage_data2["DateLastModified"] = constants.EMPTY_DATE
        phage_data3["DateLastModified"] = constants.EMPTY_DATE

        phage_data_list = [phage_data1, phage_data2, phage_data3]
        for phage_data in phage_data_list:
            test_db_utils.insert_data(PHAGE, phage_data)

        gene_data1 = test_data_utils.get_trixie_gene_data()
        gene_data2 = test_data_utils.get_trixie_gene_data()
        gene_data3 = test_data_utils.get_trixie_gene_data()
        gene_data4 = test_data_utils.get_trixie_gene_data()

        gene_data1["PhageID"] = "Trixie"
        gene_data2["PhageID"] = "Trixie"
        gene_data3["PhageID"] = "Trixie"
        gene_data4["PhageID"] = "D29"

        gene_data1["GeneID"] = "Trixie_1"
        gene_data2["GeneID"] = "Trixie_2"
        gene_data3["GeneID"] = "Trixie_3"
        gene_data4["GeneID"] = "D29_1"

        gene_data_list = [gene_data1, gene_data2, gene_data3, gene_data4]
        for gene_data in gene_data_list:
            test_db_utils.insert_data(GENE, gene_data)

        trna_data1 = test_data_utils.get_trixie_trna_data()
        trna_data2 = test_data_utils.get_trixie_trna_data()
        trna_data3 = test_data_utils.get_trixie_trna_data()

        trna_data1["PhageID"] = "Trixie"
        trna_data2["PhageID"] = "Trixie"
        trna_data3["PhageID"] = "D29"

        trna_data1["GeneID"] = "Trixie_4"
        trna_data2["GeneID"] = "Trixie_5"
        trna_data3["GeneID"] = "D29_1"

        trna_data_list = [trna_data1, trna_data2, trna_data3]
        for trna_data in trna_data_list:
            test_db_utils.insert_data(TRNA, trna_data)

        tmrna_data1 = test_data_utils.get_trixie_tmrna_data()
        tmrna_data2 = test_data_utils.get_trixie_tmrna_data()

        tmrna_data1["PhageID"] = "Trixie"
        tmrna_data2["PhageID"] = "L5"

        tmrna_data1["GeneID"] = "Trixie_6"
        tmrna_data2["GeneID"] = "L5_1"

        tmrna_data_list = [tmrna_data1, tmrna_data2]
        for tmrna_data in tmrna_data_list:
            test_db_utils.insert_data(TMRNA, tmrna_data)