Skip to content

Commit

Permalink
Item 5911: Added tic area as default run scoped metric
Browse files Browse the repository at this point in the history
* Item 5911 : Add new run scoped metric in qcmetricconfiguration and new column in sample file

* Item 5911: Read tic area in skyline doc importer and add in samplefile table

* Item 5911: new run scoped metric query and changes in qc plot panel

* Item 5911: Hide/Un-hide Show All Series in a single plot checkbox in qc plot web part

* Item 5911: upgrading sql scripts and module version

* Item 5911: using setVisible to show/hide the checkbox

* Item 5911: Include runid in view document link for run scoped metrics

* Item 5911: Adding ticarea column in xml

* Item 5911: sample data -adding tic area to existing sample data file

* Item 5912 : automated test

* Fixing automated tests and correcting typo

* Item 5912: Re-arranging the order of qc metric configuration deletions on container delete

* scroll down to qc plot web part

* Item 5912: mouse over data point

* adding wait after scroll to the view

* Added wiki webpart to scroll into

* Moving QC Plots webpart at the top

* Removing sleep

* moving qc plt webpart down after the test
  • Loading branch information
labkey-ankurj authored Aug 2, 2019
1 parent c96418d commit d903f72
Show file tree
Hide file tree
Showing 19 changed files with 233 additions and 15 deletions.
18 changes: 18 additions & 0 deletions resources/queries/targetedms/QCRunMetric_ticArea.query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="QCRunMetric_ticArea" tableDbType="NOT_IN_DB">
<columns>
<column columnName="SampleFileId">
<fk>
<fkDbSchema>targetedms</fkDbSchema>
<fkTable>SampleFile</fkTable>
<fkColumnName>Id</fkColumnName>
<fkDisplayColumnName>SampleName</fkDisplayColumnName>
</fk>
</column>
</columns>
</table>
</tables>
</metadata>
</query>
25 changes: 25 additions & 0 deletions resources/queries/targetedms/QCRunMetric_ticArea.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2019 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.
*/

SELECT
0 AS PrecursorId,
0 AS PrecursorChromInfoId,
Id AS SampleFileId,
'Total Ion Chromatogram Area' AS SeriesLabel,
NULL AS DataType,
TicArea AS MetricValue,
0.0 AS mz
FROM SampleFile
22 changes: 22 additions & 0 deletions resources/schemas/dbscripts/postgresql/targetedms-19.21-19.22.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2019 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.
*/

WITH rootIdentity as (select EntityId as theIdentity FROM core.Containers WHERE Parent is null)

INSERT INTO targetedms.QCMetricConfiguration (Container, Name,Series1Label,Series1SchemaName,Series1QueryName,Series2Label,Series2SchemaName,Series2QueryName,PrecursorScoped) VALUES
((select theIdentity from rootIdentity), 'TIC Area','TIC Area','targetedms','QCRunMetric_ticArea',NULL , NULL , NULL , FALSE );

ALTER TABLE targetedms.SampleFile ADD COLUMN TicArea DOUBLE PRECISION;
24 changes: 24 additions & 0 deletions resources/schemas/dbscripts/sqlserver/targetedms-19.21-19.22.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2019 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.
*/


declare @rootIdentity ENTITYID;
select @rootIdentity = [EntityId] FROM [core].[Containers] WHERE Parent is null

INSERT INTO targetedms.QCMetricConfiguration (Container, Name, Series1Label, Series1SchemaName, Series1QueryName, PrecursorScoped)
VALUES (@rootIdentity, 'TIC Area','TIC Area','targetedms','QCRunMetric_ticArea', 0);

ALTER TABLE targetedms.SampleFile ADD TicArea DOUBLE PRECISION;
1 change: 1 addition & 0 deletions resources/schemas/targetedms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<column columnName="InstrumentId">
<columnTitle>Instrument</columnTitle>
</column>
<column columnName="TicArea"/>
</columns>
</table>
<table tableName="Runs" tableDbType="TABLE">
Expand Down
5 changes: 3 additions & 2 deletions src/org/labkey/targetedms/TargetedMSListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ public void containerDeleted(Container c, User user)
// Clean up AutoQCPing
new SqlExecutor(TargetedMSManager.getSchema()).execute("DELETE FROM " + TargetedMSManager.getTableInfoAutoQCPing() + " WHERE Container = ?", c);

