ensembl-hive  2.7.0
create_fixsql.pl
Go to the documentation of this file.
1 #!/usr/bin/env perl
2 # See the NOTICE file distributed with this work for additional information
3 # regarding copyright ownership.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 use strict;
18 use warnings;
19 
20 my $old;
21 my $new;
22 while (<>) {
23 
24  if (/grep (\S+)/) {
25  $old=$1;
26  next;
27  }
28 
29  if (/(ENSE\S+)\s(ENSE\S+)/) {
30  if ($2 eq $old) {
31  $new=$1;
32  if ($old ne $1) {
33  print "update translation set start_exon\=\"$1\" where start_exon\=\"$old\"\;\n";
34  print "update translation set end_exon\=\"$1\" where end_exon\=\"$old\"\;\n";
35  print "update supporting_feature set exon\=\"$1\" where exon\=\"$old\"\;\n";
36  print "update exon_transcript set exon\=\"$1\" where exon\=\"$old\"\;\n";
37  }
38  }
39  elsif ($1 eq $old) {
40  if ($new ne $2) {
41  print "update translation set start_exon\=\"$new\" where start_exon\=\"$2\"\;\n";
42  print "update translation set end_exon\=\"$new\" where end_exon\=\"$2\"\;\n";
43  print "update supporting_feature set exon\=\"$new\" where exon\=\"$2\"\;\n";
44  print "update exon_transcript set exon\=\"$new\" where exon\=\"$2\"\;\n";
45  }
46  $old = $2;
47  }
48  }
49 }