Skip to content

Commit 181f36a

Browse files
authored
Update bam insert statement to include new required data (#33)
* Update bam insert statement to include new required data * Add missing comma
1 parent e1c7539 commit 181f36a

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/main/scripts/add_bam_pair_xenocp.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def add_bam_pair_stp(raptr, sample, target, project, subproject, **kwargs):
8585
None
8686
"""
8787
# Get stp ID
88-
query = """select sample_target_project_id from sample_target_project_view where
88+
query = """select sample_target_project_id from sample_target_project_view where
8989
formal_name = %s and target_name = %s and project_name = %s and subproject = %s;"""
9090
stp_id = raptr.fetch_item_or_fail(query, (sample, target, project, subproject))
9191

@@ -109,19 +109,25 @@ def add_bam_pair_stp(raptr, sample, target, project, subproject, **kwargs):
109109
# Get genome for old bam
110110
query = """select genome_id from bam where bam_id = %s;"""
111111
genome_id = raptr.fetch_item_or_fail(query, (bam_id,))
112+
113+
# Get anls type named xenocp
114+
query = """select anls_type_id from raptr.anls_type where name='%s'"""
115+
anls_type_id = raptr.fetch_item_or_fail(query, ('xenocp',))
116+
112117
# Add a new bam
113-
query = """insert into bam (bam_id, bam_tpl_id, status, notes, genome_id)
114-
values (nextval('blt_id_seq'), %s, 'Normal', NULL, %s) returning bam_id;"""
115-
bam_id_xenocp = raptr.fetch_item_or_fail(query, (bam_tpl_id_xenocp, genome_id))
118+
query = """insert into bam (bam_id, bam_tpl_id, status, notes, genome_id, anls_type_id, source_bam_id)
119+
values (nextval('blt_id_seq'), %s, 'Normal', NULL, %s, %s, %s) returning bam_id;"""
120+
bam_id_xenocp = raptr.fetch_item_or_fail(query, (bam_tpl_id_xenocp, genome_id, anls_type_id, bam_id))
121+
116122
# Update primary_bam_id of bam_tpl with the qualifier
117123
query = """update bam_tpl set primary_bam_id = %s where bam_tpl_id = %s;"""
118124
raptr.execute(query, (bam_id_xenocp, bam_tpl_id_xenocp))
119125

120126
# Get read_group_ids and insert into bam_read_group
121-
query = """SELECT read_group_id, pu from read_group inner join (select loadable_id as lid,
127+
query = """SELECT read_group_id, pu from read_group inner join (select loadable_id as lid,
122128
project_id as pid, project_name, subproject, target_name from loadable inner join
123129
(select * from sample_target_project_view where
124-
formal_name = %s and target_name = %s and project_name = %s
130+
formal_name = %s and target_name = %s and project_name = %s
125131
and subproject = %s) using (sample_target_id))
126132
on loadable_id = lid and project_id = pid where status = 'Normal';"""
127133
res = raptr.execute_fetch(query, (sample, target, project, subproject))
@@ -150,7 +156,7 @@ def add_bam_pair_bam_id(raptr, bam_id, **kwargs):
150156
None
151157
"""
152158
query = """select formal_name, target_name, project_name, subproject from sample_target_project_view inner join
153-
(select sample_target_project_id from bam_and_tpl where bam_id = %s and bam_status = 'Normal'
159+
(select sample_target_project_id from bam_and_tpl where bam_id = %s and bam_status = 'Normal'
154160
and legacy = false)
155161
using (sample_target_project_id);"""
156162
(sample, target, project, subproject) = raptr.fetch_row_or_fail(query, (bam_id,))

0 commit comments

Comments
 (0)