change export
package io.github.mzmine.modules.io.export_msn_tree_json;
import io.github.mzmine.datamodel.PrecursorIonTree;
+import io.github.mzmine.datamodel.PrecursorIonTreeNode;
import io.github.mzmine.datamodel.RawDataFile;
+import io.github.mzmine.datamodel.Scan;
import io.github.mzmine.parameters.ParameterSet;
import io.github.mzmine.parameters.parametertypes.tolerances.MZTolerance;
import io.github.mzmine.taskcontrol.AbstractTask;
+import io.github.mzmine.taskcontrol.TaskStatus;
import io.github.mzmine.util.scans.ScanUtils;
import java.io.File;
import java.time.Instant;
+import java.util.ArrayList;
import java.util.List;
public class MSnTreeJsonExportTask extends AbstractTask {
@@ -34,8 +38,8 @@ public class MSnTreeJsonExportTask extends AbstractTask {
private final File outFile;
private final RawDataFile[] raws;
private final MZTolerance mzTol;
- private final int total = 0;
- private final int done = 0;
+ private int total = 0;
+ private int done;
private String description = "Exporting raw files as MSn trees to jsonlines file";
public MSnTreeJsonExportTask(ParameterSet parameters, Instant moduleCallDate) {
@@ -59,11 +63,36 @@ public class MSnTreeJsonExportTask extends AbstractTask {
@Override
public void run() {
+ setStatus(TaskStatus.PROCESSING);
+ total = raws.length;
+
for (RawDataFile raw : raws) {
final List<PrecursorIonTree> trees = ScanUtils.getMSnFragmentTrees(raw);
for (PrecursorIonTree tree : trees) {
- tree.getRoot().getFragmentScans()
+ List<String> lines = treeNodeToCSV(raw, tree.getRoot(), new ArrayList<>());
+ }
+
+ done++;
}
+
+ setStatus(TaskStatus.FINISHED);
+ }
+
+ private List<String> treeNodeToCSV(RawDataFile raw, PrecursorIonTreeNode treeNode,
+ List<String> lines) {
+ // export all spectra
+ for (var spec : treeNode.getFragmentScans()) {
+ spectrumToCSV(raw, spec, lines);
}
+
+ // add children
+ for (var child : treeNode.getChildPrecursors()) {
+ treeNodeToCSV(raw, child, lines);
+ }
+ return lines;
+ }
+
+ private void spectrumToCSV(RawDataFile raw, Scan spec, List<String> lines) {
+
}
}
