示例#1
0
    def setUp(self):

        self.ticket1 = ticket.ImportTicket()

        self.src1 = source.Source()
        self.src1.id = "L5_SRC_1"
        self.src2 = source.Source()
        self.src2.id = "L5_SRC_2"
        self.src3 = source.Source()
        self.src3.id = "L5_SRC_3"

        self.cds1 = cds.Cds()
        self.cds1.id = "L5_CDS_1"
        self.cds2 = cds.Cds()
        self.cds2.id = "L5_CDS_2"
        self.cds3 = cds.Cds()
        self.cds3.id = "L5_CDS_3"

        self.trna1 = trna.Trna()
        self.trna1.id = "L5_TRNA_1"
        self.trna2 = trna.Trna()
        self.trna2.id = "L5_TRNA_2"
        self.trna3 = trna.Trna()
        self.trna3.id = "L5_TRNA_3"

        self.tmrna1 = tmrna.Tmrna()
        self.tmrna1.id = "L5_TMRNA_1"
        self.tmrna2 = tmrna.Tmrna()
        self.tmrna2.id = "L5_TMRNA_2"
        self.tmrna3 = tmrna.Tmrna()
        self.tmrna3.id = "L5_TMRNA_3"

        self.genome1 = genome.Genome()
        self.genome1.type = "flat_file"
        self.genome1.cds_features = [self.cds1, self.cds2]
        self.genome1.source_features = [self.src1, self.src2]
        self.genome1.trna_features = [self.trna1, self.trna2]
        self.genome1.tmrna_features = [self.tmrna1, self.tmrna2]

        self.genome2 = genome.Genome()
        self.genome2.type = "mysql"
        self.genome_pair1 = genomepair.GenomePair()
        self.genome_pair2 = genomepair.GenomePair()
        self.bndl = bundle.Bundle()
        self.bndl.ticket = self.ticket1
        self.bndl.genome_dict[self.genome1.type] = self.genome1
        self.bndl.genome_dict[self.genome2.type] = self.genome2
        self.bndl.genome_pair_dict["genome_pair1"] = self.genome_pair1
        self.bndl.genome_pair_dict["genome_pair2"] = self.genome_pair2

        self.eval_correct1 = evaluation.Evaluation(status="correct")
        self.eval_correct2 = evaluation.Evaluation(status="correct")
        self.eval_error1 = evaluation.Evaluation(status="error")
        self.eval_error2 = evaluation.Evaluation(status="error")
示例#2
0
 def setUp(self):
     self.feature = tmrna.Tmrna()
     self.seq1 = Seq("AATTCGAGCT")
     self.seqfeature1 = test_data_utils.create_1_part_seqfeature(
                             1, 5, 1, "CDS")
     self.seqfeature2 = test_data_utils.create_1_part_seqfeature(
                             1, 5, -1, "CDS")
     self.seqfeature3 = test_data_utils.create_2_part_seqfeature(
                             1, 5, 1, 3, 7, 1, "CDS")
