0
|
1 package Bio::EnsEMBL::Variation::Pipeline::UpdateVariationFeature;
|
|
2
|
|
3 use strict;
|
|
4 use warnings;
|
|
5
|
|
6 use base qw(Bio::EnsEMBL::Variation::Pipeline::BaseVariationProcess);
|
|
7
|
|
8 sub run {
|
|
9
|
|
10 my $self = shift;
|
|
11
|
|
12 my $var_dba = $self->get_species_adaptor('variation');
|
|
13
|
|
14 my $dbc = $var_dba->dbc;
|
|
15
|
|
16 # first set the default consequence type
|
|
17
|
|
18 $dbc->do(qq{
|
|
19 UPDATE variation_feature
|
|
20 SET consequence_types = 'intergenic_variant'
|
|
21 }) or die "Failed to reset consequence_types on variation_feature";
|
|
22
|
|
23 # create a temp table (dropping it if it exists)
|
|
24
|
|
25 my $temp_table = 'variation_feature_with_tv';
|
|
26
|
|
27 $dbc->do(qq{DROP TABLE IF EXISTS $temp_table})
|
|
28 or die "Failed to drop pre-existing temp table";
|
|
29
|
|
30 $dbc->do(qq{CREATE TABLE $temp_table LIKE variation_feature})
|
|
31 or die "Failed to create temp table";
|
|
32
|
|
33 # concatenate the consequence types from transcript_variation
|
|
34
|
|
35 $dbc->do(qq{
|
|
36 INSERT INTO $temp_table (variation_feature_id, consequence_types)
|
|
37 SELECT variation_feature_id, GROUP_CONCAT(DISTINCT(consequence_types))
|
|
38 FROM transcript_variation
|
|
39 GROUP BY variation_feature_id
|
|
40 }) or die "Populating temp table failed";
|
|
41
|
|
42 # update variation_feature
|
|
43
|
|
44 $dbc->do(qq{
|
|
45 UPDATE variation_feature vf, $temp_table tvf
|
|
46 SET vf.consequence_types = tvf.consequence_types
|
|
47 WHERE vf.variation_feature_id = tvf.variation_feature_id
|
|
48 }) or die "Failed to update vf table";
|
|
49
|
|
50 # and get rid of our temp table
|
|
51
|
|
52 $dbc->do(qq{DROP TABLE $temp_table})
|
|
53 or die "Failed to drop temp table";
|
|
54
|
|
55 }
|
|
56
|
|
57 1;
|
|
58
|