From 2832ba7658d58bfb6fd6cc96dfbfa7b27c6523d1 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Sun, 5 Oct 2025 12:52:13 -0700 Subject: [PATCH 1/3] Checkpoint FileLike migration --- .../genotyping/HaplotypeAssayProvider.java | 19 ++++++------------- .../genotyping/HaplotypeDataCollector.java | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/genotyping/src/org/labkey/genotyping/HaplotypeAssayProvider.java b/genotyping/src/org/labkey/genotyping/HaplotypeAssayProvider.java index 793e29e3..1d8ab95c 100644 --- a/genotyping/src/org/labkey/genotyping/HaplotypeAssayProvider.java +++ b/genotyping/src/org/labkey/genotyping/HaplotypeAssayProvider.java @@ -46,6 +46,7 @@ import org.labkey.api.assay.AssayUrls; import org.labkey.api.study.assay.ParticipantVisitResolverType; import org.labkey.api.util.FileType; +import org.labkey.api.util.HtmlString; import org.labkey.api.util.PageFlowUtil; import org.labkey.api.util.Pair; import org.labkey.api.view.ActionURL; @@ -135,7 +136,7 @@ public String getName() @Override public HttpView getDataDescriptionView(AssayRunUploadForm form) { - return new HtmlView(""); + return new HtmlView(HtmlString.EMPTY_STRING); } @Override @@ -205,26 +206,18 @@ protected Map> getRequiredDomainProperties() { Map> domainMap = super.getRequiredDomainProperties(); - Set runProperties = domainMap.get(ExpProtocol.ASSAY_DOMAIN_RUN); - if (runProperties == null) - { - runProperties = new HashSet<>(); - domainMap.put(ExpProtocol.ASSAY_DOMAIN_RUN, runProperties); - } + Set runProperties = domainMap.computeIfAbsent(ExpProtocol.ASSAY_DOMAIN_RUN, k -> new HashSet<>()); runProperties.add(ENABLED_PROPERTY_NAME); - for (String propName : getColumnMappingProperties(true).keySet()) - { - runProperties.add(propName); - } + runProperties.addAll(getColumnMappingProperties(true).keySet()); runProperties.add(SPECIES_COLUMN.getName()); return domainMap; } @Override - public List getDataCollectors(@Nullable Map uploadedFiles, AssayRunUploadForm context) + public List getDataCollectors(@Nullable Map uploadedFiles, AssayRunUploadForm context) { - return Collections.singletonList(new HaplotypeDataCollector()); + return Collections.singletonList(new HaplotypeDataCollector<>()); } @Override diff --git a/genotyping/src/org/labkey/genotyping/HaplotypeDataCollector.java b/genotyping/src/org/labkey/genotyping/HaplotypeDataCollector.java index ead2db07..0055bb88 100644 --- a/genotyping/src/org/labkey/genotyping/HaplotypeDataCollector.java +++ b/genotyping/src/org/labkey/genotyping/HaplotypeDataCollector.java @@ -43,7 +43,7 @@ public class HaplotypeDataCollector _reshowMap; @Override - public HttpView getView(ContextType context) + public HttpView getView(ContextType context) { // if reshowing on error, get the data param out of the context for the JSP to use HttpServletRequest request = context.getRequest(); From 8583884e97180f4c02debbe679e2bc667d672943 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Sat, 11 Oct 2025 15:31:01 -0700 Subject: [PATCH 2/3] ExperimentDataHandler File->FileLike --- .../src/org/labkey/genotyping/HaplotypeDataHandler.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/genotyping/src/org/labkey/genotyping/HaplotypeDataHandler.java b/genotyping/src/org/labkey/genotyping/HaplotypeDataHandler.java index 23da88d2..cab2c6c4 100644 --- a/genotyping/src/org/labkey/genotyping/HaplotypeDataHandler.java +++ b/genotyping/src/org/labkey/genotyping/HaplotypeDataHandler.java @@ -47,6 +47,7 @@ import org.labkey.api.assay.AssayService; import org.labkey.api.view.ActionURL; import org.labkey.api.view.ViewBackgroundInfo; +import org.labkey.vfs.FileLike; import java.io.File; import java.io.IOException; @@ -70,17 +71,17 @@ public DataType getDataType() } @Override - public void importFile(@NotNull ExpData data, File dataFile, @NotNull ViewBackgroundInfo info, @NotNull Logger log, @NotNull XarContext context) throws ExperimentException + public void importFile(@NotNull ExpData data, @NotNull FileLike dataFile, @NotNull ViewBackgroundInfo info, @NotNull Logger log, @NotNull XarContext context) throws ExperimentException { if (!dataFile.exists()) { - log.warn("Could not find file " + dataFile.getAbsolutePath() + " on disk for data with LSID " + data.getLSID()); + log.warn("Could not find file " + dataFile + " on disk for data with LSID " + data.getLSID()); return; } ExpRun expRun = data.getRun(); if (expRun == null) { - throw new ExperimentException("Could not load haplotype file " + dataFile.getAbsolutePath() + " because it is not owned by an experiment run"); + throw new ExperimentException("Could not load haplotype file " + dataFile + " because it is not owned by an experiment run"); } try @@ -100,7 +101,7 @@ public void importFile(@NotNull ExpData data, File dataFile, @NotNull ViewBackgr Map animalIds = new CaseInsensitiveTreeMap<>(); List haplotypes = new ArrayList<>(); List dataRows = new ArrayList<>(); - TabLoader tabLoader = new TabLoader(dataFile, true); + TabLoader tabLoader = new TabLoader(dataFile.openInputStream(), true, data.getContainer()); List> rowsMap = tabLoader.load(); parseHaplotypeData(protocol, rowsMap, runPropertyValues, animalIds, haplotypes, dataRows); From 30b9e22d2426d6fcd393be5646eb504bf6ed58f6 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Mon, 13 Oct 2025 09:51:15 -0700 Subject: [PATCH 3/3] Test cleanup --- .../genotyping/IlluminaFastqParser.java | 40 +++++-------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/genotyping/src/org/labkey/genotyping/IlluminaFastqParser.java b/genotyping/src/org/labkey/genotyping/IlluminaFastqParser.java index 8513fb3f..6b433035 100644 --- a/genotyping/src/org/labkey/genotyping/IlluminaFastqParser.java +++ b/genotyping/src/org/labkey/genotyping/IlluminaFastqParser.java @@ -214,7 +214,7 @@ else if (reader.getLineNumber() == 1 && totalReads == 0 && !f.getName().contains sampleId = _sampleNameToIdMap.get(sampleName); } String name = (_outputPrefix == null ? "Reads" : _outputPrefix) + "-R" + pairNumber + "-" + (sampleIdx == 0 ? "Control" : sampleId) + ".fastq.gz"; - File newFile = new File(targetDir, name); + File newFile = FileUtil.appendName(targetDir, name); if (!f.equals(newFile)) { @@ -408,9 +408,7 @@ public void testHeaders() throws PipelineJobException, IOException { Module module = ModuleLoader.getInstance().getModule("genotyping"); File newHeaderPath = JunitUtil.getSampleData(module, "genotyping/illumina_newHeader"); - String newHeaderSampledataLoc = newHeaderPath.toString(); File oldHeaderPath = JunitUtil.getSampleData(module, "genotyping"); - String oldHeaderSampledataLoc = oldHeaderPath.toString(); final List filenamesOldHeader = Arrays.asList( "IlluminaSamples-R1-4892.fastq.gz", "IlluminaSamples-R1-4893.fastq.gz", @@ -472,8 +470,7 @@ public void testHeaders() throws PipelineJobException, IOException "IlluminaSamplesNewHeader-R2-4905.fastq.gz" ); - final Pair[] pairs = - { + final var pairs = List.of( new Pair<>(4892, 1), new Pair<>(4893, 1), new Pair<>(4894, 1), @@ -501,11 +498,10 @@ public void testHeaders() throws PipelineJobException, IOException new Pair<>(4902, 2), new Pair<>(4903, 2), new Pair<>(4904, 2), - new Pair<>(4905, 2) - }; + new Pair<>(4905, 2)); int i = 0; - int numOfPairs = pairs.length; + int numOfPairs = pairs.size(); Set> expectedOutputs = new HashSet<>(); Map sampleIndexToIdMap = new IntHashMap<>(); sampleIndexToIdMap.put(0, 0); @@ -516,15 +512,15 @@ public void testHeaders() throws PipelineJobException, IOException for (String fn : filenamesOldHeader) { - File target = new File(_testRoot, fn); - FileUtils.copyFile(new File(oldHeaderSampledataLoc, fn), target); - expectedOutputs.add((Pair) pairs[i]); + File target = FileUtil.appendName(_testRoot, fn); + FileUtils.copyFile(FileUtil.appendName(oldHeaderPath, fn), target); + expectedOutputs.add(pairs.get(i)); oldHeaderFiles.add(target); if (i < (numOfPairs / 2)) { - sampleIndexToIdMap.put(i + 1, (Integer)pairs[i].getKey()); - sampleIdToIndexMap.put((Integer)pairs[i].getKey(), i + 1); + sampleIndexToIdMap.put(i + 1, pairs.get(i).getKey()); + sampleIdToIndexMap.put(pairs.get(i).getKey(), i + 1); } i++; } @@ -537,8 +533,8 @@ public void testHeaders() throws PipelineJobException, IOException for (String fn : filenamesNewHeader) { - File target = new File(_testRoot, fn); - FileUtils.copyFile(new File(newHeaderSampledataLoc, fn), target); + File target = FileUtil.appendName(_testRoot, fn); + FileUtils.copyFile(FileUtil.appendName(newHeaderPath, fn), target); newHeaderFiles.add(target); } @@ -546,20 +542,6 @@ public void testHeaders() throws PipelineJobException, IOException outputs = parser.parseFastqFiles(null); Assert.assertEquals("Outputs from parseFastqFiles with new headers were not as expected.", expectedOutputs, outputs.keySet()); } - - // @After // TODO: Disabling to debug gradle failure on TeamCity - public void cleanup() throws IOException - { - if (container != null) - { - ContainerManager.delete(container, TestContext.get().getUser()); - } - - if (_testRoot != null) - { - FileUtils.deleteDirectory(_testRoot); - } - } } }