示例#3
0
    def test_create_tmrna_table_insert_1(self):
        """Verify tmrna table INSERT statement is created correctly when
        locus_tag, note, and peptide_tag are not empty."""
        # Note: even though this function returns a string and doesn't
        # actually utilize a MySQL database, this test ensures
        # that the returned statement will function properly in MySQL.
        tmrna1 = tmrna.Tmrna()
        tmrna1.id = "Trixie_1"
        tmrna1.genome_id = "Trixie"
        tmrna1.name = "1"
        tmrna1.locus_tag = "TAG1"
        tmrna1.start = 5
        tmrna1.stop = 10
        tmrna1.length = 200
        tmrna1.orientation = "F"
        tmrna1.note = "misc"
        tmrna1.peptide_tag = "random"
        statement = mysqldb.create_tmrna_table_insert(tmrna1)
        test_db_utils.execute(statement)
        result = test_db_utils.get_data(TMRNA_QUERY2)
        results = result[0]
        exp = ("""INSERT INTO tmrna """
               """(GeneID, PhageID, Start, Stop, Length, """
               """Name, Orientation, Note, LocusTag, PeptideTag) """
               """VALUES """
               """("Trixie_1", "Trixie", 5, 10, 200, """
               """"1", "F", "misc", "TAG1", "random");""")

        with self.subTest():
            self.assertEqual(statement, exp)
        with self.subTest():
            self.assertEqual(results["GeneID"], "Trixie_1")
        with self.subTest():
            self.assertEqual(results["PhageID"], "Trixie")
        with self.subTest():
            self.assertEqual(results["Start"], 5)
        with self.subTest():
            self.assertEqual(results["Stop"], 10)
        with self.subTest():
            self.assertEqual(results["Length"], 200)
        with self.subTest():
            self.assertEqual(results["Name"], "1")
        with self.subTest():
            self.assertEqual(results["Orientation"], "F")
        with self.subTest():
            self.assertEqual(results["Note"].decode("utf-8"), "misc")
        with self.subTest():
            self.assertEqual(results["LocusTag"], "TAG1")
        with self.subTest():
            self.assertEqual(results["PeptideTag"], "random")
示例#4
0
def parse_tmrna_seqfeature(seqfeature):
    """
    Parses data from a BioPython tmRNA SeqFeature object into a
    Tmrna object.
    :param seqfeature: BioPython SeqFeature
    :type seqfeature: SeqFeature
    :return: pdm_utils Tmrna object
    :rtype: Tmrna
    """
    tmrna_ftr = tmrna.Tmrna()
    tmrna_ftr.seqfeature = seqfeature

    try:
        locus_tag = seqfeature.qualifiers["locus_tag"][0]
    except (KeyError, IndexError):
        locus_tag = ""
    finally:
        tmrna_ftr.set_locus_tag(locus_tag, delimiter=None)

    tmrna_ftr.set_orientation(seqfeature.strand, "fr_short", True)
    tmrna_ftr.start, tmrna_ftr.stop, tmrna_ftr.parts = parse_coordinates(
        seqfeature)

    # Coordinate format for GenBank flat file features parsed by Biopython
    # are 0-based half open intervals.
    tmrna_ftr.coordinate_format = "0_half_open"

    tmrna_ftr.set_nucleotide_length(use_seq=True)

    try:
        note = seqfeature.qualifiers["note"][0]
    except (KeyError, IndexError):
        note = ""
    finally:
        tmrna_ftr.note = note

    try:
        gene = seqfeature.qualifiers["gene"][0]
    except (KeyError, IndexError):
        gene = ""
    finally:
        tmrna_ftr.gene = gene

    tmrna_ftr.set_name()
    return tmrna_ftr
示例#5
0
def parse_tmrna_table_data(data_dict):
    """Parse a MySQL database dictionary to create a Tmrna object.

    :param data_dict:
        Dictionary of data retrieved from the gene table.
    :type data_dict: dict
    :returns: A pdm_utils Tmrna object.
    :rtype: Tmrna
    """

    ftr = tmrna.Tmrna()
    ftr.type = "tmRNA"

    try:
        ftr.id = data_dict["GeneID"]
    except:
        pass

    try:
        ftr.genome_id = data_dict["PhageID"]
    except:
        pass

    try:
        ftr.start = int(data_dict["Start"])
    except:
        pass

    try:
        ftr.stop = int(data_dict["Stop"])
    except:
        pass

    try:
        ftr.length = int(data_dict["Length"])
    except:
        pass

    try:
        ftr.name = data_dict["Name"]
    except:
        pass

    try:
        ftr.orientation = data_dict["Orientation"]
    except:
        pass

    try:
        ftr.set_locus_tag(data_dict["LocusTag"])
    except:
        pass

    try:
        ftr.note = data_dict["Note"].decode("utf-8")
    except:
        pass

    try:
        ftr.peptide_tag = data_dict["PeptideTag"]
    except:
        pass

    try:
        ftr.parts = 1
    except:
        pass

    ftr.coordinate_format = "0_half_open"

    return ftr
