generated from solgenomics/breedbase_site
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd_new_project_type.pm
89 lines (57 loc) · 1.8 KB
/
add_new_project_type.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
=head1 NAME
AddNewProjectType.pm
=head1 SYNOPSIS
mx-run ThisPackageName [options] -H hostname -D dbname -u username [-F]
this is a subclass of L<CXGN::Metadata::Dbpatch>
see the perldoc of parent class for more details.
=head1 DESCRIPTION
This patch adds the necessary cvterms that are used for genetic gain, storage, heterosis and health status project types
This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
=head1 AUTHOR
chris simoes <ccs263@cornell.edu>
=head1 COPYRIGHT & LICENSE
Copyright 2010 Boyce Thompson Institute for Plant Research
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
package AddNewProjectType;
use Moose;
use Bio::Chado::Schema;
use Try::Tiny;
extends 'CXGN::Metadata::Dbpatch';
has '+description' => ( default => <<'' );
Add new cvterms for Genetic Gain, Storage, Heterosis and Health Status project types
has '+prereq' => (
default => sub {
[],
},
);
sub patch {
my $self=shift;
print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
print STDOUT "\nExecuting the SQL commands.\n";
my $schema = Bio::Chado::Schema->connect( sub { $self->dbh->clone } );
print STDERR "INSERTING CVTERMS...\n";
my $terms = {
'project_type' => [
'Stage 1',
'Stage 2',
'Stage 3',
'First Clonal',
'Second Clonal'
],
};
foreach my $t (keys %$terms){
foreach (@{$terms->{$t}}){
$schema->resultset("Cv::Cvterm")->create_with({
name => $_,
cv => $t
});
}
}
print "You're done!\n";
}
####
1; #
####