Skip to content

Commit bdad221

Browse files
Haplotype assay cleanup (#200)
#### Rationale Lint cleanup and SQL improvements #### Changes * Clear assorted IntelliJ warnings * Use JDBC parameter
1 parent f250a30 commit bdad221

4 files changed

Lines changed: 10 additions & 29 deletions

File tree

genotyping/src/org/labkey/genotyping/HaplotypeProtocolBean.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,7 @@
2222
* Date: 12/14/12
2323
*/
2424

25-
public class HaplotypeProtocolBean
25+
public record HaplotypeProtocolBean(HaplotypeDataCollector<?> dataCollector, ExpProtocol protocol)
2626
{
27-
private final HaplotypeDataCollector dataCollector;
28-
private final ExpProtocol protocol;
29-
30-
public HaplotypeProtocolBean(HaplotypeDataCollector dataCollector, ExpProtocol protocol){
31-
this.dataCollector = dataCollector;
32-
this.protocol = protocol;
33-
}
34-
35-
public HaplotypeDataCollector getDataCollector(){
36-
return dataCollector;
37-
}
38-
39-
public ExpProtocol getProtocol(){
40-
return protocol;
41-
}
4227

4328
}

genotyping/src/org/labkey/genotyping/HaplotypeProtocolSchema.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public TableInfo getTable(String name, @Nullable ContainerFilter cf, boolean inc
102102
@Override
103103
public @Nullable TableInfo createDataTable(ContainerFilter cf, boolean includeCopiedToStudyColumns)
104104
{
105-
FilteredTable<?> table = (FilteredTable)new GenotypingQuerySchema(getUser(), getContainer()).getTable(GenotypingQuerySchema.TableType.AnimalAnalysis.name(), cf,true, true);
105+
FilteredTable<?> table = (FilteredTable<?>)new GenotypingQuerySchema(getUser(), getContainer()).getTable(GenotypingQuerySchema.TableType.AnimalAnalysis.name(), cf,true, true);
106106
List<FieldKey> keys = new ArrayList<>(table.getDefaultVisibleColumns());
107107
HashSet<String> defaults = HaplotypeAssayProvider.getDefaultColumns();
108108
List<? extends DomainProperty> props = HaplotypeAssayProvider.getDomainProps(getProtocol());
@@ -147,14 +147,15 @@ private ExprColumn makeColumnFromRunField(DomainProperty prop, boolean max, SQLF
147147

148148
String field = prop.getName();
149149
String label = prop.getLabel() != null ? prop.getLabel() : ColumnInfo.labelFromName(prop.getName());
150-
String type = field.substring(0, prop.getName().length()-1).replaceAll("Haplotype", ""); //ColumnInfo.labelFromName(prop.getName()).split(" ")[0];
150+
String type = field.substring(0, prop.getName().length()-1).replace("Haplotype", ""); //ColumnInfo.labelFromName(prop.getName()).split(" ")[0];
151151

152152
SQLFragment sql = new SQLFragment("(SELECT ");
153153
sql.append("min");
154154
sql.append("(x.Haplotype) FROM (");
155155
sql.append(selectStatement);
156-
sql.append(") AS x WHERE x.DiploidNumber = ? AND x.Type = '" + type + "' AND x.AnimalAnalysisId = " + ExprColumn.STR_TABLE_ALIAS + ".RowID)");
156+
sql.append(") AS x WHERE x.DiploidNumber = ? AND x.Type = ? AND x.AnimalAnalysisId = " + ExprColumn.STR_TABLE_ALIAS + ".RowID)");
157157
sql.add(max ? 2 : 1);
158+
sql.add(type);
158159
ExprColumn column = new ExprColumn(table, field, sql, JdbcType.VARCHAR);
159160
TableInfo haplotypeDetailsTableInfo = getHaplotypeDetailsTableInfo();
160161
if (haplotypeDetailsTableInfo != null && haplotypeDetailsTableInfo.getGridURL(getContainer()) != null)
@@ -180,8 +181,7 @@ public DataView createDataView()
180181
{
181182
DataView result = super.createDataView();
182183
DataRegion rgn = result.getDataRegion();
183-
184-
ButtonBar bar = result.getDataRegion().getButtonBar(DataRegion.MODE_GRID);
184+
ButtonBar bar = rgn.getButtonBar(DataRegion.MODE_GRID);
185185
if (!bar.isLocked())
186186
{
187187
ActionButton reportButton = new ActionButton(GenotypingController.HaplotypeAssignmentReportAction.class, "Produce Report");

genotyping/src/org/labkey/genotyping/IlluminaFastqParser.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import org.apache.commons.collections4.ListValuedMap;
2121
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
2222
import org.apache.commons.io.FileUtils;
23-
import org.apache.logging.log4j.Logger;
2423
import org.apache.logging.log4j.LogManager;
24+
import org.apache.logging.log4j.Logger;
2525
import org.jetbrains.annotations.Nullable;
2626
import org.junit.Assert;
2727
import org.junit.Before;
@@ -57,10 +57,6 @@
5757
* This is designed to parse the FASTQ files produced by a single run on an Illumina instrument and produce one gzipped FASTQ
5858
* for each sample in that run. Parsing that CSV file to obtain the sample list is upstream of this class.
5959
* It is designed to be called from a pipeline job, although it should not need to be.
60-
*
61-
* User: bbimber
62-
* Date: 4/18/12
63-
* Time: 11:35 AM
6460
*/
6561
public class IlluminaFastqParser
6662
{
@@ -350,7 +346,7 @@ else if(rc == 0 && readCount != 0)
350346
return fileName + " has " + readCount + " reads, while its pair file is empty and has 0 reads.";
351347
}
352348
else
353-
m.put(fileNameWithoutPairingInfo, Integer.valueOf(readCount));
349+
m.put(fileNameWithoutPairingInfo, readCount);
354350

355351
return null;
356352

genotyping/src/org/labkey/genotyping/view/importHaplotypeAssignments.jsp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<%
2929
JspView<HaplotypeProtocolBean> me = HttpView.currentView();
3030
HaplotypeProtocolBean bean = me.getModelBean();
31-
HaplotypeDataCollector dataCollector = bean.getDataCollector();
31+
HaplotypeDataCollector dataCollector = bean.dataCollector();
3232
String[] reshowData = {};
3333
if (dataCollector.getReshowValue("data") != null && !dataCollector.getReshowValue("data").isEmpty())
3434
{
@@ -42,7 +42,7 @@
4242
<script type="text/javascript" nonce="<%=getScriptNonce()%>">
4343
var expectedHeaders = [];
4444
<%
45-
for (Map.Entry<String, HaplotypeColumnMappingProperty> property : HaplotypeAssayProvider.getColumnMappingProperties(bean.getProtocol()).entrySet())
45+
for (Map.Entry<String, HaplotypeColumnMappingProperty> property : HaplotypeAssayProvider.getColumnMappingProperties(bean.protocol()).entrySet())
4646
{
4747
%>expectedHeaders.push({name: '<%=h(property.getKey())%>', label: '<%=h(property.getValue().getLabel())%>', reshowValue: '<%=h(dataCollector.getReshowValue(property.getKey()))%>', required: <%=property.getValue().isRequired()%>});<%
4848
}

0 commit comments

Comments
 (0)