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 SeqStoreConverter::vega::VBasicConverter;
28 sub remove_supercontigs {
31 my $target = $self->target();
32 my $dbh = $self->dbh();
33 $self->debug(
"Vega specific - removing supercontigs from $target");
35 $dbh->do(
"DELETE FROM $target.meta ".
36 "WHERE meta_value like '%supercontig%'");
38 $dbh->do(
"DELETE FROM $target.coord_system ".
39 "WHERE name like 'supercontig'");
41 $dbh->do(
"DELETE $target.a ".
42 "FROM $target.assembly a, $target.seq_region sr ".
43 "WHERE sr.coord_system_id = 2 ".
44 "and a.asm_seq_region_id = sr.seq_region_id");
46 $dbh->do(
"DELETE FROM $target.seq_region ".
47 "WHERE coord_system_id = 2");
50 sub copy_other_vega_tables {
57 "current_transcript_info",
70 eval { $self->copy_current_clone_info; };
74 sub copy_current_clone_info {
76 my $source = $self->source();
77 my $target = $self->target();
78 my $sth = $self->dbh()->prepare
79 (
"INSERT INTO $target.current_clone_info(clone_id,clone_info_id) SELECT * FROM $source.current_clone_info");
84 sub update_clone_info {
89 sub copy_internal_clone_names {
94 sub copy_assembly_exception {
97 # copy assembly_exception table
98 $self->debug(
'Vega specific - copying assembly_exception table');
99 $self->copy_tables(
'assembly_exception');
101 my $source = $self->source();
102 my $target = $self->target();
103 my $dbh = $self->dbh();
105 # fix seq_region_id in assembly_exception
106 $self->debug(
'Vega specific - Updating seq_region_id in assembly_exception table');
108 UPDATE $target.assembly_exception, $target.tmp_chr_map
109 SET assembly_exception.seq_region_id = tmp_chr_map.new_id
110 WHERE assembly_exception.seq_region_id = tmp_chr_map.old_id
113 UPDATE $target.assembly_exception, $target.tmp_chr_map
114 SET assembly_exception.exc_seq_region_id = tmp_chr_map.new_id
115 WHERE assembly_exception.exc_seq_region_id = tmp_chr_map.old_id
118 # fix seq_region.length if necessary (this is the case if you have an
119 # assembly_exception at the end of a chromosome)
120 my $sth1 = $dbh->prepare(qq(
121 UPDATE $target.seq_region SET length = ? WHERE seq_region_id = ?
123 my $sth2 = $dbh->prepare(qq(
127 max(ae.seq_region_end)
129 $target.seq_region sr,
130 $target.assembly_exception ae
131 WHERE sr.seq_region_id = ae.seq_region_id
132 GROUP BY ae.seq_region_id
135 while (my ($sr_id, $sr_length, $max_ae_length) = $sth2->fetchrow_array) {
136 if ($max_ae_length > $sr_length) {
137 $self->debug(
" Updating seq_region.length for $sr_id (old $sr_length, new $max_ae_length)");
138 $sth1->execute($max_ae_length, $sr_id);
143 # reset gene, transcript, gene_description and external_db tables back to 30
144 sub back_patch_schema {
146 $self->debug (
"Patching gene, transcript, gene_description and external_db tables back to sch-30");
147 my $target = $self->target;
148 my $dbh = $self->dbh;
149 $dbh->do(
"DROP TABLE $target.gene");
150 $dbh->do( qq(CREATE TABLE $target.gene (
151 `gene_id`
int(10)
unsigned NOT NULL auto_increment,
152 `type` varchar(40) NOT NULL
default '',
153 `analysis_id`
int(11)
default NULL,
154 `seq_region_id`
int(10)
unsigned NOT NULL
default '0',
155 `seq_region_start`
int(10)
unsigned NOT NULL
default '0',
156 `seq_region_end`
int(10)
unsigned NOT NULL
default '0',
157 `seq_region_strand` tinyint(2) NOT NULL
default '0',
158 `display_xref_id`
int(10)
unsigned default NULL,
159 PRIMARY KEY (`gene_id`),
160 KEY `seq_region_idx` (`seq_region_id`,`seq_region_start`),
161 KEY `xref_id_index` (`display_xref_id`),
162 KEY `analysis_idx` (`analysis_id`)
163 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
165 $dbh->do(
"DROP TABLE $target.transcript");
166 $dbh->do( qq(CREATE TABLE $target.transcript (
167 `transcript_id`
int(10)
unsigned NOT NULL auto_increment,
168 `gene_id`
int(10)
unsigned NOT NULL
default '0',
169 `seq_region_id`
int(10)
unsigned NOT NULL
default '0',
170 `seq_region_start`
int(10)
unsigned NOT NULL
default '0',
171 `seq_region_end`
int(10)
unsigned NOT NULL
default '0',
172 `seq_region_strand` tinyint(2) NOT NULL
default '0',
173 `display_xref_id`
int(10)
unsigned default NULL,
174 PRIMARY KEY (`transcript_id`),
175 KEY `seq_region_idx` (`seq_region_id`,`seq_region_start`),
176 KEY `gene_index` (`gene_id`),
177 KEY `xref_id_index` (`display_xref_id`)
178 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
180 $dbh->do( qq(CREATE TABLE $target.gene_description (
181 `gene_id`
int(10)
unsigned NOT NULL
default '0',
183 PRIMARY KEY (`gene_id`)
184 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
186 $dbh->do(
"DROP TABLE $target.external_db");
187 $dbh->do( qq(CREATE TABLE $target.external_db (
188 `external_db_id`
int(11) NOT NULL
default '0',
189 `db_name` varchar(100) NOT NULL
default '',
190 `release` varchar(40) NOT NULL
default '',
191 `status`
enum(
'KNOWNXREF',
'KNOWN',
'XREF',
'PRED',
'ORTH',
'PSEUDO') NOT NULL
default 'KNOWNXREF',
192 PRIMARY KEY (`external_db_id`)
193 ) ENGINE=MyISAM DEFAULT CHARSET=latin1