5 def main(cmdline=None):
7 dest='/tmp/fctracker.db'
10 shutil.copy(cmdline[0], dest)
11 conn = sqlite3.connect(dest)
14 #Copy user id's from auth User to new HTSUser
15 c.execute('INSERT INTO samples_htsuser (user_ptr_id) SELECT id FROM auth_user;')
17 c.execute("""CREATE TEMPORARY TABLE experiments_flowcell_temp (
18 "id" integer NOT NULL PRIMARY KEY,
19 "flowcell_id" varchar(20) NOT NULL UNIQUE,
20 "run_date" datetime NOT NULL,
21 "advanced_run" bool NOT NULL,
22 "paired_end" bool NOT NULL,
23 "read_length" integer NOT NULL,
24 "lane_1_library_id" integer NOT NULL REFERENCES "samples_library" ("id"),
25 "lane_2_library_id" integer NOT NULL REFERENCES "samples_library" ("id"),
26 "lane_3_library_id" integer NOT NULL REFERENCES "samples_library" ("id"),
27 "lane_4_library_id" integer NOT NULL REFERENCES "samples_library" ("id"),
28 "lane_5_library_id" integer NOT NULL REFERENCES "samples_library" ("id"),
29 "lane_6_library_id" integer NOT NULL REFERENCES "samples_library" ("id"),
30 "lane_7_library_id" integer NOT NULL REFERENCES "samples_library" ("id"),
31 "lane_8_library_id" integer NOT NULL REFERENCES "samples_library" ("id"),
32 "lane_1_pM" decimal NOT NULL,
33 "lane_2_pM" decimal NOT NULL,
34 "lane_3_pM" decimal NOT NULL,
35 "lane_4_pM" decimal NOT NULL,
36 "lane_5_pM" decimal NOT NULL,
37 "lane_6_pM" decimal NOT NULL,
38 "lane_7_pM" decimal NOT NULL,
39 "lane_8_pM" decimal NOT NULL,
40 "lane_1_cluster_estimate" integer NULL,
41 "lane_2_cluster_estimate" integer NULL,
42 "lane_3_cluster_estimate" integer NULL,
43 "lane_4_cluster_estimate" integer NULL,
44 "lane_5_cluster_estimate" integer NULL,
45 "lane_6_cluster_estimate" integer NULL,
46 "lane_7_cluster_estimate" integer NULL,
47 "lane_8_cluster_estimate" integer NULL,
48 "cluster_station_id" integer NOT NULL REFERENCES "experiments_clusterstation" ("id"),
49 "sequencer_id" integer NOT NULL REFERENCES "experiments_sequencer" ("id"),
52 c.execute("""INSERT INTO experiments_flowcell_temp SELECT id,flowcell_id,run_date,advanced_run,paired_end,read_length,lane_1_library_id,lane_2_library_id,lane_3_library_id,lane_4_library_id,lane_5_library_id,lane_6_library_id,lane_7_library_id,lane_8_library_id,lane_1_pM,lane_2_pM,lane_3_pM,lane_4_pM,lane_5_pM,lane_6_pM,lane_7_pM,lane_8_pM,lane_1_cluster_estimate,lane_2_cluster_estimate,lane_3_cluster_estimate,lane_4_cluster_estimate,lane_5_cluster_estimate,lane_6_cluster_estimate,lane_7_cluster_estimate,lane_8_cluster_estimate,cluster_station_id,sequencer_id,notes FROM experiments_flowcell;
54 c.execute('DROP TABLE experiments_flowcell;')
55 c.execute("""CREATE TABLE experiments_flowcell (
56 "id" integer NOT NULL PRIMARY KEY,
57 "flowcell_id" varchar(20) NOT NULL UNIQUE,
58 "run_date" datetime NOT NULL,
59 "advanced_run" bool NOT NULL,
60 "paired_end" bool NOT NULL,
61 "read_length" integer NOT NULL,
62 "cluster_station_id" integer NOT NULL REFERENCES "experiments_clusterstation" ("id"),
63 "sequencer_id" integer NOT NULL REFERENCES "experiments_sequencer" ("id"),
67 c.execute("""INSERT INTO experiments_flowcell SELECT id,flowcell_id,run_date,advanced_run,paired_end,read_length,cluster_station_id,sequencer_id,notes FROM experiments_flowcell_temp;
69 c.execute("""select id from experiments_flowcell;""")
70 flowcell_pks = [ r[0] for r in c ]
72 lane_insert = """INSERT INTO experiments_lane (
78 SELECT id, %(lane)d, lane_%(lane)d_library_id, lane_%(lane)d_pM,
79 lane_%(lane)d_cluster_estimate
80 FROM experiments_flowcell_temp
83 for pk in flowcell_pks:
84 for lane in (1,2,3,4,5,6,7,8):
85 c.execute( lane_insert % {'lane': int(lane), 'id': int(pk)} )
87 c.execute('DROP TABLE experiments_flowcell_temp;')
89 #Add control_lane column
90 c.execute('ALTER TABLE experiments_flowcell ADD COLUMN "control_lane" integer NULL;')
94 if __name__ == "__main__":