From bdad2219da8de0cd97542fd5dafa76035d9e021b Mon Sep 17 00:00:00 2001 From: Josh Eckels Date: Tue, 9 Jun 2026 07:52:53 -0700 Subject: [PATCH 1/2] Haplotype assay cleanup (#200) #### Rationale Lint cleanup and SQL improvements #### Changes * Clear assorted IntelliJ warnings * Use JDBC parameter --- .../genotyping/HaplotypeProtocolBean.java | 17 +---------------- .../genotyping/HaplotypeProtocolSchema.java | 10 +++++----- .../labkey/genotyping/IlluminaFastqParser.java | 8 ++------ .../view/importHaplotypeAssignments.jsp | 4 ++-- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/genotyping/src/org/labkey/genotyping/HaplotypeProtocolBean.java b/genotyping/src/org/labkey/genotyping/HaplotypeProtocolBean.java index d6efa3ee..1c36ed80 100644 --- a/genotyping/src/org/labkey/genotyping/HaplotypeProtocolBean.java +++ b/genotyping/src/org/labkey/genotyping/HaplotypeProtocolBean.java @@ -22,22 +22,7 @@ * Date: 12/14/12 */ -public class HaplotypeProtocolBean +public record HaplotypeProtocolBean(HaplotypeDataCollector dataCollector, ExpProtocol protocol) { - private final HaplotypeDataCollector dataCollector; - private final ExpProtocol protocol; - - public HaplotypeProtocolBean(HaplotypeDataCollector dataCollector, ExpProtocol protocol){ - this.dataCollector = dataCollector; - this.protocol = protocol; - } - - public HaplotypeDataCollector getDataCollector(){ - return dataCollector; - } - - public ExpProtocol getProtocol(){ - return protocol; - } } diff --git a/genotyping/src/org/labkey/genotyping/HaplotypeProtocolSchema.java b/genotyping/src/org/labkey/genotyping/HaplotypeProtocolSchema.java index 1fa7d852..e89367fe 100644 --- a/genotyping/src/org/labkey/genotyping/HaplotypeProtocolSchema.java +++ b/genotyping/src/org/labkey/genotyping/HaplotypeProtocolSchema.java @@ -102,7 +102,7 @@ public TableInfo getTable(String name, @Nullable ContainerFilter cf, boolean inc @Override public @Nullable TableInfo createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns) { - FilteredTable table = (FilteredTable)new GenotypingQuerySchema(getUser(), getContainer()).getTable(GenotypingQuerySchema.TableType.AnimalAnalysis.name(), cf,true, true); + FilteredTable table = (FilteredTable)new GenotypingQuerySchema(getUser(), getContainer()).getTable(GenotypingQuerySchema.TableType.AnimalAnalysis.name(), cf,true, true); List keys = new ArrayList<>(table.getDefaultVisibleColumns()); HashSet defaults = HaplotypeAssayProvider.getDefaultColumns(); List props = HaplotypeAssayProvider.getDomainProps(getProtocol()); @@ -147,14 +147,15 @@ private ExprColumn makeColumnFromRunField(DomainProperty prop, boolean max, SQLF String field = prop.getName(); String label = prop.getLabel() != null ? prop.getLabel() : ColumnInfo.labelFromName(prop.getName()); - String type = field.substring(0, prop.getName().length()-1).replaceAll("Haplotype", ""); //ColumnInfo.labelFromName(prop.getName()).split(" ")[0]; + String type = field.substring(0, prop.getName().length()-1).replace("Haplotype", ""); //ColumnInfo.labelFromName(prop.getName()).split(" ")[0]; SQLFragment sql = new SQLFragment("(SELECT "); sql.append("min"); sql.append("(x.Haplotype) FROM ("); sql.append(selectStatement); - sql.append(") AS x WHERE x.DiploidNumber = ? AND x.Type = '" + type + "' AND x.AnimalAnalysisId = " + ExprColumn.STR_TABLE_ALIAS + ".RowID)"); + sql.append(") AS x WHERE x.DiploidNumber = ? AND x.Type = ? AND x.AnimalAnalysisId = " + ExprColumn.STR_TABLE_ALIAS + ".RowID)"); sql.add(max ? 2 : 1); + sql.add(type); ExprColumn column = new ExprColumn(table, field, sql, JdbcType.VARCHAR); TableInfo haplotypeDetailsTableInfo = getHaplotypeDetailsTableInfo(); if (haplotypeDetailsTableInfo != null && haplotypeDetailsTableInfo.getGridURL(getContainer()) != null) @@ -180,8 +181,7 @@ public DataView createDataView() { DataView result = super.createDataView(); DataRegion rgn = result.getDataRegion(); - - ButtonBar bar = result.getDataRegion().getButtonBar(DataRegion.MODE_GRID); + ButtonBar bar = rgn.getButtonBar(DataRegion.MODE_GRID); if (!bar.isLocked()) { ActionButton reportButton = new ActionButton(GenotypingController.HaplotypeAssignmentReportAction.class, "Produce Report"); diff --git a/genotyping/src/org/labkey/genotyping/IlluminaFastqParser.java b/genotyping/src/org/labkey/genotyping/IlluminaFastqParser.java index 29c2bc84..15ed34a8 100644 --- a/genotyping/src/org/labkey/genotyping/IlluminaFastqParser.java +++ b/genotyping/src/org/labkey/genotyping/IlluminaFastqParser.java @@ -20,8 +20,8 @@ import org.apache.commons.collections4.ListValuedMap; import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.commons.io.FileUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; import org.junit.Assert; import org.junit.Before; @@ -57,10 +57,6 @@ * This is designed to parse the FASTQ files produced by a single run on an Illumina instrument and produce one gzipped FASTQ * for each sample in that run. Parsing that CSV file to obtain the sample list is upstream of this class. * It is designed to be called from a pipeline job, although it should not need to be. - * - * User: bbimber - * Date: 4/18/12 - * Time: 11:35 AM */ public class IlluminaFastqParser { @@ -350,7 +346,7 @@ else if(rc == 0 && readCount != 0) return fileName + " has " + readCount + " reads, while its pair file is empty and has 0 reads."; } else - m.put(fileNameWithoutPairingInfo, Integer.valueOf(readCount)); + m.put(fileNameWithoutPairingInfo, readCount); return null; diff --git a/genotyping/src/org/labkey/genotyping/view/importHaplotypeAssignments.jsp b/genotyping/src/org/labkey/genotyping/view/importHaplotypeAssignments.jsp index ae2cd3a2..b1e79896 100644 --- a/genotyping/src/org/labkey/genotyping/view/importHaplotypeAssignments.jsp +++ b/genotyping/src/org/labkey/genotyping/view/importHaplotypeAssignments.jsp @@ -28,7 +28,7 @@ <% JspView me = HttpView.currentView(); HaplotypeProtocolBean bean = me.getModelBean(); - HaplotypeDataCollector dataCollector = bean.getDataCollector(); + HaplotypeDataCollector dataCollector = bean.dataCollector(); String[] reshowData = {}; if (dataCollector.getReshowValue("data") != null && !dataCollector.getReshowValue("data").isEmpty()) { @@ -42,7 +42,7 @@ diff --git a/genotyping/src/org/labkey/genotyping/view/configure.jsp b/genotyping/src/org/labkey/genotyping/view/configure.jsp index 8b002b7c..8cffe2e2 100644 --- a/genotyping/src/org/labkey/genotyping/view/configure.jsp +++ b/genotyping/src/org/labkey/genotyping/view/configure.jsp @@ -116,9 +116,6 @@ <%=h(form.getMessage())%>   <% } %> - Configure Galaxy - Galaxy server home page URL -   Configure Genotyping Queries External source of DNA reference sequences   diff --git a/genotyping/src/org/labkey/genotyping/view/importReads.jsp b/genotyping/src/org/labkey/genotyping/view/importReads.jsp index 66ec423d..45628cb2 100644 --- a/genotyping/src/org/labkey/genotyping/view/importReads.jsp +++ b/genotyping/src/org/labkey/genotyping/view/importReads.jsp @@ -71,10 +71,9 @@ - <%= button("Import Reads").submit(true) %> - <%=platform == SEQUENCE_PLATFORMS.LS454 ? button("Import Reads And Analyze").submit(true).onClick("document.importReads.analyze.value=1;") : HtmlString.EMPTY_STRING%> + <%=platform == SEQUENCE_PLATFORMS.LS454 ? button("Import Reads And Analyze").submit(true) : HtmlString.EMPTY_STRING%> diff --git a/genotyping/src/org/labkey/genotyping/view/mySettings.jsp b/genotyping/src/org/labkey/genotyping/view/mySettings.jsp deleted file mode 100644 index c54465f9..00000000 --- a/genotyping/src/org/labkey/genotyping/view/mySettings.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<% -/* - * Copyright (c) 2010-2014 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -%> -<%@ page import="org.labkey.api.util.URLHelper"%> -<%@ page import="org.labkey.genotyping.GenotypingController" %> -<%@ page import="org.labkey.genotyping.GenotypingController.MySettingsAction" %> -<%@ page import="org.labkey.genotyping.galaxy.GalaxyFolderSettings" %> -<%@ page import="org.labkey.genotyping.galaxy.GalaxyManager" %> -<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %> -<%@ page extends="org.labkey.api.jsp.JspBase" %> -<% - GenotypingController.MySettingsForm form = (GenotypingController.MySettingsForm)getModelBean(); - GalaxyFolderSettings settings = GalaxyManager.get().getSettings(getContainer()); - String serverURL = settings.getGalaxyURL(); - String preferencesHTML = "the API Keys page"; - - // Make it a link if admin has set the Galaxy URL - if (null != serverURL) - { - URLHelper userURL = new URLHelper((serverURL.endsWith("/") ? serverURL : serverURL + "/") + "user/api_keys"); - preferencesHTML = "" + preferencesHTML + ""; - } -%> - - - <%=formatMissedErrorsInTable("form", 2)%> - - - - - - -
- You need to provide a Galaxy web API key to send data from LabKey to your Galaxy server. Galaxy generates a - unique web API key for each user and uses it to authorize every call to the Galaxy web API. You can find or - generate a key by logging into Galaxy and visiting <%=unsafe(preferencesHTML)%>. Copy the 32-character hexadecimal - string and paste it in the box below. -
 
Galaxy web API key
 
<%= button("Submit").submit(true) %> <%= button("Cancel").href(form.getReturnUrlHelper()) %><%=generateReturnUrlFormField(form)%>
-
diff --git a/genotyping/src/org/labkey/genotyping/view/overview.jsp b/genotyping/src/org/labkey/genotyping/view/overview.jsp index d9fec53a..ec3c4fae 100644 --- a/genotyping/src/org/labkey/genotyping/view/overview.jsp +++ b/genotyping/src/org/labkey/genotyping/view/overview.jsp @@ -99,8 +99,7 @@ Settings - - <%=link("My Settings", GenotypingController.getMySettingsURL(c, getActionURL()))%><% + <% if (c.hasPermission(user, AdminPermission.class)) { %> diff --git a/genotyping/test/src/org/labkey/test/tests/GenotypingBaseTest.java b/genotyping/test/src/org/labkey/test/tests/GenotypingBaseTest.java index 61e065b4..815f3c2f 100644 --- a/genotyping/test/src/org/labkey/test/tests/GenotypingBaseTest.java +++ b/genotyping/test/src/org/labkey/test/tests/GenotypingBaseTest.java @@ -90,17 +90,11 @@ protected void configureAdmin(boolean configureSequences) _extHelper.waitForExt3MaskToDisappear(WAIT_FOR_JAVASCRIPT); } } + clickButton("Submit"); if (configureSequences) { - setFormElement(Locator.name("galaxyURL"), "http://galaxy.labkey.org:8080"); - clickButton("Submit"); clickButton("Load Sequences"); - - log("Configure Galaxy Server Key"); - clickAndWait(Locator.linkWithText("My Settings")); - setFormElement(Locator.name("galaxyKey"), "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); } - clickButton("Submit"); } @Override diff --git a/genotyping/test/src/org/labkey/test/tests/GenotypingTest.java b/genotyping/test/src/org/labkey/test/tests/GenotypingTest.java index 32d6c074..f7d3e09c 100644 --- a/genotyping/test/src/org/labkey/test/tests/GenotypingTest.java +++ b/genotyping/test/src/org/labkey/test/tests/GenotypingTest.java @@ -25,8 +25,6 @@ import org.labkey.test.categories.OConnor; import org.openqa.selenium.NoSuchElementException; -import java.io.File; - @Category({CustomModules.class, OConnor.class}) @BaseWebDriverTest.ClassTimeout(minutes = 9) public class GenotypingTest extends GenotypingBaseTest @@ -34,8 +32,6 @@ public class GenotypingTest extends GenotypingBaseTest public static final String first454importNum = "207"; public static final String second454importNum = "208"; - protected int runNum = 0; //this is globally unique, so we need to retrieve it every time. - @Override protected String getProjectName() { @@ -65,9 +61,7 @@ public void testSteps() { //TODO: need to fix 454/genotyping tests importRunTest(); - runAnalysisTest(); importSecondRunTest(); - verifyAnalysis(); } private void importSecondRunTest() @@ -95,65 +89,6 @@ private void importRunAgainTest() } } - private void runAnalysisTest() - { - sendDataToGalaxyServer(); - receiveDataFromGalaxyServer(); - } - - private void verifyAnalysis() - { - goToProjectHome(); - - clickAndWait(Locator.linkWithText("View Analyses")); - clickAndWait(Locator.linkWithText("" + getRunNumber())); // TODO: This is probably still too permissive... need a more specific way to get the run link - - assertTextPresent("Reads", "Sample Id", "Percent", "TEST09"); - assertElementPresent(Locator.paginationText(1, 100, 1410)); - } - - private void receiveDataFromGalaxyServer() - { - String[] filesToCopy = {"matches.txt", "analysis_complete.txt"}; - String analysisFolder = "analysis_" + getRunNumber(); - for (String file: filesToCopy) - { - copyFile(new File(getPipelineLoc(), file), new File(getPipelineLoc(), analysisFolder + "/" + file)); - } - refresh(); - waitForPipelineJobsToComplete(++pipelineJobCount, "Import genotyping analysis", false); - } - - private int getRunNumber() - { - return runNum; - } - - private void sendDataToGalaxyServer() - { - clickButton("Add Analysis"); - _extHelper.selectComboBoxItem("Reference Sequences:", "[default]"); //TODO: this should be cyno - clickButton("Submit"); - waitForPipelineJobsToComplete(++pipelineJobCount, "Submit genotyping analysis", false); - findAndSetAnalysisNumber(); - - } - - private void findAndSetAnalysisNumber() - { - Locator l = Locator.tagContainingText("td", "Submit genotyping analysis"); - isElementPresent(l); - getText(l); - String[] temp = getText(l).split(" "); - setAnalysisNumber(Integer.parseInt(temp[temp.length-1])); - - } - - private void setAnalysisNumber(int i) - { - runNum = i; - } - private void importRunTest() { log("import genotyping run"); @@ -183,6 +118,5 @@ private void startImportRun(String file, String importAction, String associatedR _fileBrowserHelper.importFile(file, importAction); selectOptionByText(Locator.name("run"), associatedRun); clickButton("Import Reads"); - } }