//Clean up QC enabled metrics
new SqlExecutor(TargetedMSManager.getSchema()).execute("DELETE FROM " + TargetedMSManager.getTableInfoQCEnabledMetrics() + " WHERE Container = ?", c);

// Clean up Metric Configurations
new SqlExecutor(TargetedMSManager.getSchema()).execute("DELETE FROM " + TargetedMSManager.getTableInfoQCMetricConfiguration() + " WHERE Container = ?", c);

//Clean up QC enabled metrics
new SqlExecutor(TargetedMSManager.getSchema()).execute("DELETE FROM " + TargetedMSManager.getTableInfoQCEnabledMetrics() + " WHERE Container = ?", c);

BlibSpectrumReader.clearBlibCache(c);
}
Expand Down
6 changes: 4 additions & 2 deletions src/org/labkey/targetedms/TargetedMSManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1947,8 +1947,10 @@ public List<QCMetricConfiguration> getEnabledQCMetricConfigurations(Container co
"Series1QueryName, " +
"Series2Label, " +
"Series2SchemaName, " +
"Series2QueryName " +
"FROM qcMetricsConfig WHERE Enabled = TRUE";
"Series2QueryName, " +
"PrecursorScoped " +
"FROM qcMetricsConfig " +
"WHERE Enabled = TRUE ";

QuerySchema query = DefaultSchema.get(user, container).getSchema(TargetedMSSchema.SCHEMA_NAME);
return QueryService.get().selector(query, sql).getArrayList(QCMetricConfiguration.class);
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/targetedms/TargetedMSModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public String getName()
@Override
public double getVersion()
{
return 19.21;
return 19.22;
}

@Override
Expand Down
12 changes: 12 additions & 0 deletions src/org/labkey/targetedms/model/QCMetricConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class QCMetricConfiguration
private String _series2Label;
private String _series2SchemaName;
private String _series2QueryName;
private boolean _precursorScoped;

public int getId()
{
Expand Down Expand Up @@ -107,13 +108,24 @@ public void setSeries2QueryName(String series2QueryName)
_series2QueryName = series2QueryName;
}

public boolean isPrecursorScoped()
{
return _precursorScoped;
}

public void setPrecursorScoped(boolean precursorScoped)
{
_precursorScoped = precursorScoped;
}

public JSONObject toJSON(){
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", _id);
jsonObject.put("name", _name);
jsonObject.put("series1Label", _series1Label);
jsonObject.put("series1SchemaName", _series1SchemaName);
jsonObject.put("series1QueryName", _series1QueryName);
jsonObject.put("precursorScoped", _precursorScoped);
if(_series2Label != null){
jsonObject.put("series2Label", _series2Label);
}
Expand Down
10 changes: 10 additions & 0 deletions src/org/labkey/targetedms/parser/SampleFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class SampleFile extends SkylineEntity
private String _skylineId;
private Date _acquiredTime;
private Date _modifiedTime;
private Double _ticArea;

private List<Instrument> _instrumentInfoList;
private boolean _skip;
Expand Down Expand Up @@ -115,4 +116,13 @@ public void setInstrumentInfoList(List<Instrument> instrumentInfoList)
_instrumentInfoList = instrumentInfoList;
}

public Double getTicArea()
{
return _ticArea;
}

public void setTicArea(Double ticArea)
{
_ticArea = ticArea;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@ private SampleFile readSampleFile(XMLStreamReader reader) throws XMLStreamExcept

sampleFile.setAcquiredTime(XmlUtil.readDateAttribute(reader, "acquired_time"));
sampleFile.setModifiedTime(XmlUtil.readDateAttribute(reader, "modified_time"));
sampleFile.setTicArea(XmlUtil.readDoubleAttribute(reader,"tic_area"));

List<Instrument> instrumentList = new ArrayList<>();
sampleFile.setInstrumentInfoList(instrumentList);
Expand Down
Binary file modified test/sampledata/TargetedMS/SProCoPTutorial.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ public enum MetricType
LHRATIO("Light/Heavy Ratio", false),
TPAREARATIO("Transition/Precursor Area Ratio", true),
TPAREAS("Transition & Precursor Areas", true),
MASSACCURACTY("Mass Accuracy", true);
MASSACCURACY("Mass Accuracy", true),
TICAREA("TIC Area", true);

private String _text;
private boolean _hasData;
Expand Down Expand Up @@ -784,4 +785,15 @@ protected Checkbox findQCPlotTypeCheckbox(QCPlotType plotType)
return plotTypeCheckboxes.get(plotType);
}
}

