Пример #1
0
def parse_feature_data(alchemist, values=[], limit=8000):
    """Returns Cds objects containing data parsed from a MySQL database.

    :param alchemist: A connected and fully built AlchemyHandler object.
    :type alchemist: AlchemyHandler
    :param values: List of GeneIDs upon which the query can be conditioned.
    :type values: list[str]
    """
    gene_table = querying.get_table(alchemist.metadata, "gene")
    primary_key = list(gene_table.primary_key.columns)[0]
    cds_data_columns = list(gene_table.c)

    cds_data_query = querying.build_select(alchemist.graph, cds_data_columns)

    cds_data = querying.execute(alchemist.engine,
                                cds_data_query,
                                in_column=primary_key,
                                values=values,
                                limit=limit)

    cds_list = []
    for data_dict in cds_data:
        cds_ftr = mysqldb.parse_gene_table_data(data_dict)
        cds_list.append(cds_ftr)

    return cds_list
Пример #2
0
    def test_parse_gene_table_data_1(self):
        """Verify standard MySQL CDS data is parsed correctly
        from a data dictionary returned from a SQL query."""

        data_dict = {
            "GeneID": "L5_001",
            "PhageID": "L5",
            "Start": 10,
            "Stop": 100,
            "Parts": 1,
            "Length": 1000,
            "Name": "1",
            "Translation": "AGGPT",
            "Orientation": "F",
            "Notes": "description".encode("utf-8"),
            "DomainStatus": 1,
            "PhamID": 1,
            "LocusTag": "SEA_L5_001"
        }

        cds1 = mysqldb.parse_gene_table_data(data_dict)

        with self.subTest():
            self.assertEqual(cds1.id, "L5_001")
        with self.subTest():
            self.assertEqual(cds1.genome_id, "L5")
        with self.subTest():
            self.assertEqual(cds1.start, 10)
        with self.subTest():
            self.assertEqual(cds1.stop, 100)
        with self.subTest():
            self.assertEqual(cds1.parts, 1)
        with self.subTest():
            self.assertEqual(cds1.length, 1000)
        with self.subTest():
            self.assertEqual(cds1.name, "1")
        with self.subTest():
            self.assertEqual(cds1.type, "CDS")
        with self.subTest():
            self.assertEqual(cds1.translation, "AGGPT")
        with self.subTest():
            self.assertEqual(cds1.orientation, "F")
        with self.subTest():
            self.assertEqual(cds1.description, "description")
        with self.subTest():
            self.assertEqual(cds1.locus_tag, "SEA_L5_001")
        with self.subTest():
            self.assertEqual(cds1.translation_table, 11)
        with self.subTest():
            self.assertEqual(cds1.coordinate_format, "0_half_open")
        with self.subTest():
            self.assertEqual(cds1.domain_status, 1)
        with self.subTest():
            self.assertEqual(cds1.pham_id, 1)
Пример #3
0
def parse_cds_data_from_geneid(sql_handle, geneid_list):
    if not geneid_list:
        return []

    query = (f"SELECT * FROM gene WHERE GeneID IN ('" + \
              "','".join(geneid_list) + "')")
    result_list = sql_handle.execute_query(query)

    cds_list = []
    for data_dict in result_list:
        cds_list.append(mysqldb.parse_gene_table_data(data_dict))

    return cds_list

    args = sys.argv
    args.insert(0, "blank_argument")
    main(args)
Пример #4
0
    def test_parse_gene_table_data_2(self):
        """Verify truncated MySQL CDS data is parsed correctly
        from a data dictionary returned from a SQL query."""

        data_dict = {"GeneID":"L5_001",
                     "PhageID":"L5",
                     "Start":10,
                     "LocusTag":None}
        cds1 = mysqldb.parse_gene_table_data(data_dict)
        with self.subTest():
            self.assertEqual(cds1.id, "L5_001")
        with self.subTest():
            self.assertEqual(cds1.genome_id, "L5")
        with self.subTest():
            self.assertEqual(cds1.start, 10)
        with self.subTest():
            self.assertEqual(cds1.locus_tag, "")
        with self.subTest():
            self.assertEqual(cds1.translation_table, 11)