Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trial ETRedux export #232

Merged
merged 3 commits into from
May 1, 2024
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.cirdles.tripoli.plots.compoundPlotBuilders.PlotBlockCyclesRecord;
import org.cirdles.tripoli.sessions.analysis.Analysis;
import org.cirdles.tripoli.sessions.analysis.AnalysisInterface;
import org.cirdles.tripoli.sessions.analysis.massSpectrometerModels.dataModels.dataLiteOne.SingleBlockRawDataLiteSetRecord;
import org.cirdles.tripoli.sessions.analysis.massSpectrometerModels.dataModels.mcmc.SingleBlockModelRecord;
import org.cirdles.tripoli.sessions.analysis.massSpectrometerModels.dataModels.mcmc.SingleBlockRawDataSetRecord;
import org.cirdles.tripoli.sessions.analysis.massSpectrometerModels.dataModels.mcmc.initializers.AllBlockInitForMCMC;
Expand Down Expand Up @@ -120,7 +119,7 @@ public void plotRatios() {

switch (plottingData.analysisCaseNumber()) {
case 1 -> {
SingleBlockRawDataLiteSetRecord[] singleBlockRawDataLiteSetRecords = plottingData.singleBlockRawDataLiteSetRecords();
// SingleBlockRawDataLiteSetRecord[] singleBlockRawDataLiteSetRecords = plottingData.singleBlockRawDataLiteSetRecords();
int countOfOnPeakCycles = plottingData.cycleCount();
int[] blockIDsPerTimeSlot = analysis.getMassSpecExtractedData().assignBlockIdToSessionTimeLite();

Expand All @@ -137,33 +136,34 @@ public void plotRatios() {

for (UserFunction userFunction : ratiosToPlot) {
TripoliPlotPane tripoliPlotPane = TripoliPlotPane.makePlotPane(plotsWallPaneRatios);

// todo: simplify since analysis carries most of the info
Map<Integer, PlotBlockCyclesRecord> mapOfBlocksToCyclesRecords = new TreeMap<>();
for (int blockIndex = 0; blockIndex < singleBlockRawDataLiteSetRecords.length; blockIndex++) {
if (null != singleBlockRawDataLiteSetRecords[blockIndex]) {
Integer blockID = singleBlockRawDataLiteSetRecords[blockIndex].blockID();

mapOfBlocksToCyclesRecords.put(blockID, (BlockCyclesBuilder.initializeBlockCycles(
blockID,
true,
true, // TODO: not needed here
singleBlockRawDataLiteSetRecords[blockIndex].assembleCyclesIncludedForUserFunction(userFunction),
singleBlockRawDataLiteSetRecords[blockIndex].assembleCycleMeansForUserFunction(userFunction),
singleBlockRawDataLiteSetRecords[blockIndex].assembleCycleStdDevForUserFunction(userFunction),
new String[]{userFunction.getName()},
true,
userFunction.isTreatAsIsotopicRatio()).getBlockCyclesRecord()));
} else {
mapOfBlocksToCyclesRecords.put(blockIndex - 1, null);
}
}
//
// // todo: simplify since analysis carries most of the info
// Map<Integer, PlotBlockCyclesRecord> mapBlockIdToBlockCyclesRecord = new TreeMap<>();
// for (int blockIndex = 0; blockIndex < singleBlockRawDataLiteSetRecords.length; blockIndex++) {
// if (null != singleBlockRawDataLiteSetRecords[blockIndex]) {
// Integer blockID = singleBlockRawDataLiteSetRecords[blockIndex].blockID();
//
// mapBlockIdToBlockCyclesRecord.put(blockID, (BlockCyclesBuilder.initializeBlockCycles(
// blockID,
// true,
// true, // TODO: not needed here
// singleBlockRawDataLiteSetRecords[blockIndex].assembleCyclesIncludedForUserFunction(userFunction),
// singleBlockRawDataLiteSetRecords[blockIndex].assembleCycleMeansForUserFunction(userFunction),
// singleBlockRawDataLiteSetRecords[blockIndex].assembleCycleStdDevForUserFunction(userFunction),
// new String[]{userFunction.getName()},
// true,
// userFunction.isTreatAsIsotopicRatio()).getBlockCyclesRecord()));
// } else {
// mapBlockIdToBlockCyclesRecord.put(blockIndex - 1, null);
// }
// }

// userFunction.calculateAnalysisStatsRecord();

AbstractPlot plot = AnalysisBlockCyclesPlotOG.generatePlot(
new Rectangle(minPlotWidth, minPlotHeight),
analysis,
userFunction,
mapOfBlocksToCyclesRecords,
blockIDsPerTimeSlot,
(PlotWallPane) plotsWallPaneRatios);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public class AnalysisBlockCyclesPlotOG extends AbstractPlot implements AnalysisB
private final Tooltip tooltip;
private final String tooltipTextSculpt = "Left mouse: cntrl click toggles block, Dbl-click to Sculpt data. Right mouse: cntrl click zooms one block, Dbl-click toggles full view.";
private final String tooltipTextExitSculpt = "Left mouse: cntrl click toggles block, Dbl-click Exits Sculpting. Right mouse: cntrl click zooms one block, Dbl-click toggles full view.";
AnalysisInterface analysis;
Map<Integer, PlotBlockCyclesRecord> mapBlockIdToBlockCyclesRecord;
int[] blockIDsPerTimeSlot;
private AnalysisInterface analysis;
private Map<Integer, PlotBlockCyclesRecord> mapBlockIdToBlockCyclesRecord;
private UserFunction userFunction;
private double[] oneSigmaForCycles;
private boolean logScale;
Expand All @@ -86,7 +86,6 @@ private AnalysisBlockCyclesPlotOG(
AnalysisInterface analysis,
Rectangle bounds,
UserFunction userFunction,
Map<Integer, PlotBlockCyclesRecord> mapBlockIdToBlockCyclesRecord,
int[] blockIDsPerTimeSlot,
PlotWallPane parentWallPane) {
super(bounds,
Expand All @@ -98,7 +97,7 @@ private AnalysisBlockCyclesPlotOG(
userFunction.isTreatAsIsotopicRatio() ? "Ratio" : "Function");
this.analysis = analysis;
this.userFunction = userFunction;
this.mapBlockIdToBlockCyclesRecord = mapBlockIdToBlockCyclesRecord;
this.mapBlockIdToBlockCyclesRecord = userFunction.getMapBlockIdToBlockCyclesRecord();
this.blockIDsPerTimeSlot = blockIDsPerTimeSlot;
this.logScale = false;
this.zoomFlagsXY = new boolean[]{true, true};
Expand All @@ -113,9 +112,9 @@ private AnalysisBlockCyclesPlotOG(
}

public static AbstractPlot generatePlot(
Rectangle bounds, AnalysisInterface analysis, UserFunction userFunction, Map<Integer, PlotBlockCyclesRecord> mapOfBlocksToCyclesRecords,
Rectangle bounds, AnalysisInterface analysis, UserFunction userFunction,
int[] blockIDsPerTimeSlot, PlotWallPane parentWallPane) {
return new AnalysisBlockCyclesPlotOG(analysis, bounds, userFunction, mapOfBlocksToCyclesRecords, blockIDsPerTimeSlot, parentWallPane);
return new AnalysisBlockCyclesPlotOG(analysis, bounds, userFunction, blockIDsPerTimeSlot, parentWallPane);
}

public PlotWallPaneInterface getParentWallPane() {
Expand Down Expand Up @@ -236,21 +235,7 @@ public void calculateTics() {
}

public void calcStats() {
// Jan 2024 new approach - two modes: block mode and cycle mode
// BLOCK MODE will be default - calculate and plot stats for each block
int blockCount = mapBlockIdToBlockCyclesRecord.size();
BlockStatsRecord[] blockStatsRecords = new BlockStatsRecord[blockCount];
int arrayIndex = 0;
for (Map.Entry<Integer, PlotBlockCyclesRecord> entry : mapBlockIdToBlockCyclesRecord.entrySet()) {
PlotBlockCyclesRecord plotBlockCyclesRecord = entry.getValue();
if (plotBlockCyclesRecord != null) {
blockStatsRecords[arrayIndex] = BlockStatsRecord.generateBlockStatsRecord(
plotBlockCyclesRecord.blockID(), plotBlockCyclesRecord.blockIncluded(), isRatio,
userFunction.isInverted(), plotBlockCyclesRecord.cycleMeansData(), plotBlockCyclesRecord.cyclesIncluded());
}
arrayIndex++;
}
analysisStatsRecord = AnalysisStatsRecord.generateAnalysisStatsRecord(blockStatsRecords);
analysisStatsRecord = userFunction.calculateAnalysisStatsRecord();
}

/**
Expand All @@ -267,7 +252,7 @@ public void showLegend(GraphicsContext g2d) {

g2d.setFill(Paint.valueOf("RED"));
g2d.setFont(Font.font("SansSerif", 16));
String title = userFunction.getName();
String title = userFunction.showName();
if (isRatio && logScale) {
title = "LogRatio " + title;
}
Expand Down Expand Up @@ -331,7 +316,7 @@ public void showLegend(GraphicsContext g2d) {
sigmaPctString = " " + plusSigmaPct;
} else {
sigmaPctString = "+" + plusSigmaPct;
sigmaMinusPctString = "-" + minusSigmaPct;
sigmaMinusPctString = "" + minusSigmaPct;
}

sigmaPctString = appendTrailingZeroIfNeeded(sigmaPctString, countOfTrailingDigitsForSigFig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.cirdles.tripoli.sessions.analysis.Analysis;
import org.cirdles.tripoli.sessions.analysis.AnalysisInterface;
import org.cirdles.tripoli.sessions.analysis.massSpectrometerModels.dataModels.mcmc.EnsemblesStore;
import org.cirdles.tripoli.sessions.analysis.outputs.etRedux.ETReduxFraction;
import org.cirdles.tripoli.utilities.exceptions.TripoliException;
import org.cirdles.tripoli.utilities.file.SessionFileUtilities;
import org.cirdles.tripoli.utilities.stateUtilities.TripoliPersistentState;
Expand Down Expand Up @@ -154,7 +155,6 @@ public static File selectPeakShapeResourceFolderForBrowsing(Window ownerWindow)
return resourceFile;
}


public static void reportEnsembleDataDetails(AnalysisInterface analysis, Window ownerWindow)
throws IOException, TripoliException {

Expand Down Expand Up @@ -223,4 +223,20 @@ public static void saveAnalysisReport(AnalysisInterface analysis, Window ownerWi
stream.write(((Analysis) analysis).produceReportTemplateOne().getBytes());
stream.close();
}

public static void saveExportFile(ETReduxFraction etReduxFraction, Window ownerWindow)
throws IOException, TripoliException {

DirectoryChooser dirChooser = new DirectoryChooser();
dirChooser.setTitle("Select Export Folder");
File userHome = new File(File.separator + TripoliPersistentState.getExistingPersistentState().getMRUExportFolderPath());
dirChooser.setInitialDirectory(userHome.isDirectory() ? userHome : null);
File directory = dirChooser.showDialog(ownerWindow);
TripoliPersistentState.getExistingPersistentState().setMRUExportFolderPath(directory.getPath());

String fileName = directory + File.separator +
etReduxFraction.getSampleName() + "_" + etReduxFraction.getFractionID() + "_" + etReduxFraction.getEtReduxExportType() + ".xml";
etReduxFraction.serializeXMLObject(fileName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
<RowConstraints maxHeight="25.0" minHeight="25.0" prefHeight="25.0" valignment="CENTER" vgrow="NEVER"/>
<RowConstraints maxHeight="90.0" minHeight="90.0" prefHeight="90.0" valignment="TOP" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="90.0" minHeight="90.0" prefHeight="90.0" valignment="TOP" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="270.0" minHeight="270.0" prefHeight="270.0" valignment="TOP" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="270.0" minHeight="270.0" percentHeight="45.0" prefHeight="270.0" valignment="TOP"
vgrow="SOMETIMES"/>
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" valignment="TOP" vgrow="SOMETIMES"/>
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" valignment="TOP" vgrow="SOMETIMES"/>
</rowConstraints>
Expand All @@ -59,15 +60,23 @@
<Label style="-fx-text-fill: #3c77c9; -fx-font-weight: bold;" text="Sample &amp; Description:"
GridPane.rowIndex="2"/>
<HBox alignment="CENTER_LEFT" GridPane.columnIndex="1" GridPane.hgrow="NEVER" GridPane.rowIndex="2">
<TextField fx:id="sampleNameTextField" prefHeight="263.0" prefWidth="270.0" promptText="Sample"
<TextField fx:id="sampleNameTextField" prefHeight="25.0" prefWidth="156.0" promptText="Sample"
style="-fx-font-size: 12;"/>
<Label alignment="CENTER" layoutX="293.0" layoutY="14.0" prefHeight="17.0" prefWidth="61.0"
style="-fx-text-fill: #3c77c9;" text="Fraction:">
<opaqueInsets>
<Insets/>
</opaqueInsets>
</Label>
<TextField fx:id="fractionNameTextField" layoutX="10.0" layoutY="10.0" prefHeight="25.0" prefWidth="140.0"
promptText="Fraction" style="-fx-font-size: 12;"/>
<Label alignment="CENTER" prefHeight="17.0" prefWidth="82.0" style="-fx-text-fill: #3c77c9;" text="Description:"
HBox.hgrow="NEVER">
<opaqueInsets>
<Insets/>
</opaqueInsets>
</Label>
<TextField fx:id="sampleDescriptionTextField" prefHeight="23.0" prefWidth="714.0"
<TextField fx:id="sampleDescriptionTextField" prefHeight="23.0" prefWidth="639.0"
promptText="Sample Description:" style="-fx-font-size: 12;"/>
</HBox>
<Label style="-fx-text-fill: #3c77c9; -fx-font-weight: bold;" text="Data File Path Name:" GridPane.rowIndex="3"/>
Expand All @@ -77,14 +86,16 @@
style="-fx-text-fill: #3c77c9; -fx-font-weight: bold;" text="Actions:" GridPane.rowIndex="8"/>
<HBox GridPane.columnIndex="1" GridPane.rowIndex="8">
<children>
<ToolBar maxHeight="30.0" minHeight="30.0" prefHeight="30.0" prefWidth="392.0"
<ToolBar maxHeight="30.0" minHeight="30.0" prefHeight="30.0" prefWidth="613.0"
style="-fx-background-color: transparent;">
<Button mnemonicParsing="false" onAction="#selectDataFileButtonAction" text="Load Data File"/>
<Button layoutX="10.0" layoutY="7.0" mnemonicParsing="false" onAction="#selectMethodFileButtonAction"
text="Load Method File"/>
<Button id="MCMC" fx:id="reviewSculptData" mnemonicParsing="false"
onAction="#previewAndSculptDataAction" style="-fx-text-fill: RED;"
text="Preview and Sculpt Data"/>
<Button id="MCMC" fx:id="exportToETReduxButton" layoutX="225.0" layoutY="7.0" mnemonicParsing="false"
onAction="#exportToETReduxButtonAction" style="-fx-text-fill: RED;" text="Export ETRedux"/>
</ToolBar>
<ToolBar fx:id="processingToolBar" maxHeight="30.0" minHeight="30.0" prefHeight="30.0" prefWidth="701.0"
style="-fx-background-color: transparent;">
Expand Down Expand Up @@ -239,16 +250,16 @@
</GridPane>
</content>
</Tab>
<Tab fx:id="selectColumnsToPlot" closable="false" text="SelectColumns to Plot">
<Tab fx:id="selectColumnsToPlot" closable="false" text="Select Columns to Plot">
<content>
<SplitPane dividerPositions="0.5" prefHeight="242.0" prefWidth="1065.0">
<SplitPane dividerPositions="0.75" prefHeight="242.0" prefWidth="1065.0">
<items>
<ScrollPane hbarPolicy="NEVER">
<ScrollPane fx:id="ratiosScrollPane" hbarPolicy="NEVER">
<content>
<VBox fx:id="ratiosVBox" prefHeight="239.0" prefWidth="527.0"/>
<VBox fx:id="ratiosVBox" prefHeight="239.0" prefWidth="797.0"/>
</content>
</ScrollPane>
<ScrollPane hbarPolicy="NEVER">
<ScrollPane fx:id="functionsScrollPane" hbarPolicy="NEVER">
<content>
<VBox fx:id="functionsVBox" prefHeight="239.0" prefWidth="527.0"/>
</content>
Expand All @@ -269,4 +280,4 @@
<HBox fx:id="blockStatusHBox" prefHeight="100.0" prefWidth="200.0"
style="-fx-background-color: white; -fx-border-color: green; -fx-border-width: 2;"
stylesheets="@css/tripoli.css" GridPane.columnIndex="1" GridPane.rowIndex="7"/>
</GridPane>
</GridPane>
1 change: 1 addition & 0 deletions TripoliCore/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@
exports org.cirdles.tripoli.sessions.analysis.massSpectrometerModels.dataModels.dataLiteOne;
exports org.cirdles.tripoli.sessions.analysis.massSpectrometerModels.dataSourceProcessors.phoenix;
exports org.cirdles.tripoli.utilities.mathUtilities;
exports org.cirdles.tripoli.sessions.analysis.outputs.etRedux;
}
Loading