Skip to content

Commit

Permalink
Revert "Revert "Merge branch 'master' into topic/genotype_marker_load…
Browse files Browse the repository at this point in the history
…ing""

This reverts commit 8db90bc.
  • Loading branch information
isaak committed Aug 24, 2023
1 parent e5f2343 commit eef7673
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 9 deletions.
21 changes: 20 additions & 1 deletion lib/CXGN/Genotype/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,15 @@ sub get_cached_file_VCF {
#Get all marker information for the protocol(s) requested. this is important if they are requesting subsets of markers or if they are querying more than one protocol at once. Also important for ordering VCF output. Old genotypes did not have protocolprop marker info so markers are taken from first genotypeprop return below.
my @all_marker_objects;
my %unique_germplasm;
my @protocol_names;

if (!$protocol_ids->[0]) {
if ($self->markerprofile_id_list()) {
my $protocol_id = $self->get_protocol_id_from_genotype_id($self->markerprofile_id_list());
push @$protocol_ids, $protocol_id;
}
}

foreach (@$protocol_ids) {
my $protocol = CXGN::Genotype::Protocol->new({
bcs_schema => $self->bcs_schema,
Expand All @@ -1626,9 +1635,14 @@ sub get_cached_file_VCF {
my $markers = $protocol->markers;
push @all_protocol_info_lines, @{$protocol->header_information_lines};
push @all_marker_objects, values %$markers;
push @protocol_names, $protocol->protocol_name();
}


push @all_protocol_info_lines, "##source=FILE GENERATED BY BREEDBASE";
push @all_protocol_info_lines, "##fileDate=$timestamp";
push @all_protocol_info_lines, "##Genotyping protocol id(s)=@$protocol_ids";
push @all_protocol_info_lines, "##Genotyping protocol name(s)=@protocol_names";

foreach (@all_marker_objects) {
$self->_filtered_markers()->{$_->{name}}++;
Expand Down Expand Up @@ -1959,9 +1973,13 @@ sub get_cached_file_VCF_compute_from_parents {
});
my $markers = $protocol->markers;
my @all_marker_objects = values %$markers;
my $protocol_name = $protocol->protocol_name();

push @all_protocol_info_lines, @{$protocol->header_information_lines};
push @all_protocol_info_lines, "##source=FILE GENERATED BY BREEDBASE";
push @all_protocol_info_lines, "##source=FILE GENERATED BY BREEDBASE";
push @all_protocol_info_lines, "##fileDate=$timestamp";
push @all_protocol_info_lines, "##Genotyping protocol id=$protocol_id";
push @all_protocol_info_lines, "##Protocol name=$protocol_name";

foreach (@all_marker_objects) {
$self->_filtered_markers()->{$_->{name}}++;
Expand Down Expand Up @@ -2265,4 +2283,5 @@ sub search_vcf_genotyping_cvterm_id {
return $vcf_genotyping_cvterm_id;

}

1;
4 changes: 2 additions & 2 deletions lib/CXGN/Trial/ParseUpload/Plugin/GenotypeTrialXLS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ sub _validate_with_plugin {
}
}
#tissue_type must not be blank and must be either leaf, root, or step
if (!$tissue_type || $tissue_type eq '' || ($tissue_type ne 'leaf' && $tissue_type ne 'root' && $tissue_type ne 'stem')) {
push @error_messages, "Cell E$row_name: column tissue type and must be either stem, leaf, or root";
if (!$tissue_type || $tissue_type eq '' || ($tissue_type ne 'leaf' && $tissue_type ne 'root' && $tissue_type ne 'stem' && $tissue_type ne 'seed')) {
push @error_messages, "Cell E$row_name: column tissue type and must be either stem, leaf, root or seed";
}

if ($include_facility_identifiers) {
Expand Down
148 changes: 143 additions & 5 deletions lib/SGN/Controller/AJAX/LabelDesigner.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,61 @@ my %ADDITIONAL_LIST_DATA = (
for my $index (0 .. $#$list_item_ids ) {
$values{$list_item_ids->[$index]} = $list_item_db_ids->[$index];
}
return \%values;
},

'accession pedigree' => sub {
my ($c, $schema, $dbh, $list_id, $list_item_ids, $list_item_names, $list_item_db_ids) = @_;
my %values;
my $accession_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, "accession", "stock_type")->cvterm_id();
my $mother_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'female_parent', 'stock_relationship')->cvterm_id();
my $father_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'male_parent', 'stock_relationship')->cvterm_id();

foreach my $stock_id ( @$list_item_db_ids) {

# Get the pedigree of the stock
my $prs = $schema->resultset("Stock::StockRelationship")->search([
{
'me.object_id' => $stock_id,
'me.type_id' => $father_type_id,
'subject.type_id'=> $accession_type_id
},
{
'me.object_id' => $stock_id,
'me.type_id' => $mother_type_id,
'subject.type_id'=> $accession_type_id
}
], {
'join' => 'subject',
'+select' => ['subject.uniquename'],
'+as' => ['subject_uniquename']
});

# Retrieve the names of the parents
my $parents = {};
while ( my $p = $prs->next() ) {
if ( $p->type_id == $mother_type_id ) {
$parents->{'mother'} = $p->get_column('subject_uniquename');
}
else {
$parents->{'father'} = $p->get_column('subject_uniquename');
}
}

# Build pedigree string
my $pedigree = 'NA/NA';
if ( $parents->{'mother'} && $parents->{'father'} ) {
$pedigree = $parents->{'mother'} . '/' . $parents->{'father'};
}

# Add pedigree to return hash
for my $index (0 .. $#$list_item_db_ids ) {
if ( $list_item_db_ids->[$index] eq $stock_id ) {
$values{$list_item_ids->[$index]} = $pedigree;
}
}
}

return \%values;
}

Expand Down Expand Up @@ -99,6 +154,75 @@ my %ADDITIONAL_LIST_DATA = (
return \%values;
},

'seedlot contents pedigree' => sub {
my ($c, $schema, $dbh, $list_id, $list_item_ids, $list_item_names, $list_item_db_ids) = @_;
my %values;
my $type_id = SGN::Model::Cvterm->get_cvterm_row($schema, "collection_of", "stock_relationship")->cvterm_id();
my $accession_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, "accession", "stock_type")->cvterm_id();
my $mother_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'female_parent', 'stock_relationship')->cvterm_id();
my $father_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'male_parent', 'stock_relationship')->cvterm_id();
my $cross_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, "cross", "stock_type")->cvterm_id();

