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;
}
Aggregations