Skip to content

Commit

Permalink
Support fillPlatesOnly
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-nicka committed Jan 9, 2025
1 parent 749daae commit f7cf4c6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
18 changes: 12 additions & 6 deletions assay/src/org/labkey/assay/plate/layout/ArrayOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ public List<WellLayout> execute(ExecutionContext context) throws ValidationExcep
}

List<PlateManager.PlateData> targetPlateData = new ArrayList<>(context.targetPlateData());
boolean hasTargetPlateData = !targetPlateData.isEmpty();
boolean isFillPlatesOnly = context.options().isFillPlatesOnly();
int initialSampleCount = sampleIds.size();

// Plate all samples
while (sampleIndex < sampleIds.size())
{
// If target plates are specified, then require that those plate configurations are enough to plate all
// the samples. Otherwise, when target plates are not specified, generate additional plates.
if (hasTargetPlateData && targetPlateData.isEmpty())
throw new ValidationException(String.format("Only %d of %d samples could be plated with this configuration.", sampleIndex + 1, initialSampleCount));
// If isFillPlatesOnly is true, then require that those target plate configurations are enough to plate all
// the samples. Otherwise, generate additional plates.
if (isFillPlatesOnly && targetPlateData.isEmpty() && targetLayouts.isEmpty())
throw new ValidationException(String.format("%s%d of %d samples could be plated with this configuration.", sampleIndex == 0 ? "" : "Only ", sampleIndex, initialSampleCount));

WellLayout wellLayout = getNextWellLayout(context, targetLayouts, targetPlateData);
if (wellLayout == null)
throw new ValidationException(String.format("Only %d of %d samples could be plated with this configuration.", sampleIndex, sampleIds.size()));
throw new ValidationException(String.format("%s%d of %d samples could be plated with this configuration.", sampleIndex == 0 ? "" : "Only ", sampleIndex, sampleIds.size()));

Pair<Integer, WellLayout> result;

Expand Down Expand Up @@ -461,4 +461,10 @@ public boolean supportsFillExistingWells()
{
return true;
}

@Override
public boolean supportsFillPlatesOnly()
{
return true;
}
}
2 changes: 2 additions & 0 deletions assay/src/org/labkey/assay/plate/layout/LayoutEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public List<WellLayout> run(Container container, User user, WellData.Cache wellD
throw new ValidationException("A target plate template is required for this operation.");
if (_options.isFillExistingWells() && !_operation.supportsFillExistingWells())
throw new ValidationException("Filling existing wells is not supported for this operation.");
if (_options.isFillPlatesOnly() && !_operation.supportsFillPlatesOnly())
throw new ValidationException("Filling plates only is not supported for this operation.");

LayoutOperation.ExecutionContext context = new LayoutOperation.ExecutionContext(
container,
Expand Down
5 changes: 5 additions & 0 deletions assay/src/org/labkey/assay/plate/layout/LayoutOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ default boolean supportsFillExistingWells()
return false;
}

default boolean supportsFillPlatesOnly()
{
return false;
}

record ExecutionContext(
Container container,
User user,
Expand Down
11 changes: 11 additions & 0 deletions assay/src/org/labkey/assay/plate/model/ReformatOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public void setSourceType(SourceType sourceType)
}

private Boolean _fillExistingWells = false;
private Boolean _fillPlatesOnly = false;
private ReformatOperation _operation;
private List<PlateManager.PlateData> _plates;
private List<Integer> _plateRowIds;
Expand All @@ -168,6 +169,16 @@ public ReformatOptions setFillExistingWells(Boolean fillExistingWells)
return this;
}

public Boolean isFillPlatesOnly()
{
return _fillPlatesOnly;
}

public void setFillPlatesOnly(Boolean fillPlatesOnly)
{
_fillPlatesOnly = fillPlatesOnly;
}

public ReformatOperation getOperation()
{
return _operation;
Expand Down

0 comments on commit f7cf4c6

Please sign in to comment.