Skip to content

Multi-Trial Upload: allow crosses #5482

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

Merged
merged 5 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/upload_multiple_trial_design.pl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ =head1 AUTHOR
trial_location => $trial_design->{'location'},
trial_name => $trial_name,
design_type => $trial_design->{'design_type'},
trial_stock_type => $trial_design->{'trial_stock_type'},
design => $trial_design->{'design_details'},
program => $trial_design->{'breeding_program'},
upload_trial_file => $infile,
Expand Down
28 changes: 23 additions & 5 deletions lib/CXGN/Trial/ParseUpload/Plugin/MultipleTrialDesignGeneric.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use CXGN::Calendar;
use CXGN::Trial;

my @REQUIRED_COLUMNS = qw|trial_name breeding_program location year design_type description accession_name plot_number block_number|;
my @OPTIONAL_COLUMNS = qw|plot_name trial_type plot_width plot_length field_size planting_date transplanting_date harvest_date is_a_control rep_number range_number row_number col_number seedlot_name num_seed_per_plot weight_gram_seed_per_plot entry_number|;
my @OPTIONAL_COLUMNS = qw|plot_name trial_type trial_stock_type plot_width plot_length field_size planting_date transplanting_date harvest_date is_a_control rep_number range_number row_number col_number seedlot_name num_seed_per_plot weight_gram_seed_per_plot entry_number|;
# Any additional columns that are not required or optional will be used as a treatment

# VALID DESIGN TYPES
Expand All @@ -33,6 +33,13 @@ my %valid_design_types = (
"Analysis" => 1
);

# VALID STOCK TYPES
my %valid_stock_types = (
"accession" => 1,
"cross" => 1,
"family_name" => 1
);