# Get the stock ids of the seedlot contents
my $rs = $schema->resultset("Stock::StockRelationship")->search({
'me.object_id' => { in => $list_item_db_ids },
'me.type_id' => $type_id,
'subject.type_id' => { in => [$accession_type_id, $cross_type_id] }
}, {
'join' => 'subject',
'+select' => ['subject.uniquename', 'subject.stock_id'],
'+as' => ['subject_uniquename', 'subject_stockid']
});
while ( my $row = $rs->next() ) {
my $seedlot_id = $row->object_id();
my $stock_id = $row->get_column('subject_stockid');

# Get the pedigree of the contents
my $prs = $schema->resultset("Stock::StockRelationship")->search([
{
'me.object_id' => $stock_id,
'me.type_id' => $father_type_id,
'subject.type_id'=> $accession_type_id
},
{
'me.object_id' => $stock_id,
'me.type_id' => $mother_type_id,
'subject.type_id'=> $accession_type_id
}
], {
'join' => 'subject',
'+select' => ['subject.uniquename'],
'+as' => ['subject_uniquename']
});

# Retrieve the names of the parents
my $parents = {};
while ( my $p = $prs->next() ) {
if ( $p->type_id == $mother_type_id ) {
$parents->{'mother'} = $p->get_column('subject_uniquename');
}
else {
$parents->{'father'} = $p->get_column('subject_uniquename');
}
}

# Build pedigree string
my $pedigree = 'NA/NA';
if ( $parents->{'mother'} && $parents->{'father'} ) {
$pedigree = $parents->{'mother'} . '/' . $parents->{'father'};
}

# Add pedigree to return hash
for my $index (0 .. $#$list_item_db_ids ) {
if ( $list_item_db_ids->[$index] eq $seedlot_id ) {
$values{$list_item_ids->[$index]} = $pedigree;
}
}
}

