10 mx-run RedefineTraitsView [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.
17 This patch updates the materialized view that stores traits
21 Bryan Ellerbrock<bje24@cornell.edu>
23 =head1 COPYRIGHT & LICENSE
25 Copyright 2010 Boyce Thompson Institute for Plant Research
27 This program is free software; you can redistribute it and/or modify
28 it under the same terms as Perl itself.
33 package RedefineTraitsView
;
36 extends
'CXGN::Metadata::Dbpatch';
39 has
'+description' => ( default => <<'' );
40 This patch updates the materialized view that stores traits
45 print STDOUT
"Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
47 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
49 print STDOUT
"\nExecuting the SQL commands.\n";
51 $self->dbh->do(<<EOSQL);
54 DROP MATERIALIZED VIEW public.traits;
56 CREATE MATERIALIZED VIEW public.traits AS
57 SELECT cvterm.cvterm_id AS trait_id,
58 (((cvterm.name::text || '|'::text) || db.name::text) || ':'::text) || dbxref.accession::text AS trait_name
60 JOIN dbxref ON cvterm.dbxref_id = dbxref.dbxref_id
61 JOIN db ON dbxref.db_id = db.db_id
62 WHERE cvterm.cvterm_id IN (SELECT cvterm_relationship.subject_id FROM cvterm_relationship JOIN cvterm on (cvterm_relationship.subject_id = cvterm.cvterm_id) where cvterm_relationship.type_id = (SELECT cvterm_id from cvterm where name = 'VARIABLE_OF') GROUP BY 1)
66 JOIN nd_experiment_stock USING(stock_id)
67 JOIN nd_experiment_phenotype USING(nd_experiment_id)
68 JOIN phenotype USING(phenotype_id)
69 JOIN cvterm ON phenotype.cvalue_id = cvterm.cvterm_id
70 JOIN dbxref ON cvterm.dbxref_id = dbxref.dbxref_id LIMIT 1)
71 GROUP BY public.cvterm.cvterm_id, trait_name
73 CREATE UNIQUE INDEX traits_idx ON public.traits(trait_id) WITH (fillfactor=100);
74 ALTER MATERIALIZED VIEW traits OWNER TO web_usr;
80 print "You're done!\n";