sub _validate_with_plugin {
my $self = shift;
my $filename = $self->get_filename();
Expand All @@ -56,7 +63,10 @@ sub _validate_with_plugin {
my $parser = CXGN::File::Parse->new(
file => $filename,
required_columns => \@REQUIRED_COLUMNS,
optional_columns => \@OPTIONAL_COLUMNS
optional_columns => \@OPTIONAL_COLUMNS,
column_aliases => {
'accession_name' => [ 'stock_name', 'cross_unique_id', 'family_name' ]
}
);
my $parsed = $parser->parse();
my $parsed_errors = $parsed->{'errors'};
Expand Down Expand Up @@ -339,9 +349,17 @@ sub _validate_with_plugin {
}
}

# Trial Stock Type: must be a valid / supported trial stock type
foreach (@{$parsed_values->{'trial_stock_type'}}) {
if ( !exists $valid_stock_types{$_} ) {
push @error_messages, "trial_stock_type <strong>$_</strong> is not supported. Supported trial stock types: " . join(', ', keys(%valid_stock_types)) . ".";
}
}

# Accession Names: must exist in the database
my @accessions = @{$parsed_values->{'accession_name'}};
my $accessions_hashref = $validator->validate($schema,'accessions',\@accessions);
my @multiple_synonyms = @{$accessions_hashref->{'multiple_synonyms'}};

#find unique synonyms. Sometimes trial uploads use synonym names instead of the unique accession name. We allow this if the synonym is unique and matches one accession in the database
my @synonyms = @{$accessions_hashref->{'synonyms'}};
Expand All @@ -356,12 +374,11 @@ sub _validate_with_plugin {
}

#now validate again the accession names
$accessions_hashref = $validator->validate($schema,'accessions',\@accessions);
$accessions_hashref = $validator->validate($schema,'accessions_or_crosses_or_familynames',\@accessions);
my @accessions_missing = @{$accessions_hashref->{'missing'}};
my @multiple_synonyms = @{$accessions_hashref->{'multiple_synonyms'}};

if (scalar(@accessions_missing) > 0) {
push @error_messages, "Accession(s) <strong>".join(',',@accessions_missing)."</strong> are not in the database as uniquenames or synonyms.";
push @error_messages, "Stocks(s) <strong>".join(',',@accessions_missing)."</strong> are not in the database as uniquenames or synonyms of accessions, crosses, or families.";
}
if (scalar(@multiple_synonyms) > 0) {
my @msgs;
Expand Down Expand Up @@ -554,6 +571,7 @@ sub _parse_with_plugin {
$single_design{'year'} = $row->{'year'};
$single_design{'design_type'} = $row->{'design_type'};
$single_design{'description'} = $row->{'description'};
$single_design{'trial_stock_type'} = $row->{'trial_stock_type'} || 'accession';
$single_design{'plot_width'} = $row->{'plot_width'};
$single_design{'plot_length'} = $row->{'plot_length'};
$single_design{'field_size'} = $row->{'field_size'};
Expand Down
6 changes: 4 additions & 2 deletions mason/breeders_toolbox/trial/trial_upload_dialogs.mas
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ $design_types => ()
<td>design_type</td>
<td>description</td>
<td>trial_type</td>
<td>trial_stock_type</td>
<td>plot_width</td>
<td>plot_length</td>
<td>field_size</td>
Expand All @@ -769,7 +770,7 @@ $design_types => ()
</table>

<b>Header as a string:</b><br/>
<p>trial_name,breeding_program,location,year,transplanting_date,design_type,description,trial_type,plot_width,plot_length,field_size,planting_date,harvest_date,plot_name,accession_name,plot_number,block_number,is_a_control,rep_number,range_number,row_number,col_number,seedlot_name,num_seed_per_plot,weight_gram_seed_per_plot,entry_number</p>
<p>trial_name,breeding_program,location,year,transplanting_date,design_type,description,trial_type,trial_stock_type,plot_width,plot_length,field_size,planting_date,harvest_date,plot_name,accession_name,plot_number,block_number,is_a_control,rep_number,range_number,row_number,col_number,seedlot_name,num_seed_per_plot,weight_gram_seed_per_plot,entry_number</p>

<b> Required fields:</b>
<ul>
Expand All @@ -780,7 +781,7 @@ $design_types => ()

<li>design_type (The shorthand for the design type, must exist in the database. Possible values include CRD (Completely Randomized Design), RCBD (Randomized Complete Block Design), RRC (Resolvable Row-Column), DRRC (Doubly-Resolvable Row-Column), ARC (Augmented Row-Column), Alpha (Alpha Lattice Design), Lattice (Lattice Design), Augmented (Augmented Design), MAD (Modified Augmented Design), greenhouse (undesigned Nursery/Greenhouse), splitplot (Split Plot), stripplot (Strip Plot / Split Block), p-rep (Partially Replicated), Westcott (Westcott Design))</li>
<li>description (Additional text with any other relevant information about the trial.)</li>
<li>accession_name (The accession being tested in the plot, must exist in the database.)</li>
<li>accession_name OR cross_unique_id OR family_name (The accession, cross, or family being tested in the plot, must exist in the database.)</li>
<li>plot_number (A sequential number for the plot in the field (e.g. 1001, 1002, 2001, 2002). These numbers should be unique for the trial.)</li>
<li>block_number (A design parameter indicating which block the plot is in.)</li>
</ul>
Expand All @@ -789,6 +790,7 @@ $design_types => ()
<ul>
<li>plot_name (Must be unique across entire database. If not provided in the file, it will be automatically generated as <code>{trial_name}-PLOT_{plot_number}</code>)</li>
<li>trial_type (The name of the trial type, must exist in the database. Possible values include Seedling Nursery, phenotyping_trial, Advanced Yield Trial, Preliminary Yield Trial, Uniform Yield Trial, Variety Release Trial, Clonal Evaluation, genetic_gain_trial, storage_trial, heterosis_trial, health_status_trial, grafting_trial, Screen House, Seed Multiplication, crossing_block_trial, Specialty Trial)</li>
<li>trial_stock_type (The type of stocks that are being evaluated in the trial. Can be either 'accession', 'cross', or 'family_name'. When not provided, 'accession' is used as the default)
<li>plot_width (plot width in meters)</li>
<li>plot_length (plot length in meters)</li>
<li>field_size (field size in hectares)</li>
Expand Down
12 changes: 8 additions & 4 deletions t/selenium2/breeders/upload_multi_trial_file.t
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ for my $extension ("xlsx", "xls", "csv") {
'trial_type' => 76515,
'breeding_program' => 'test',
'plot_width' => '5',
'field_size' => '8'
'field_size' => '8',
'trial_stock_type' => 'accession'
},
'199275HBEPR_stom' => {
'breeding_program' => 'test',
Expand Down Expand Up @@ -227,7 +228,8 @@ for my $extension ("xlsx", "xls", "csv") {
'year' => '1999',
'planting_date' => '1992-09-19',
'plot_length' => '5',
'design_type' => 'Augmented'
'design_type' => 'Augmented',
'trial_stock_type' => 'accession'
},
'199934HBEPR_cara' => {
'description' => 'EPR',
Expand Down Expand Up @@ -298,7 +300,8 @@ for my $extension ("xlsx", "xls", "csv") {
'design_type' => 'Augmented',
'plot_length' => '5',
'harvest_date' => '2000-03-14',
'year' => '1999'
'year' => '1999',
'trial_stock_type' => 'accession'
},
'199947HBEPR_mora' => {
'year' => '1999',
Expand Down Expand Up @@ -369,7 +372,8 @@ for my $extension ("xlsx", "xls", "csv") {
},
'location' => 'test_location',
'trial_type' => 76515,
'description' => 'EPR'
'description' => 'EPR',
'trial_stock_type' => 'accession'
}
};

Expand Down