Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable photo traits with brapi #5162

Merged
merged 9 commits into from
Oct 24, 2024
12 changes: 7 additions & 5 deletions lib/CXGN/BrAPI/v2/Scales.pm
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,17 @@ sub _format_data_type {
if ($value) {
my %formats = (
"categorical" => "Ordinal",
"numeric" => "Numerical",
"qualitative" => "Nominal",
"numerical" => "Numerical",
"nominal" => "Nominal",
"numeric" => "Numerical",
"qualitative" => "Nominal",
"numerical" => "Numerical",
"nominal" => "Nominal",
"code" => "Code",
"date" => "Date" ,
"duration" => "Duration",
"ordinal" => "Ordinal",
"text"=> "Text",
"text" => "Text",
"photo" => "Photo",
"multicat" => "Multicat",
);

$dataType = $formats{lc $value} ? $formats{lc $value} : $dataType;
Expand Down
25 changes: 18 additions & 7 deletions lib/CXGN/Cvterm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ has 'accession' => (
is => 'rw',
);


has 'is_variable' => (
isa => 'Bool',
is => 'rw',
default => sub { return 0; },
);

#########################################

Expand All @@ -149,6 +153,19 @@ sub BUILD {
my $cvterm;
if ($self->cvterm_id){
$cvterm = $self->schema()->resultset("Cv::Cvterm")->find({ cvterm_id => $self->cvterm_id() });

if ($cvterm) {
my $cvterm_rel_rs = $self->schema()->resultset("Cv::CvtermRelationship")->search( { subject_id => $self->cvterm_id });
# require at least one parent to have a variable_of type
#
while (my $row = $cvterm_rel_rs->next()) {
#print STDERR "ROW TYPE: ".$row->type()->name()."\n";
if (uc($row->type()->name) eq uc('variable_of')) {
$self->is_variable(1);
}
}

}
} elsif ($self->accession ) {
my ($db_name, $dbxref_accession) = split "\:", $self->accession;

Expand Down Expand Up @@ -185,12 +202,6 @@ sub BUILD {
return $self;
}







=head2 function get_image_ids

Synopsis: my @images = $self->get_image_ids()
Expand Down
17 changes: 9 additions & 8 deletions lib/SGN/Controller/Cvterm.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

package SGN::Controller::Cvterm;

use CXGN::Chado::Cvterm; #DEPRECATE this !!
#use CXGN::Chado::Cvterm; #DEPRECATE this !!
use CXGN::Cvterm;

use Moose;
Expand Down Expand Up @@ -35,13 +35,14 @@ sub view_cvterm : Chained('get_cvterm') PathPart('view') Args(0) {
my $cvterm_id = $cvterm ? $cvterm->cvterm_id : undef ;

my $bcs_cvterm = $cvterm->cvterm;


my ($person_id, $user_role, $curator, $submitter, $sequencer);
my $logged_user = $c->user;
my $person_id = $logged_user->get_object->get_sp_person_id if $logged_user;
my $user_role = 1 if $logged_user;
my $curator = $logged_user->check_roles('curator') if $logged_user;
my $submitter = $logged_user->check_roles('submitter') if $logged_user;
my $sequencer = $logged_user->check_roles('sequencer') if $logged_user;
$person_id = $logged_user->get_object->get_sp_person_id if $logged_user;
$user_role = 1 if $logged_user;
$curator = $logged_user->check_roles('curator') if $logged_user;
$submitter = $logged_user->check_roles('submitter') if $logged_user;
$sequencer = $logged_user->check_roles('sequencer') if $logged_user;
my $props = $self->_cvtermprops($cvterm);
my $editable_cvterm_props = "trait_format,trait_default_value,trait_minimum,trait_maximum,trait_details,trait_categories";

Expand Down Expand Up @@ -99,7 +100,7 @@ sub _cvtermprops {
my $properties ;
if ($cvterm) {
my $bcs_cvterm = $cvterm->cvterm;
if (!$bcs_cvterm) { return undef ; }
if (!$bcs_cvterm) { return; }
my $cvtermprops = $bcs_cvterm->search_related("cvtermprops");
while ( my $prop = $cvtermprops->next ) {
push @{ $properties->{$prop->type->name} } , $prop->value ;
Expand Down
12 changes: 9 additions & 3 deletions mason/chado/cvterm.mas
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ my $db_name = $cvterm->db->name;
my $accession = $cvterm->accession;
my $cvterm_name = $cvterm->name;
my $definition = $cvterm->definition;
my $is_variable = $cvterm->is_variable;
my $comment = '' ;#$cvterm->comment;
#$stockref->{props} (hash of arrayrefs of cvtermprops. Keys = prop name, value = prop value)
my $editable_cvterm_props_string = $cvtermref->{editable_cvterm_props};
Expand Down Expand Up @@ -165,7 +166,8 @@ my $edit_privs = $curator ;

% my $props_subtitle = $edit_privs ? "[<a id=\"cvterm_add_props\" href=\"javascript:cvtermprops_addPropDialog()\">Add...</a>]" : "[Add]";

<&| /page/info_section.mas, title => "Trait Properties" , collapsible=> 1, is_subsection => 1, subtitle=>$props_subtitle &>
% if ($is_variable) {
<&| /page/info_section.mas, title => "Variable Properties" , collapsible=> 1, is_subsection => 1, subtitle=>$props_subtitle &>
<& /chado/cvtermprops.mas,
cv_name => 'trait_property',
cvterm_id =>$cvterm_id,
Expand All @@ -176,11 +178,15 @@ my $edit_privs = $curator ;
editable => \@editable_cvterm_props &>
</&>

<h4>Add this term to a list</h4>
% }
% else {


%}

<div id="cvterm_id" style="display:none" ><% $cvterm_name %>|<% $accession %></div>

<&| /page/info_section.mas, title=>"Add to list", collapsible=>1, collapsed=>1 &>
<&| /page/info_section.mas, title=>"Add this term to a list", collapsible=>1, collapsed=>1 &>
<div id="paste_to_list">
LOAD...
</div>
Expand Down