2 package SGN
::Controller
::Ontology
;
4 use CXGN
::Chado
::Cvterm
;
5 use CXGN
::People
::Roles
;
6 use URI
::FromHash
'uri';
7 use CXGN
::Page
::FormattingHelpers qw
| simple_selectbox_html
|;
13 BEGIN { extends
'Catalyst::Controller' };
14 with
'Catalyst::Component::ApplicationAttribute';
17 sub onto_browser
: Path
('/tools/onto') :Args
(0) {
21 my $root_nodes = $c->config->{onto_root_namespaces
};
22 my @namespaces = split ",", $root_nodes;
23 foreach my $n (@namespaces) {
24 $n =~ s/\s*(\w+)\s*\(.*\)/$1/g;
25 print STDERR
"Adding node $n\n";
27 #$c->stash->{root_nodes} = $c->req->param("root_nodes");
28 $c->stash->{root_nodes
} = join " ", @namespaces;
29 $c->stash->{db_name
} = $c->req->param("db_name");
30 $c->stash->{expand
} = $c->req->param("expand");
32 $c->stash->{template
} = '/ontology/standalone.mas';
36 sub compose_trait
: Path
('/tools/compose') :Args
(0) {
41 # redirect to login page
42 $c->res->redirect( uri
( path
=> '/solpeople/login.pl', query
=> { goto_url
=> $c->req->uri->path_query } ) );
46 my @composable_cvs = split ",", $c->config->{composable_cvs
};
47 my $dbh = $c->dbc->dbh();
48 my $onto = CXGN
::Onto
->new( { schema
=> $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado') } );
50 foreach my $name (@composable_cvs) {
51 $name =~ s/^\s+|\s+$//g; # remove whitespace
52 if ($name eq 'time' || $name eq 'tod' || $name eq 'toy' || $name eq 'gen' ) {
53 print STDERR
"Skipping time-related cv\n";
56 my $cv_type = $name."_ontology";
57 #print STDERR "cv_type = $cv_type\n";
60 my @root_nodes = $onto->get_root_nodes($cv_type);
61 #print STDERR Dumper \@root_nodes;
62 if (scalar @root_nodes > 1) {
63 #create simple selectbox of root_nodes
64 my $id = $name."_root_select";
65 my $name = $name."_root_select";
66 my $html = simple_selectbox_html
(
69 choices
=> \
@root_nodes,
71 default => 'Pick an Ontology'
74 $html_hash{$cv_type} = $html;
77 my $cv_id = $root_nodes[0][0];
78 my @components = $onto->get_terms($cv_id);
80 my $id = $name."_select";
81 my $name = $name."_select";
83 if ($default) { unshift @components, [ '', $default ]; }
85 my $html = simple_selectbox_html
(
89 choices
=> \
@components,
93 $html_hash{$cv_type} = $html;
97 $c->stash->{object_select
} = $html_hash{'object_ontology'};
98 $c->stash->{attribute_select
} = $html_hash{'attribute_ontology'};
99 $c->stash->{method_select
} = $html_hash{'method_ontology'};
100 $c->stash->{unit_select
} = $html_hash{'unit_ontology'};
101 $c->stash->{trait_select
} = $html_hash{'trait_ontology'};
103 $c->stash->{composable_cvs
} = $c->config->{composable_cvs
};
104 $c->stash->{composable_cvs_allowed_combinations
} = $c->config->{composable_cvs_allowed_combinations
};
105 $c->stash->{composable_tod_root_cvterm
} = $c->config->{composable_tod_root_cvterm
};
106 $c->stash->{composable_toy_root_cvterm
} = $c->config->{composable_toy_root_cvterm
};
107 $c->stash->{composable_gen_root_cvterm
} = $c->config->{composable_gen_root_cvterm
};
109 $c->stash->{user
} = $c->user();
110 $c->stash->{template
} = '/ontology/compose_trait.mas';