-
Notifications
You must be signed in to change notification settings - Fork 4
/
create_metaPORE_db.py
executable file
·96 lines (77 loc) · 2.2 KB
/
create_metaPORE_db.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/python
#
# create_metaPORE_db.py
#
# Chiu Laboratory
# University of California, San Francisco
#
# Copyright (C) 2015 Scot Federman - All Rights Reserved
# metaPORE has been released under a modified BSD license.
# Please see license file for details.
import sqlite3
import sys
usage = "create_db_realtime.py <database_name>"
if len(sys.argv) != 2:
print usage
sys.exit(0)
database = sys.argv[1]
#
## Create database
#
print "Creating database: %s " % (database)
conn = sqlite3.connect(database)
c = conn.cursor()
c.execute('''CREATE TABLE Metadata (
last_update TEXT)''')
c.execute('''CREATE TABLE virus_species (
name TEXT,
count INTEGER)''')
c.execute('''CREATE TABLE bacteria_species (
name TEXT,
count INTEGER)''')
c.execute('''CREATE TABLE species (
name TEXT,
count INTEGER)''')
c.execute('''CREATE TABLE genus (
name TEXT,
count INTEGER)''')
c.execute('''CREATE TABLE family (
name TEXT,
count INTEGER)''')
c.execute('''CREATE TABLE representative_sequence (
name TEXT,
count INTEGER)''')
c.execute('''CREATE TABLE pipeline (
name TEXT,
count INTEGER)''')
c.execute('''CREATE TABLE all_reads (
name TEXT,
count INTEGER,
color TEXT)''')
c.execute('INSERT INTO all_reads VALUES (?,?,?)', ("Homo sapiens",0,"tan"))
c.execute('INSERT INTO all_reads VALUES (?,?,?)', ("Unidentified reads",0,"Gray"))
c.execute('INSERT INTO all_reads VALUES (?,?,?)', ("Viruses",0,"Red"))
c.execute('INSERT INTO all_reads VALUES (?,?,?)', ("Cutadapt Removed",0,"Blue"))
c.execute('INSERT INTO all_reads VALUES (?,?,?)', ("Bacteria",0,"Green"))
c.execute('INSERT INTO all_reads VALUES (?,?,?)', ("non-Human Eukaryote",0,"Yellow"))
c.execute('INSERT INTO all_reads VALUES (?,?,?)', ("other lineage",0,"Black"))
c.execute('''CREATE TABLE sequences (
name TEXT,
channel INTEGER,
file TEXT,
exp_start_time INTEGER,
start_time INTEGER,
duration INTEGER,
twoD_seq TEXT,
twoD_qual TEXT,
template_seq TEXT,
template_qual TEXT,
complement_seq TEXT,
complement_qual TEXT)''')
c.execute('''CREATE TABLE BLAST (
name TEXT,
BLAST_hit_gi TEXT,
e_value REAL,
taxid INTEGER )''')
conn.commit()
conn.close()