3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
20 package XrefMapper::sars_cov_2;
30 sub transcript_names_from_gene {
32 my $core_dbi = $self->
core->
dbc;
34 my $reset_sth = $core_dbi->prepare(
"UPDATE transcript SET display_xref_id = null");
35 $reset_sth->execute();
38 my $del_xref_sth = $core_dbi->prepare(
"DELETE x FROM xref x, object_xref ox, external_db e WHERE x.xref_id = ox.xref_id AND ensembl_object_type = 'Transcript' AND e.external_db_id = x.external_db_id AND e.db_name like '%_trans_name'");
39 my $del_ox_sth = $core_dbi->prepare(
"DELETE ox FROM object_xref ox LEFT JOIN xref x ON x.xref_id = ox.xref_id WHERE isnull(x.xref_id)");
41 my $xref_id_sth = $core_dbi->prepare(
"SELECT max(xref_id) FROM xref");
42 my $ox_id_sth = $core_dbi->prepare(
"SELECT max(object_xref_id) FROM object_xref");
43 my $ins_xref_sth = $core_dbi->prepare(
"INSERT IGNORE into xref (xref_id, external_db_id, dbprimary_acc, display_label, version, description, info_type, info_text) values(?, ?, ?, ?, 0, ?, 'MISC', ?)");
44 my $ins_ox_sth = $core_dbi->prepare(
"INSERT into object_xref (object_xref_id, ensembl_id, ensembl_object_type, xref_id) values(?, ?, 'Transcript', ?)");
45 my $update_tran_sth = $core_dbi->prepare(
"UPDATE transcript t SET t.display_xref_id= ? WHERE t.transcript_id=?");
46 my $get_genes = $core_dbi->prepare(
"SELECT g.gene_id, e.db_name, x.dbprimary_acc, x.display_label, x.description FROM gene g, xref x, external_db e where g.display_xref_id = x.xref_id and e.external_db_id = x.external_db_id");
47 my $get_transcripts = $core_dbi->prepare(
"SELECT transcript_id FROM transcript WHERE gene_id = ? ORDER BY seq_region_start, seq_region_end");
48 my $get_source_id = $core_dbi->prepare(
"SELECT external_db_id FROM external_db WHERE db_name like ?");
50 $get_genes->execute();
51 my ($gene_id, $external_db, $external_db_id, $acc, $label, $description, $transcript_id, $xref_id, $ox_id, $ext, $reuse_xref_id, $info_text);
52 $get_genes->bind_columns(\$gene_id, \$external_db, \$acc, \$label, \$description);
53 $xref_id_sth->execute();
54 $xref_id_sth->bind_columns(\$xref_id);
55 $xref_id_sth->fetch();
56 $ox_id_sth->execute();
57 $ox_id_sth->bind_columns(\$ox_id);
60 $del_xref_sth->execute();
61 while ($get_genes->fetch()) {
62 $get_source_id->execute($external_db .
"_trans_name");
63 $get_source_id->bind_columns(\$external_db_id);
64 $get_source_id->fetch();
65 $get_transcripts->execute($gene_id);
66 $get_transcripts->bind_columns(\$transcript_id);
67 while ($get_transcripts->fetch) {
70 $info_text =
'via gene ' . $acc;
71 $ins_xref_sth->execute($xref_id, $external_db_id, $label, $label, $description, $info_text);
72 $ins_ox_sth->execute($ox_id, $transcript_id, $xref_id);
73 $update_tran_sth->execute($xref_id, $transcript_id);
77 $del_ox_sth->execute();
78 $del_ox_sth->finish();
80 $del_xref_sth->finish();
81 $xref_id_sth->finish();
84 $get_source_id->finish();
85 $get_transcripts->finish();
86 $ins_xref_sth->finish();
87 $ins_ox_sth->finish();
88 $update_tran_sth->finish();