示例#6
0
    def setUp(self):
        self.genome1 = genome.Genome()
        self.genome1.id = "L5"
        self.genome1.name = "L5_Draft"
        self.genome1.host_genus = "Mycobacterium"
        self.genome1.annotation_status = "final"
        self.genome1.accession = "ABC123"
        self.genome1.seq = "ATCG"
        self.genome1.length = 4
        self.genome1.gc = 0.5001
        self.genome1.date = '1/1/2000'
        self.genome1.retrieve_record = "1"
        self.genome1.annotation_author = "1"
        self.genome1.cluster = "A"
        self.genome1.subcluster = "A2"

        self.cds1 = cds.Cds()
        self.cds1.genome_id = "L5"
        self.cds1.start = 10
        self.cds1.stop = 100
        self.cds1.parts = 1
        self.cds1.length = 1000
        self.cds1.name = "1"
        self.cds1.type = "CDS"
        self.cds1.translation = "AGGPT"
        self.cds1.orientation = "F"
        self.cds1.description = "description"
        self.cds1.locus_tag = "SEA_L5_001"

        self.cds2 = cds.Cds()
        self.cds2.genome_id = "L5"
        self.cds2.start = 100
        self.cds2.stop = 1000
        self.cds2.parts = 1
        self.cds2.length = 10000
        self.cds2.name = "2"
        self.cds2.type = "CDS"
        self.cds2.translation = "AKKQE"
        self.cds2.orientation = "R"
        self.cds2.description = "description"
        self.cds2.locus_tag = "SEA_L5_002"

        self.cds_features = [self.cds1, self.cds2]

        self.trna1 = trna.Trna()
        self.trna1.id = "Trixie_1"
        self.trna1.genome_id = "Trixie"
        self.trna1.name = "1"
        self.trna1.locus_tag = "TAG1"
        self.trna1.start = 5
        self.trna1.stop = 10
        self.trna1.length = 200
        self.trna1.orientation = "F"
        self.trna1.note = "misc"
        self.trna1.amino_acid = "Ala"
        self.trna1.anticodon = "AAA"
        self.trna1.structure = "random"
        self.trna1.use = "aragorn"

        self.trna2 = trna.Trna()
        self.trna2.id = "Trixie_1"
        self.trna2.genome_id = "Trixie"
        self.trna2.name = "1"
        self.trna2.locus_tag = "TAG1"
        self.trna2.start = 5
        self.trna2.stop = 10
        self.trna2.length = 200
        self.trna2.orientation = "F"
        self.trna2.note = "misc"
        self.trna2.amino_acid = "Ala"
        self.trna2.anticodon = "AAA"
        self.trna2.structure = "random"
        self.trna2.use = "aragorn"

        self.trna_features = [self.trna1, self.trna2]

        self.tmrna1 = tmrna.Tmrna()
        self.tmrna1.id = "Trixie_1"
        self.tmrna1.genome_id = "Trixie"
        self.tmrna1.name = "1"
        self.tmrna1.locus_tag = "TAG1"
        self.tmrna1.start = 5
        self.tmrna1.stop = 10
        self.tmrna1.length = 200
        self.tmrna1.orientation = "F"
        self.tmrna1.note = "misc"
        self.tmrna1.peptide_tag = "random"

        self.tmrna2 = tmrna.Tmrna()
        self.tmrna2.id = "Trixie_1"
        self.tmrna2.genome_id = "Trixie"
        self.tmrna2.name = "1"
        self.tmrna2.locus_tag = "TAG1"
        self.tmrna2.start = 5
        self.tmrna2.stop = 10
        self.tmrna2.length = 200
        self.tmrna2.orientation = "F"
        self.tmrna2.note = "misc"
        self.tmrna2.peptide_tag = "random"

        self.tmrna_features = [self.tmrna1, self.tmrna2]