ShoaibAI commited on
Commit
58c6003
·
verified ·
1 Parent(s): c052ec6

Delete init_db.py.py

Browse files
Files changed (1) hide show
  1. init_db.py.py +0 -162
init_db.py.py DELETED
@@ -1,162 +0,0 @@
1
- import sqlite3
2
- import os
3
-
4
- def init_database():
5
- """Initialize SQLite database with species and biochemical profiles"""
6
-
7
- conn = sqlite3.connect('microid.db')
8
- cursor = conn.cursor()
9
-
10
- # Create tables
11
- cursor.execute('''
12
- CREATE TABLE IF NOT EXISTS species (
13
- id INTEGER PRIMARY KEY AUTOINCREMENT,
14
- genus TEXT NOT NULL,
15
- species TEXT NOT NULL,
16
- full_name TEXT UNIQUE NOT NULL,
17
- gram_stain TEXT,
18
- morphology TEXT,
19
- notes TEXT
20
- )
21
- ''')
22
-
23
- cursor.execute('''
24
- CREATE TABLE IF NOT EXISTS biochemical_tests (
25
- id INTEGER PRIMARY KEY AUTOINCREMENT,
26
- test_code TEXT UNIQUE NOT NULL,
27
- test_name TEXT NOT NULL,
28
- description TEXT,
29
- position INTEGER
30
- )
31
- ''')
32
-
33
- cursor.execute('''
34
- CREATE TABLE IF NOT EXISTS species_profiles (
35
- id INTEGER PRIMARY KEY AUTOINCREMENT,
36
- species_id INTEGER,
37
- test_id INTEGER,
38
- reaction TEXT NOT NULL,
39
- probability REAL DEFAULT 0.95,
40
- FOREIGN KEY (species_id) REFERENCES species(id),
41
- FOREIGN KEY (test_id) REFERENCES biochemical_tests(id)
42
- )
43
- ''')
44
-
45
- # Insert biochemical tests
46
- tests = [
47
- (1, 'ONPG', 'Beta-galactosidase', 1),
48
- (2, 'ADH', 'Arginine dihydrolase', 2),
49
- (3, 'LDC', 'Lysine decarboxylase', 3),
50
- (4, 'ODC', 'Ornithine decarboxylase', 4),
51
- (5, 'CIT', 'Citrate utilization', 5),
52
- (6, 'H2S', 'Hydrogen sulfide', 6),
53
- (7, 'URE', 'Urease', 7),
54
- (8, 'TDA', 'Tryptophan deaminase', 8),
55
- (9, 'IND', 'Indole production', 9),
56
- (10, 'VP', 'Voges-Proskauer', 10),
57
- (11, 'GEL', 'Gelatinase', 11),
58
- (12, 'GLU', 'Glucose fermentation', 12),
59
- (13, 'MAN', 'Mannitol', 13),
60
- (14, 'INO', 'Inositol', 14),
61
- (15, 'SOR', 'Sorbitol', 15),
62
- (16, 'RHA', 'Rhamnose', 16),
63
- (17, 'SAC', 'Sucrose', 17),
64
- (18, 'MEL', 'Melibiose', 18),
65
- (19, 'AMY', 'Amygdalin', 19),
66
- (20, 'ARA', 'Arabinose', 20)
67
- ]
68
-
69
- for test in tests:
70
- cursor.execute('''
71
- INSERT OR IGNORE INTO biochemical_tests (id, test_code, test_name, position)
72
- VALUES (?, ?, ?, ?)
73
- ''', test)
74
-
75
- # Insert species
76
- species_list = [
77
- ('Escherichia', 'coli', 'Escherichia coli', 'negative', 'rod'),
78
- ('Pseudomonas', 'aeruginosa', 'Pseudomonas aeruginosa', 'negative', 'rod'),
79
- ('Staphylococcus', 'aureus', 'Staphylococcus aureus', 'positive', 'coccus'),
80
- ('Streptococcus', 'pneumoniae', 'Streptococcus pneumoniae', 'positive', 'coccus'),
81
- ('Klebsiella', 'pneumoniae', 'Klebsiella pneumoniae', 'negative', 'rod'),
82
- ('Proteus', 'mirabilis', 'Proteus mirabilis', 'negative', 'rod'),
83
- ('Enterococcus', 'faecalis', 'Enterococcus faecalis', 'positive', 'coccus'),
84
- ('Neisseria', 'gonorrhoeae', 'Neisseria gonorrhoeae', 'negative', 'coccus'),
85
- ('Haemophilus', 'influenzae', 'Haemophilus influenzae', 'negative', 'rod'),
86
- ('Candida', 'albicans', 'Candida albicans', 'yeast', 'yeast'),
87
- ('Salmonella', 'typhimurium', 'Salmonella typhimurium', 'negative', 'rod'),
88
- ('Shigella', 'flexneri', 'Shigella flexneri', 'negative', 'rod'),
89
- ('Bacillus', 'subtilis', 'Bacillus subtilis', 'positive', 'rod'),
90
- ('Clostridium', 'perfringens', 'Clostridium perfringens', 'positive', 'rod'),
91
- ('Listeria', 'monocytogenes', 'Listeria monocytogenes', 'positive', 'rod'),
92
- ('Acinetobacter', 'baumannii', 'Acinetobacter baumannii', 'negative', 'coccus'),
93
- ('Enterobacter', 'cloacae', 'Enterobacter cloacae', 'negative', 'rod'),
94
- ('Serratia', 'marcescens', 'Serratia marcescens', 'negative', 'rod'),
95
- ('Citrobacter', 'freundii', 'Citrobacter freundii', 'negative', 'rod'),
96
- ('Morganella', 'morganii', 'Morganella morganii', 'negative', 'rod'),
97
- ('Yersinia', 'enterocolitica', 'Yersinia enterocolitica', 'negative', 'rod'),
98
- ('Vibrio', 'cholerae', 'Vibrio cholerae', 'negative', 'rod'),
99
- ('Campylobacter', 'jejuni', 'Campylobacter jejuni', 'negative', 'curved rod'),
100
- ('Bacteroides', 'fragilis', 'Bacteroides fragilis', 'negative', 'rod'),
101
- ('Lactobacillus', 'acidophilus', 'Lactobacillus acidophilus', 'positive', 'rod'),
102
- ('Streptococcus', 'pyogenes', 'Streptococcus pyogenes', 'positive', 'coccus'),
103
- ('Staphylococcus', 'epidermidis', 'Staphylococcus epidermidis', 'positive', 'coccus'),
104
- ('Candida', 'glabrata', 'Candida glabrata', 'yeast', 'yeast'),
105
- ('Candida', 'parapsilosis', 'Candida parapsilosis', 'yeast', 'yeast'),
106
- ('Candida', 'tropicalis', 'Candida tropicalis', 'yeast', 'yeast'),
107
- ('Cryptococcus', 'neoformans', 'Cryptococcus neoformans', 'yeast', 'yeast')
108
- ]
109
-
110
- for species in species_list:
111
- cursor.execute('''
112
- INSERT OR IGNORE INTO species (genus, species, full_name, gram_stain, morphology)
113
- VALUES (?, ?, ?, ?, ?)
114
- ''', species)
115
-
116
- # Get species IDs
117
- cursor.execute('SELECT id, full_name FROM species')
118
- species_map = {row[1]: row[0] for row in cursor.fetchall()}
119
-
120
- # Get test IDs
121
- cursor.execute('SELECT id, test_code FROM biochemical_tests')
122
- test_map = {row[1]: row[0] for row in cursor.fetchall()}
123
-
124
- # Insert profiles (simplified - add more for full database)
125
- profiles = {
126
- 'Escherichia coli': {
127
- 'ONPG':'+', 'ADH':'-', 'LDC':'+', 'ODC':'+', 'CIT':'-',
128
- 'H2S':'-', 'URE':'-', 'TDA':'-', 'IND':'+', 'VP':'-',
129
- 'GEL':'-', 'GLU':'+', 'MAN':'+', 'INO':'-', 'SOR':'+',
130
- 'RHA':'+', 'SAC':'+', 'MEL':'+', 'AMY':'-', 'ARA':'+'
131
- },
132
- 'Pseudomonas aeruginosa': {
133
- 'ONPG':'-', 'ADH':'+', 'LDC':'-', 'ODC':'-', 'CIT':'+',
134
- 'H2S':'-', 'URE':'-', 'TDA':'-', 'IND':'-', 'VP':'-',
135
- 'GEL':'+', 'GLU':'+', 'MAN':'-', 'INO':'-', 'SOR':'-',
136
- 'RHA':'-', 'SAC':'-', 'MEL':'-', 'AMY':'-', 'ARA':'-'
137
- },
138
- 'Staphylococcus aureus': {
139
- 'ONPG':'+', 'ADH':'-', 'LDC':'-', 'ODC':'-', 'CIT':'V',
140
- 'H2S':'-', 'URE':'+', 'TDA':'-', 'IND':'-', 'VP':'+',
141
- 'GEL':'V', 'GLU':'+', 'MAN':'+', 'INO':'-', 'SOR':'+',
142
- 'RHA':'V', 'SAC':'+', 'MEL':'-', 'AMY':'V', 'ARA':'-'
143
- }
144
- }
145
-
146
- # Add more species profiles (I'll add more in the complete version)
147
- for species_name, reactions in profiles.items():
148
- if species_name in species_map:
149
- species_id = species_map[species_name]
150
- for test_code, reaction in reactions.items():
151
- test_id = test_map[test_code]
152
- cursor.execute('''
153
- INSERT OR IGNORE INTO species_profiles (species_id, test_id, reaction)
154
- VALUES (?, ?, ?)
155
- ''', (species_id, test_id, reaction))
156
-
157
- conn.commit()
158
- conn.close()
159
- print("Database initialized successfully!")
160
-
161
- if __name__ == "__main__":
162
- init_database()