-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
436896a
commit 6e5eac6
Showing
14 changed files
with
527 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...o/github/mzmine/modules/visualization/projectmetadata/io/ProjectMetadataExportModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (c) 2004-2024 The mzmine Development Team | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package io.github.mzmine.modules.visualization.projectmetadata.io; | ||
|
||
import io.github.mzmine.datamodel.MZmineProject; | ||
import io.github.mzmine.modules.MZmineModuleCategory; | ||
import io.github.mzmine.modules.MZmineProcessingModule; | ||
import io.github.mzmine.parameters.ParameterSet; | ||
import io.github.mzmine.taskcontrol.Task; | ||
import io.github.mzmine.util.ExitCode; | ||
import java.time.Instant; | ||
import java.util.Collection; | ||
import java.util.logging.Logger; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class ProjectMetadataExportModule implements MZmineProcessingModule { | ||
|
||
private static final Logger logger = Logger.getLogger( | ||
ProjectMetadataExportModule.class.getName()); | ||
|
||
private static final String MODULE_NAME = "Project metadata export"; | ||
private static final String MODULE_DESCRIPTION = "This module exports metadata to .tsv or .csv-format."; | ||
|
||
@Override | ||
public @NotNull String getName() { | ||
return MODULE_NAME; | ||
} | ||
|
||
@Override | ||
public @NotNull String getDescription() { | ||
return MODULE_DESCRIPTION; | ||
} | ||
|
||
@Override | ||
public @Nullable Class<? extends ParameterSet> getParameterSetClass() { | ||
return ProjectMetadataImportParameters.class; | ||
} | ||
|
||
@Override | ||
public @NotNull MZmineModuleCategory getModuleCategory() { | ||
return MZmineModuleCategory.PROJECTMETADATA; | ||
} | ||
|
||
@Override | ||
public @NotNull ExitCode runModule(@NotNull MZmineProject project, | ||
@NotNull ParameterSet parameters, @NotNull Collection<Task> tasks, | ||
@NotNull Instant moduleCallDate) { | ||
tasks.add(new ProjectMetadataExportTask(moduleCallDate, parameters)); | ||
|
||
return ExitCode.OK; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...thub/mzmine/modules/visualization/projectmetadata/io/ProjectMetadataExportParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2004-2024 The mzmine Development Team | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package io.github.mzmine.modules.visualization.projectmetadata.io; | ||
|
||
import io.github.mzmine.parameters.ParameterSet; | ||
import io.github.mzmine.parameters.impl.SimpleParameterSet; | ||
import io.github.mzmine.parameters.parametertypes.ComboParameter; | ||
import io.github.mzmine.parameters.parametertypes.filenames.FileNameParameter; | ||
import io.github.mzmine.parameters.parametertypes.filenames.FileSelectionType; | ||
import io.github.mzmine.util.files.ExtensionFilters; | ||
import java.io.File; | ||
|
||
public class ProjectMetadataExportParameters extends SimpleParameterSet { | ||
|
||
public enum MetadataFileFormat { | ||
DEFAULT, | ||
/** | ||
* Adds additional headers for data types | ||
*/ | ||
MZMINE_INTERNAL, | ||
/** | ||
* GNPS requires Filename and then all other columns with ATTRIBUTE_ prefix | ||
*/ | ||
GNPS; | ||
|
||
@Override | ||
public String toString() { | ||
return switch (this) { | ||
case DEFAULT -> "Default"; | ||
case MZMINE_INTERNAL -> "mzmine internal"; | ||
case GNPS -> "GNPS"; | ||
}; | ||
} | ||
} | ||
|
||
public static final FileNameParameter fileName = new FileNameParameter("Metadata file", """ | ||
CSV or TSV file to save metadata to.""", ExtensionFilters.CSV_TSV_EXPORT, | ||
FileSelectionType.SAVE); | ||
|
||
public static final ComboParameter<MetadataFileFormat> format = new ComboParameter<>("Format", | ||
"Format to export the metadata in", MetadataFileFormat.values(), MetadataFileFormat.DEFAULT); | ||
|
||
public ProjectMetadataExportParameters() { | ||
super(fileName, format); | ||
} | ||
|
||
public static ParameterSet create(final File file, final MetadataFileFormat mFormat) { | ||
ParameterSet params = new ProjectMetadataExportParameters().cloneParameterSet(); | ||
params.setParameter(fileName, file); | ||
params.setParameter(format, mFormat); | ||
return params; | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
.../io/github/mzmine/modules/visualization/projectmetadata/io/ProjectMetadataExportTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2004-2024 The mzmine Development Team | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package io.github.mzmine.modules.visualization.projectmetadata.io; | ||
|
||
import io.github.mzmine.modules.visualization.projectmetadata.io.ProjectMetadataExportParameters.MetadataFileFormat; | ||
import io.github.mzmine.modules.visualization.projectmetadata.table.MetadataTable; | ||
import io.github.mzmine.parameters.ParameterSet; | ||
import io.github.mzmine.project.ProjectService; | ||
import io.github.mzmine.taskcontrol.AbstractSimpleToolTask; | ||
import java.io.File; | ||
import java.time.Instant; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ProjectMetadataExportTask extends AbstractSimpleToolTask { | ||
|
||
private final File file; | ||
private final MetadataFileFormat format; | ||
|
||
/** | ||
* @param moduleCallDate the call date of module to order execution order | ||
*/ | ||
public ProjectMetadataExportTask(final @NotNull Instant moduleCallDate, | ||
@NotNull final ParameterSet parameters) { | ||
super(moduleCallDate, parameters); | ||
file = parameters.getValue(ProjectMetadataExportParameters.fileName); | ||
format = parameters.getValue(ProjectMetadataExportParameters.format); | ||
} | ||
|
||
@Override | ||
protected void process() { | ||
MetadataTable metadata = ProjectService.getProject().getProjectMetadata(); | ||
ProjectMetadataWriter writer = new ProjectMetadataWriter(metadata, format); | ||
if (!writer.exportTo(file)) { | ||
error("Error during metadata file export"); | ||
return; | ||
} | ||
} | ||
|
||
@Override | ||
public String getTaskDescription() { | ||
return "Exporting project metadata to file"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.