Skip to content
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
6 changes: 3 additions & 3 deletions elisa/src/org/labkey/elisa/AbstractElisaImportHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import org.labkey.api.exp.api.ProvenanceService;
import org.labkey.api.exp.property.Domain;
import org.labkey.api.exp.property.DomainProperty;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -26,11 +26,11 @@ public abstract class AbstractElisaImportHelper implements ElisaImportHelper
protected AssayUploadXarContext _context;
protected PlateBasedAssayProvider _provider;
protected ExpProtocol _protocol;
protected File _dataFile;
protected FileLike _dataFile;
protected Container _container;
Map<Position, String> _specimenGroupMap;

public AbstractElisaImportHelper(AssayUploadXarContext context, PlateBasedAssayProvider provider, ExpProtocol protocol, File dataFile)
public AbstractElisaImportHelper(AssayUploadXarContext context, PlateBasedAssayProvider provider, ExpProtocol protocol, FileLike dataFile)
{
_context = context;
_provider = provider;
Expand Down
12 changes: 6 additions & 6 deletions elisa/src/org/labkey/elisa/ElisaDataHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected boolean shouldAddInputMaterials()
return true;
}

private ElisaImportHelper getImportHelper(AssayUploadXarContext context, PlateBasedAssayProvider provider, ExpProtocol protocol, File dataFile) throws ExperimentException
private ElisaImportHelper getImportHelper(AssayUploadXarContext context, PlateBasedAssayProvider provider, ExpProtocol protocol, FileLike dataFile) throws ExperimentException
{
if (provider.getMetadataInputFormat(protocol).equals(SampleMetadataInputFormat.MANUAL))
{
Expand Down Expand Up @@ -135,7 +135,7 @@ public Map<DataType, DataIteratorBuilder> getValidationDataMap(ExpData data, Fil
Map<String, DomainProperty> sampleProperties = plateProvider.getSampleWellGroupDomain(protocol)
.getProperties().stream()
.collect(Collectors.toMap(DomainProperty::getName, dp -> dp));
ElisaImportHelper importHelper = getImportHelper(xarContext, plateProvider, protocol, dataFile.toNioPathForRead().toFile());
ElisaImportHelper importHelper = getImportHelper(xarContext, plateProvider, protocol, dataFile);

for (String plateName : importHelper.getPlates())
{
Expand All @@ -148,7 +148,7 @@ public Map<DataType, DataIteratorBuilder> getValidationDataMap(ExpData data, Fil
SimpleRegression regression = new SimpleRegression(true);
Map<String, Double> standardConcentrations = importHelper.getStandardConcentrations(plateName, analytePlateEntry.getKey());

CurveFit standardCurve = calculateStandardCurve(run, plate, regression, standardConcentrations, runDomain);
CurveFit<?> standardCurve = calculateStandardCurve(run, plate, regression, standardConcentrations, runDomain);
if (standardCurve != null && standardCurve.getParameters() == null)
throw new ExperimentException("Unable to fit the standard concentrations to a curve, please check the input data and try again");

Expand Down Expand Up @@ -321,7 +321,7 @@ private boolean isRowEmptyOrNull(Map<String, Object> row)
* data and can be used to generate an R squared value.
*/
@Nullable
private CurveFit calculateStandardCurve(ExpRun run, Plate plate, @Nullable SimpleRegression regression, Map<String, Double> standardConcentrations,
private CurveFit<?> calculateStandardCurve(ExpRun run, Plate plate, @Nullable SimpleRegression regression, Map<String, Double> standardConcentrations,
Domain runDomain) throws ExperimentException
{
// compute the calibration curve, there could be multiple control groups but one contains the standards
Expand All @@ -333,7 +333,7 @@ private CurveFit calculateStandardCurve(ExpRun run, Plate plate, @Nullable Simpl

for (WellGroup replicate : stdWellGroup.getOverlappingGroups(WellGroup.Type.REPLICATE))
{
maxValue = replicate.getMean() > maxValue ? replicate.getMean() : maxValue;
maxValue = Math.max(replicate.getMean(), maxValue);
}

for (WellGroup replicate : stdWellGroup.getOverlappingGroups(WellGroup.Type.REPLICATE))
Expand All @@ -358,7 +358,7 @@ private CurveFit calculateStandardCurve(ExpRun run, Plate plate, @Nullable Simpl

// Compute curve fit parameters based on the selected curve fit (default to linear for legacy assay designs)
StatsService.CurveFitType curveFitType = ElisaManager.getRunCurveFitType(runDomain, run);
CurveFit curveFit = StatsService.get().getCurveFit(curveFitType, points.toArray(DoublePoint[]::new));
CurveFit<?> curveFit = StatsService.get().getCurveFit(curveFitType, points.toArray(DoublePoint[]::new));
curveFit.setLogXScale(false);
curveFit.setAssumeCurveDecreasing(false);

Expand Down
9 changes: 6 additions & 3 deletions elisa/src/org/labkey/elisa/ElisaSampleFilePropertyHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
import org.labkey.api.study.assay.SampleMetadataInputFormat;

import jakarta.servlet.http.HttpServletRequest;
import java.io.File;
import org.labkey.vfs.FileLike;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
Expand All @@ -41,13 +43,14 @@ public Map<String, Map<DomainProperty, String>> getSampleProperties(HttpServletR
if (_sampleProperties != null)
return _sampleProperties;

File metadataFile = getSampleMetadata(request);
FileLike metadataFile = getSampleMetadata(request);
if (metadataFile == null)
throw new ExperimentException("No metadata or data file provided");

Map<String, Map<DomainProperty, String>> allProperties = new HashMap<>();
DataLoaderFactory factory = DataLoaderService.get().findFactory(metadataFile, null);
try (DataLoader loader = factory.createLoader(metadataFile, true))
try (InputStream in = metadataFile.openInputStream();
DataLoader loader = factory.createLoader(in, true))
{
validateRequiredColumns(loader.getColumns());

Expand Down
8 changes: 5 additions & 3 deletions elisa/src/org/labkey/elisa/HighThroughputImportHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import org.labkey.api.reader.DataLoader;
import org.labkey.api.reader.DataLoaderFactory;
import org.labkey.api.reader.DataLoaderService;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand All @@ -37,7 +38,7 @@ public class HighThroughputImportHelper extends AbstractElisaImportHelper
private final Map<String, AnalytePlate> _plateMap = new HashMap<>();
private Plate _plateTemplate;

public HighThroughputImportHelper(AssayUploadXarContext context, PlateBasedAssayProvider provider, ExpProtocol protocol, File dataFile) throws ExperimentException
public HighThroughputImportHelper(AssayUploadXarContext context, PlateBasedAssayProvider provider, ExpProtocol protocol, FileLike dataFile) throws ExperimentException
{
super(context, provider, protocol, dataFile);
ensureData();
Expand All @@ -47,7 +48,8 @@ private void ensureData() throws ExperimentException
{
_plateTemplate = _provider.getPlate(_protocol.getContainer(), _protocol);
DataLoaderFactory factory = DataLoaderService.get().findFactory(_dataFile, null);
try (DataLoader loader = factory.createLoader(_dataFile, true))
try (InputStream in = _dataFile.openInputStream();
DataLoader loader = factory.createLoader(in, true))
{
String signalColumnName = "Signal";

Expand Down
3 changes: 2 additions & 1 deletion elisa/src/org/labkey/elisa/ManualImportHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.labkey.api.exp.property.DomainProperty;
import org.labkey.elisa.actions.ElisaRunUploadForm;
import org.labkey.elisa.plate.BioTekPlateReader;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.util.HashMap;
Expand All @@ -32,7 +33,7 @@
*/
public class ManualImportHelper extends AbstractElisaImportHelper
{
public ManualImportHelper(AssayUploadXarContext context, PlateBasedAssayProvider provider, ExpProtocol protocol, File dataFile)
public ManualImportHelper(AssayUploadXarContext context, PlateBasedAssayProvider provider, ExpProtocol protocol, FileLike dataFile)
{
super(context, provider, protocol, dataFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.labkey.elispot;

import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.labkey.api.assay.AssayUrls;
import org.labkey.api.assay.plate.Position;
import org.labkey.api.data.Container;
Expand All @@ -39,8 +40,8 @@
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.ViewBackgroundInfo;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -79,10 +80,10 @@ public interface ElispotDataFileParser
List<Map<String, Object>> getResults() throws ExperimentException;
}

public abstract ElispotDataFileParser getDataFileParser(ExpData data, File dataFile, ViewBackgroundInfo info, Logger log, XarContext context);
public abstract ElispotDataFileParser getDataFileParser(ExpData data, FileLike dataFile, ViewBackgroundInfo info, Logger log, XarContext context);

@Override
public void importFile(ExpData data, File dataFile, ViewBackgroundInfo info, Logger log, XarContext context) throws ExperimentException
public void importFile(@NotNull ExpData data, @NotNull FileLike dataFile, @NotNull ViewBackgroundInfo info, @NotNull Logger log, @NotNull XarContext context) throws ExperimentException
{
ExpRun run = data.getRun();

Expand Down
10 changes: 5 additions & 5 deletions elispotassay/src/org/labkey/elispot/ElispotDataHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public DataType getDataType()
static class ElispotFileParser implements ElispotDataFileParser
{
private final ExpData _data;
private final File _dataFile;
private final FileLike _dataFile;
private final XarContext _context;

public ElispotFileParser(ExpData data, File dataFile, XarContext context)
public ElispotFileParser(ExpData data, FileLike dataFile, XarContext context)
{
_data = data;
_dataFile = dataFile;
Expand Down Expand Up @@ -199,7 +199,7 @@ else if (SPOT_SIZE_PROPERTY_NAME.equalsIgnoreCase(measurement))
}

@Override
public ElispotDataFileParser getDataFileParser(ExpData data, File dataFile, ViewBackgroundInfo info, Logger log, XarContext context)
public ElispotDataFileParser getDataFileParser(ExpData data, FileLike dataFile, ViewBackgroundInfo info, Logger log, XarContext context)
{
return new ElispotFileParser(data, dataFile, context);
}
Expand All @@ -213,7 +213,7 @@ public void importTransformDataMap(ExpData data, AssayRunUploadContext<?> contex
@Override
public Map<DataType, DataIteratorBuilder> getValidationDataMap(ExpData data, FileLike dataFile, ViewBackgroundInfo info, Logger log, XarContext context, DataLoaderSettings settings) throws ExperimentException
{
ElispotDataFileParser parser = getDataFileParser(data, dataFile.toNioPathForRead().toFile(), info, log, context);
ElispotDataFileParser parser = getDataFileParser(data, dataFile, info, log, context);

Map<DataType, DataIteratorBuilder> datas = new HashMap<>();
List<Map<String, Object>> rows = parser.getResults();
Expand All @@ -222,7 +222,7 @@ public Map<DataType, DataIteratorBuilder> getValidationDataMap(ExpData data, Fil
return datas;
}

public static Map<PlateInfo, Plate> initializePlates(ExpProtocol protocol, File dataFile, Plate template, PlateReader reader) throws ExperimentException
public static Map<PlateInfo, Plate> initializePlates(ExpProtocol protocol, FileLike dataFile, Plate template, PlateReader reader) throws ExperimentException
{
AssayProvider provider = AssayService.get().getProvider(protocol);
Map<PlateInfo, Plate> plateMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ protected ExpRun finishPost(ElispotRunUploadForm form, BindException errors)
if (runPropMap.containsKey(ElispotAssayProvider.READER_PROPERTY_NAME))
{
reader = provider.getPlateReader(runPropMap.get(ElispotAssayProvider.READER_PROPERTY_NAME));
plates = ElispotDataHandler.initializePlates(form.getProtocol(), data.get(0).getFile(), template, reader);
plates = ElispotDataHandler.initializePlates(form.getProtocol(), data.get(0).getFileLike(), template, reader);
}

boolean subtractBackground = NumberUtils.toInt(runPropMap.get(ElispotAssayProvider.BACKGROUND_WELL_PROPERTY_NAME), 0) > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public PlateAnalytePropertyHelper(ElispotRunUploadForm form, List<? extends Doma
if (runPropMap.containsKey(ElispotAssayProvider.READER_PROPERTY_NAME))
{
reader = form.getProvider().getPlateReader(runPropMap.get(ElispotAssayProvider.READER_PROPERTY_NAME));
for (PlateUtils.GridInfo grid : reader.loadMultiGridFile(template, file.toNioPathForRead().toFile()))
for (PlateUtils.GridInfo grid : reader.loadMultiGridFile(template, file))
{
// attempt to parse the plate grid annotation into a PlateInfo object
FluorescentPlateInfo plateInfo = FluorescentPlateInfo.create(grid.getAnnotations());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.labkey.elispot.ElispotManager;
import org.labkey.elispot.RunDataRow;
import org.labkey.elispot.plate.PlateInfo;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -185,12 +186,12 @@ private Plate initializePlate(PlateBasedAssayProvider provider, ExpRun run, Plat

if (reader != null)
{
File dataFile = data.get(0).getFile();
FileLike dataFile = data.get(0).getFileLike();

if (dataFile.exists())
{
// TODO: how to handle background subtraction for fluorospot scans
for (Map.Entry<PlateInfo, Plate> entry : ElispotDataHandler.initializePlates(run.getProtocol(), data.get(0).getFile(), template, reader).entrySet())
for (Map.Entry<PlateInfo, Plate> entry : ElispotDataHandler.initializePlates(run.getProtocol(), dataFile, template, reader).entrySet())
{
if (entry.getKey().getMeasurement().equals(ElispotDataHandler.SFU_PROPERTY_NAME))
{
Expand Down
13 changes: 8 additions & 5 deletions elispotassay/src/org/labkey/elispot/plate/AIDPlateReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import org.labkey.api.query.ValidationException;
import org.labkey.api.reader.DataLoader;
import org.labkey.api.reader.DataLoaderFactory;
import org.labkey.vfs.FileLike;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
Expand Down Expand Up @@ -55,13 +56,14 @@ else if ("--".equalsIgnoreCase(token))
}

@Override
public double[][] loadFile(Plate template, File dataFile) throws ExperimentException
public double[][] loadFile(Plate template, FileLike dataFile) throws ExperimentException
{
String fileName = dataFile.getName().toLowerCase();
if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx"))
{
DataLoaderFactory factory = DataLoader.get().findFactory(dataFile, null);
try (DataLoader loader = factory.createLoader(dataFile, false))
try (InputStream in = dataFile.openInputStream();
DataLoader loader = factory.createLoader(in, false))
{
return PlateUtils.parseGrid(dataFile, loader.load(), template.getRows(), template.getColumns(), this);
}
Expand All @@ -77,13 +79,14 @@ public double[][] loadFile(Plate template, File dataFile) throws ExperimentExcep
}

@Override
public List<PlateUtils.GridInfo> loadMultiGridFile(Plate template, File dataFile) throws ExperimentException
public List<PlateUtils.GridInfo> loadMultiGridFile(Plate template, FileLike dataFile) throws ExperimentException
{
String fileName = dataFile.getName().toLowerCase();
if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx"))
{
DataLoaderFactory factory = DataLoader.get().findFactory(dataFile, null);
try (DataLoader loader = factory.createLoader(dataFile, false))
try (InputStream in = dataFile.openInputStream();
DataLoader loader = factory.createLoader(in, false))
{
return PlateUtils.parseAllGrids(dataFile, loader.load(), template.getRows(), template.getColumns(), this);
}
Expand Down
6 changes: 3 additions & 3 deletions flow/enginesrc/org/labkey/flow/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static Workspace readWorkspace(File file, boolean printWarnings)

private static File uniqueFile(File dir, String name)
{
File file = new File(dir, name);
File file = FileUtil.appendName(dir, name);
if (file.exists())
{
String base = name;
Expand All @@ -108,7 +108,7 @@ private static File uniqueFile(File dir, String name)
}

for (int i = 1; file.exists(); i++)
file = new File(dir, base + i + ext);
file = FileUtil.appendName(dir, base + i + ext);
}

return file;
Expand Down Expand Up @@ -244,7 +244,7 @@ private static void writeAnalysis(File outDir, String name, Workspace workspace,
{
XmlOptions options = new XmlOptions();
options.setSavePrettyPrint();
doc.save(new File(outDir, name), options);
doc.save(FileUtil.appendName(outDir, name), options);
}
catch (IOException ioe)
{
Expand Down
3 changes: 2 additions & 1 deletion flow/enginesrc/org/labkey/flow/analysis/model/FCS.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.StringUtilsLabKey;

import java.io.*;
Expand Down Expand Up @@ -368,7 +369,7 @@ public boolean accept(File dir, String name)
return ext.equals(".fcs") || ext.equals(".facs") || ext.equals(".lmd");
}
else
return isFCSFile(new File(dir,name));
return isFCSFile(FileUtil.appendName(dir, name));
}
}

Expand Down
Loading