public Locator.XPathLocator getBubble()
{
return Locator.byClass("hopscotch-bubble-container");
}

public Locator.XPathLocator getBubbleContent()
{
Locator.XPathLocator hopscotchBubble = Locator.byClass("hopscotch-bubble-container");
return hopscotchBubble.append(Locator.byClass("hopscotch-bubble-content").append(Locator.byClass("hopscotch-content")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void testShowAutoQC()
waitForElements(Locator.tagWithClass("div", "sample-file-item"), 6);
tempStringList01.put("Q_Exactive_08_23_2013_JGB_58", "27");
tempStringList01.put("Q_Exactive_08_23_2013_JGB_51", "26");
tempStringList01.put("Q_Exactive_08_23_2013_JGB_37", "29");
tempStringList01.put("Q_Exactive_08_23_2013_JGB_37", "31");
tempStringList02.add(Arrays.asList("Q_Exactive_08_23_2013_JGB_58", "Acquired Date/Time: 2013-08-27 14:45"));
tempStringList02.add(Arrays.asList("Q_Exactive_08_23_2013_JGB_51", "Acquired Date/Time: 2013-08-27 03:19"));
tempStringList02.add(Arrays.asList("Q_Exactive_08_23_2013_JGB_37", "Acquired Date/Time: 2013-08-26 04:27"));
Expand Down Expand Up @@ -293,10 +293,12 @@ public void testShowAutoQC()
tempStringList01.clear();
tempStringList01.put("Q_Exactive_08_23_2013_JGB_58", "2");
tempStringList01.put("Q_Exactive_08_23_2013_JGB_51", "4");
tempStringList01.put("Q_Exactive_08_23_2013_JGB_37", "1");

tempStringList02.clear();
tempStringList02.add(Arrays.asList("Q_Exactive_08_23_2013_JGB_58", "Full Width at Half Maximum (FWHM) 1 1 0 0 0 0"));
tempStringList02.add(Arrays.asList("Q_Exactive_08_23_2013_JGB_51", "Peak Area 0 2 0 0 0 0"));
tempStringList02.add(Arrays.asList("Q_Exactive_08_23_2013_JGB_37", "TIC Area 0 1 0 0 0 0"));
validateSampleFile(0, tempStringList01, tempStringList02);

removeAllGuideSets();
Expand Down
42 changes: 40 additions & 2 deletions test/src/org/labkey/test/tests/targetedms/TargetedMSQCTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.labkey.test.categories.DailyB;
import org.labkey.test.categories.MS2;
import org.labkey.test.components.ext4.RadioButton;
import org.labkey.test.components.html.SiteNavBar;
import org.labkey.test.components.targetedms.GuideSet;
import org.labkey.test.components.targetedms.QCAnnotationTypeWebPart;
import org.labkey.test.components.targetedms.QCAnnotationWebPart;
Expand Down Expand Up @@ -55,7 +56,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.labkey.test.components.targetedms.QCPlotsWebPart.QCPlotType.CUSUMm;
import static org.labkey.test.components.targetedms.QCPlotsWebPart.QCPlotType.LeveyJennings;
import static org.labkey.test.components.targetedms.QCPlotsWebPart.QCPlotType.MovingRange;
Expand Down Expand Up @@ -155,6 +155,8 @@ public class TargetedMSQCTest extends TargetedMSTest
"\n" +
" return testLegends();";

private final PortalHelper portalHelper = new PortalHelper(this);

@Override
protected String getProjectName()
{
Expand Down Expand Up @@ -364,7 +366,7 @@ public void testQCPlotLogMessages()
qcPlotsWebPart.checkAllPlotTypes(true);

// if metric has negative values and we pick log y-axis scale, we should revert to linear scale and show message
qcPlotsWebPart.setMetricType(QCPlotsWebPart.MetricType.MASSACCURACTY);
qcPlotsWebPart.setMetricType(QCPlotsWebPart.MetricType.MASSACCURACY);
qcPlotsWebPart.setScale(QCPlotsWebPart.Scale.LOG);
assertEquals("Unexpected number of plots with invalid log scale.", 3, qcPlotsWebPart.getLogScaleInvalidCount());
assertEquals("Unexpected number of plots with invalid log scale.", 0, qcPlotsWebPart.getLogScaleWarningCount());
Expand Down Expand Up @@ -662,6 +664,42 @@ public void testCombinedPlots()
qcPlotsWebPart.resetInitialQCPlotFields();
}

@Test
public void testRunScopedMetric()
{
new SiteNavBar(getDriver()).enterPageAdminMode();
portalHelper.moveWebPart("QC Plots", PortalHelper.Direction.UP);
String acquiredDate = "2013-08-09 11:39:00";
PanoramaDashboard qcDashboard = new PanoramaDashboard(this);
QCPlotsWebPart qcPlotsWebPart = qcDashboard.getQcPlotsWebPart();

log("Verifying TIC Area QC Plots");
qcPlotsWebPart.setMetricType(QCPlotsWebPart.MetricType.TICAREA);
qcPlotsWebPart.waitForPlots(1, true);
String ticPlotSVGText = qcPlotsWebPart.getSVGPlotText("tiledPlotPanel-2-precursorPlot0");
assertFalse(ticPlotSVGText.isEmpty());

log("Verifying Show All Series Checkbox");
assertElementNotVisible(Locator.tagContainingText("label", "Show All Series in a Single Plot"));
qcPlotsWebPart.setMetricType(QCPlotsWebPart.MetricType.RETENTION);
assertElementVisible(Locator.tagContainingText("label", "Show All Series in a Single Plot"));

log("Verifying tic_area information in hover plot");
qcPlotsWebPart.setMetricType(QCPlotsWebPart.MetricType.TICAREA);
qcPlotsWebPart.waitForPlots(1, true);
mouseOver(qcPlotsWebPart.getPointByAcquiredDate(acquiredDate));
waitForElement(qcPlotsWebPart.getBubble());
String ticAreahoverText = waitForElement(qcPlotsWebPart.getBubbleContent()).getText();
assertTrue("Wrong header present", ticAreahoverText.contains("Total Ion Chromatogram Area"));
assertTrue("Wrong Link present", ticAreahoverText.contains("VIEW DOCUMENT"));
assertFalse("peptide should not be present", ticAreahoverText.contains("peptide"));
assertFalse("View Chromatogram link should not be present", ticAreahoverText.contains("VIEW CHROMATOGRAM"));

log("Moving QC Plots Webpart down");
portalHelper.moveWebPart("QC Plots", PortalHelper.Direction.DOWN);
portalHelper.exitAdminMode();
}

private void testEachCombinedPlots(QCPlotsWebPart.QCPlotType plotType)
{
log("Testing combined plot for " + plotType.getLongLabel());
Expand Down
1 change: 1 addition & 0 deletions webapp/TargetedMS/js/QCPlotHelperBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ Ext4.define("LABKEY.targetedms.QCPlotHelperBase", {
{
var data = this.processPlotDataRow(row, fragment, seriesType, metricProps);
this.fragmentPlotData[fragment].data.push(data);
this.fragmentPlotData[fragment].precursorScoped = metricProps.precursorScoped;
this.setSeriesMinMax(this.fragmentPlotData[fragment], data);
allPlotDateValues.push(data.fullDate);
}, this);
Expand Down
6 changes: 5 additions & 1 deletion webapp/TargetedMS/js/QCPlotHelperWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ Ext4.define("LABKEY.targetedms.QCPlotHelperWrapper", {
{
ids.push(id + '_plotType_' + j);
}
this.addPlotsToPlotDiv(ids, this.precursors[i] + ", " + precursorInfo.mz, this.plotDivId, 'qc-plot-wp');

precursorInfo.precursorScoped ?
this.addPlotsToPlotDiv(ids, this.precursors[i] + ", " + precursorInfo.mz, this.plotDivId, 'qc-plot-wp'):
this.addPlotsToPlotDiv(ids, this.precursors[i], this.plotDivId, 'qc-plot-wp');

var plotIndex = 0;
// add a new panel for each plot so we can add the title to the frame
if (this.showLJPlot())
Expand Down
Loading

0 comments on commit d903f72

Please sign in to comment.