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")
def test_create_trna_table_insert_1(self): """Verify trna table INSERT statement is created correctly when locus_tag, note, and structure, and use 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. trna1 = trna.Trna() trna1.id = "Trixie_1" trna1.genome_id = "Trixie" trna1.name = "1" trna1.locus_tag = "TAG1" trna1.start = 5 trna1.stop = 10 trna1.length = 200 trna1.orientation = "F" trna1.note = "misc" trna1.amino_acid = "Ala" trna1.anticodon = "AAA" trna1.structure = "random" trna1.use = "aragorn" statement = mysqldb.create_trna_table_insert(trna1) test_db_utils.execute(statement) result = test_db_utils.get_data(TRNA_QUERY2) results = result[0] exp = ("""INSERT INTO trna """ """(GeneID, PhageID, Start, Stop, Length, """ """Name, Orientation, Note, LocusTag, AminoAcid, Anticodon, """ """Structure, Source) """ """VALUES """ """("Trixie_1", "Trixie", 5, 10, 200, "1", "F", "misc", """ """"TAG1", "Ala", "AAA", "random", "aragorn");""") 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["Structure"].decode("utf-8"), "random") with self.subTest(): self.assertEqual(results["AminoAcid"], "Ala") with self.subTest(): self.assertEqual(results["Anticodon"], "AAA") with self.subTest(): self.assertEqual(results["Source"], "aragorn")
def setUp(self): self.feature = trna.Trna() 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")
def parse_trna_seqfeature(seqfeature): """ Parse data from a Biopython tRNA SeqFeature object into a Trna object. :param seqfeature: Biopython SeqFeature :type seqfeature: SeqFeature :returns: a pdm_utils Trna object :rtype: Trna """ trna_ftr = trna.Trna() trna_ftr.seqfeature = seqfeature try: locus_tag = seqfeature.qualifiers["locus_tag"][0] except (KeyError, IndexError): locus_tag = "" finally: trna_ftr.set_locus_tag(locus_tag, delimiter=None) trna_ftr.set_orientation(seqfeature.strand, "fr_short", True) trna_ftr.start, trna_ftr.stop, trna_ftr.parts = parse_coordinates( seqfeature) # Coordinate format for GenBank flat file features parsed by Biopython # are 0-based half open intervals. trna_ftr.coordinate_format = "0_half_open" trna_ftr.set_nucleotide_length(use_seq=True) try: product = seqfeature.qualifiers["product"][0] except (KeyError, IndexError): product = "" finally: trna_ftr.product = product try: note = seqfeature.qualifiers["note"][0] except (KeyError, IndexError): note = "" finally: trna_ftr.note = note try: gene = seqfeature.qualifiers["gene"][0] except (KeyError, IndexError): gene = "" finally: trna_ftr.gene = gene trna_ftr.set_name() return trna_ftr
def parse_trna_table_data(data_dict): """Parse a MySQL database dictionary to create a Trna object. :param data_dict: Dictionary of data retrieved from the gene table. :type data_dict: dict :returns: A pdm_utils Trna object. :rtype: Trna """ ftr = trna.Trna() ftr.type = "tRNA" 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.amino_acid = data_dict["AminoAcid"] except: pass try: ftr.anticodon = data_dict["Anticodon"] except: pass try: ftr.structure = data_dict["Structure"].decode("utf-8") except: pass try: ftr.use = data_dict["Source"] except: pass try: ftr.parts = 1 except: pass ftr.coordinate_format = "0_half_open" return ftr
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]