Search in sources :

Example 1 with POSITION

use of net.sf.mzmine.modules.rawdatamethods.merge.RawFileMergeParameters.POSITION in project mzmine2 by mzmine.

the class RawFileMergeModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    // merge all selected
    if (parameters.getParameter(RawFileMergeParameters.mode).getValue().equals(MODE.MERGE_SELECTED)) {
        RawDataFile[] raw = parameters.getParameter(RawFileMergeParameters.dataFiles).getValue().getMatchingRawDataFiles();
        RawFileMergeTask task = new RawFileMergeTask(project, parameters, raw);
        tasks.add(task);
    } else {
        // sort files into merge groups
        RawDataFile[] raw = parameters.getParameter(RawFileMergeParameters.dataFiles).getValue().getMatchingRawDataFiles();
        POSITION pos = parameters.getParameter(RawFileMergeParameters.position).getValue();
        String posMarker = parameters.getParameter(RawFileMergeParameters.posMarker).getValue();
        String groupingElement = "";
        List<RawDataFile> current = new ArrayList<>();
        do {
            current.clear();
            for (int i = 0; i < raw.length; i++) {
                if (raw[i] != null) {
                    String group = extractGroup(pos, posMarker, raw[i]);
                    if (current.isEmpty()) {
                        groupingElement = group;
                        current.add(raw[i]);
                        raw[i] = null;
                    } else if (group.equals(groupingElement)) {
                        current.add(raw[i]);
                        raw[i] = null;
                    }
                }
            }
            // run task
            if (current.size() > 1) {
                RawFileMergeTask task = new RawFileMergeTask(project, parameters, current.toArray(new RawDataFile[current.size()]));
                tasks.add(task);
            }
        } while (!current.isEmpty());
    }
    return ExitCode.OK;
}
Also used : POSITION(net.sf.mzmine.modules.rawdatamethods.merge.RawFileMergeParameters.POSITION) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

Aggregations

ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)1 POSITION (net.sf.mzmine.modules.rawdatamethods.merge.RawFileMergeParameters.POSITION)1