 # change the transcript_variation & variation_feature tables to add new consequence protein_altering_variant
 ##################
 
+## VARIATION_FEATURE
+# create tmp table
+CREATE TABLE tmp_vf LIKE variation_feature;
 
-ALTER TABLE variation_feature MODIFY consequence_types SET (
+# alter its consequence type field
+ALTER TABLE tmp_vf CHANGE consequence_types consequence_types SET (
         'intergenic_variant',
         'splice_acceptor_variant',
         'splice_donor_variant',

        'protein_altering_variant'
    ) DEFAULT 'intergenic_variant' NOT NULL;



ALTER TABLE transcript_variation MODIFY consequence_types SET (
                                            'splice_acceptor_variant',
                                            'splice_donor_variant',
                                            'stop_lost',

                                            'protein_altering_variant'
                                        );

# insert into tmp table, replacing old terms with new as we go
INSERT INTO tmp_tv SELECT transcript_variation_id, variation_feature_id, feature_stable_id, allele_string, somatic,
    REPLACE(consequence_types, 'initiator_codon_variant', 'start_lost'),
cds_start, cds_end, cdna_start, cdna_end, translation_start, translation_end, distance_to_transcript, codon_allele_string, pep_allele_string, hgvs_genomic, hgvs_transcript, hgvs_protein, polyphen_prediction, polyphen_score, sift_prediction, sift_score, display
FROM transcript_variation;

DROP TABLE transcript_variation;
RENAME TABLE tmp_tv TO transcript_variation;


# patch identifier
INSERT INTO meta (species_id, meta_key, meta_value) VALUES (NULL,'patch', 'patch_79_80_c.sql|change the column consequence_types in transcript_variation and variation_feature to add protein_altering_variant and change initiator_codon_variant to start_lost');
