Merge pull request #5163 from solgenomics/audit-error-checking
[sgn.git] / db / 00139 / AddSequenceMetadataTypes.pm
blobeb2f5781f8709567ef2ea2d6675f42e407dfe4c6
1 #!/usr/bin/env perl
4 =head1 NAME
6 AddSequenceMetadataTypes.pm
8 =head1 SYNOPSIS
10 mx-run AddSequenceMetadataTypes [options] -H hostname -D dbname -u username [-F]
12 this is a subclass of L<CXGN::Metadata::Dbpatch>
13 see the perldoc of parent class for more details.
15 =head1 DESCRIPTION
17 This patch adds the CV and CVTerms for the Sequence Metadata Types (used by the featureprop_json table)
18 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
20 =head1 AUTHOR
22 =head1 COPYRIGHT & LICENSE
24 Copyright 2010 Boyce Thompson Institute for Plant Research
26 This program is free software; you can redistribute it and/or modify
27 it under the same terms as Perl itself.
29 =cut
32 package AddSequenceMetadataTypes;
34 use Moose;
35 use Bio::Chado::Schema;
36 use Try::Tiny;
37 extends 'CXGN::Metadata::Dbpatch';
40 has '+description' => ( default => <<'' );
41 This patch adds the CV and CVTerms for the Sequence Metadata Types (used by the featureprop_json table)
43 has '+prereq' => (
44 default => sub {
45 [],
50 sub patch {
51 my $self=shift;
53 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
55 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
57 print STDOUT "\nExecuting the SQL commands.\n";
58 my $schema = Bio::Chado::Schema->connect( sub { $self->dbh->clone } );
59 my $cvterm_rs = $schema->resultset("Cv::Cvterm");
60 my $cv_rs = $schema->resultset("Cv::Cv");
62 print STDERR "CREATING CV...\n";
63 my $cv = $cv_rs->find_or_create({ name => 'sequence_metadata_types' });
65 print STDERR "ADDING CVTERMS...\n";
66 $cvterm_rs->create_with({
67 name => 'Gene Annotation',
68 cv => 'sequence_metadata_types'
69 });
70 $cvterm_rs->create_with({
71 name => 'GWAS Results',
72 cv => 'sequence_metadata_types'
73 });
74 $cvterm_rs->create_with({
75 name => 'MNase',
76 cv => 'sequence_metadata_types'
77 });
79 print STDERR "UPDATING DEFINITIONS...\n";
80 $self->dbh->do(<<EOSQL);
81 UPDATE public.cvterm SET definition = 'Provides sequence features (gene, mRNA, UTR, exon, CDS) and annotations based on alignments of biological evidence.'
82 WHERE name = 'Gene Annotation' AND cv_id = (SELECT cv_id FROM cv WHERE name = 'sequence_metadata_types');
84 UPDATE public.cvterm SET definition = 'Report of quantitative trait loci (QTLs) indentified by running rrBLUP analysis on phenotype trials and genotype trials within the T3 database.'
85 WHERE name = 'GWAS Results' AND cv_id = (SELECT cv_id FROM cv WHERE name = 'sequence_metadata_types');
87 UPDATE public.cvterm SET definition = 'Report of chromatine accessibility score. The report can be used to prioritize genomic variants and explain phenotypes. (https://genomebiology.biomedcentral.com/track/pdf/10.1186/s13059-020-02093-1)'
88 WHERE name = 'MNase' AND cv_id = (SELECT cv_id FROM cv WHERE name = 'sequence_metadata_types');
89 EOSQL
91 print "You're done!\n";
95 ####
96 1; #
97 ####