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
=> '/user/login', 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 $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
49 my $onto = CXGN
::Onto
->new( { schema
=> $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id) } );
51 foreach my $name (@composable_cvs) {
52 $name =~ s/^\s+|\s+$//g; # remove whitespace
53 if ($name eq 'time' || $name eq 'tod' || $name eq 'toy' || $name eq 'gen' || $name eq 'evt' ) {
54 print STDERR
"Skipping time-related cv\n";
57 my $cv_type = $name."_ontology";
58 #print STDERR "cv_type = $cv_type\n";
61 my @root_nodes = $onto->get_root_nodes($cv_type);
62 #print STDERR Dumper \@root_nodes;
63 if (scalar @root_nodes > 1) {
64 #create simple selectbox of root_nodes
65 my $id = $name."_root_select";
66 my $name = $name."_root_select";
67 my $html = simple_selectbox_html
(
70 choices
=> \
@root_nodes,
72 default => 'Pick an Ontology'
75 $html_hash{$cv_type} = $html;
78 my $cv_id = $root_nodes[0][0];
79 my @components = $onto->get_terms($cv_id);
81 my $id = $name."_select";
82 my $name = $name."_select";
84 if ($default) { unshift @components, [ '', $default ]; }
86 my $html = simple_selectbox_html
(
90 choices
=> \
@components,
94 $html_hash{$cv_type} = $html;
98 $c->stash->{object_select
} = $html_hash{'object_ontology'};
99 $c->stash->{attribute_select
} = $html_hash{'attribute_ontology'};
100 $c->stash->{method_select
} = $html_hash{'method_ontology'};
101 $c->stash->{unit_select
} = $html_hash{'unit_ontology'};
102 $c->stash->{trait_select
} = $html_hash{'trait_ontology'};
104 $c->stash->{composable_cvs
} = $c->config->{composable_cvs
};
105 $c->stash->{composable_cvs_allowed_combinations
} = $c->config->{composable_cvs_allowed_combinations
};
106 $c->stash->{composable_tod_root_cvterm
} = $c->config->{composable_tod_root_cvterm
};
107 $c->stash->{composable_toy_root_cvterm
} = $c->config->{composable_toy_root_cvterm
};
108 $c->stash->{composable_gen_root_cvterm
} = $c->config->{composable_gen_root_cvterm
};
109 $c->stash->{composable_evt_root_cvterm
} = $c->config->{composable_evt_root_cvterm
};
111 $c->stash->{user
} = $c->user();
112 $c->stash->{template
} = '/ontology/compose_trait.mas';