return \%values;
},

'seedlot box' => sub {
my ($c, $schema, $dbh, $list_id, $list_item_ids, $list_item_names, $list_item_db_ids) = @_;
my %values;
Expand Down Expand Up @@ -193,13 +317,27 @@ __PACKAGE__->config(

# Get additional list data for just the longest item
if ( $data_type eq 'Lists' ) {
my $additional_list_data = get_additional_list_data($c, $source_id, $longest_hash{'list_item_id'}, $longest_hash{'list_item_name'});
my %longest_additional_list_data;
my $additional_list_data = get_additional_list_data($c, $source_id);
if ( $additional_list_data ) {
my $fields = $additional_list_data->{$longest_hash{'list_item_id'}};
if ( (ref($fields) eq "HASH") && (keys(%$fields) > 0) ) {
%longest_hash = (%longest_hash, %$fields);
}
foreach my $key ( keys(%$additional_list_data) ) {
my $fields = $additional_list_data->{$key};
if ( (ref($fields) eq "HASH") && (keys(%$fields) > 0) ) {
foreach my $field_name ( keys(%$fields) ) {
my $field_value = $fields->{$field_name};
if (exists $longest_additional_list_data{$field_name} ) {
if ( length($field_value) > length($longest_additional_list_data{$field_name}) ) {
$longest_additional_list_data{$field_name} = $field_value;
}
}
else {
$longest_additional_list_data{$field_name} = $field_value;
}
}
}
}
}
%longest_hash = (%longest_hash, %longest_additional_list_data);
}

$c->stash->{rest} = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ $facilities => ();
<option value="leaf">Leaf</option>
<option value="root">Root</option>
<option value="stem">Stem</option>
<option value="seed">Seed</option>
</select>
</div>
</div>
Expand Down Expand Up @@ -389,7 +390,7 @@ $facilities => ();
<li>row (the row position of the sample in the plate e.g. A)</li>
<li>column (the column position of the sample in the plate e.g. 10)</li>
<li>source_observation_unit_name (must exist in the database. the identifier of the origin material. in order of most desirable identifier to least desirable identifier that can be used here: tissue sample name, plant name, plot name, accession name. For blank wells, you can write BLANK here and place a 1 in the is_blank column also.)</li>
<li>tissue_type (must be either leaf, root, or stem)</li>
<li>tissue_type (must be either leaf, root, stem or seed)</li>
</ul>

<b>Optional fields:</b>
Expand Down
1 change: 1 addition & 0 deletions mason/tools/label_designer/design_label.mas
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div class="text-center">
<p>Time to design! Start by selecting a type and field. Then click 'add' to generate your new label element in the draw area.</p>
<p>Add, drag, customize, resize, and delete as many elements as you like. A barcode containing your unique identifier (plot_name, plant_name, etc) is strongly recommended.</p>
<p><em><strong>NOTE:</strong> The property values displayed here in the design tool may not be from the same plot, list item, etc. The longest value is displayed here to aid in the positioning and sizing of the element. The values will be correctly associated when all of the labels are printed in the next step.</em></p>
</div>
</br>
<div class="col-md-12" id="d3-draw-div" style="margin-bottom:20px;">
Expand Down

0 comments on commit eef7673

Please sign in to comment.