|
1 | 1 | package org.baderlab.csplugins.enrichmentmap;
|
2 | 2 |
|
3 |
| -import static java.lang.annotation.RetentionPolicy.RUNTIME; |
4 |
| - |
5 |
| -import java.lang.annotation.Retention; |
6 |
| - |
7 | 3 | import org.baderlab.csplugins.enrichmentmap.actions.OpenEnrichmentMapAction;
|
8 | 4 | import org.baderlab.csplugins.enrichmentmap.commands.ChartCommandTask;
|
9 | 5 | import org.baderlab.csplugins.enrichmentmap.commands.DatasetShowCommandTask;
|
10 | 6 | import org.baderlab.csplugins.enrichmentmap.commands.EMBuildCommandTask;
|
11 | 7 | import org.baderlab.csplugins.enrichmentmap.commands.EMGseaCommandTask;
|
12 | 8 | import org.baderlab.csplugins.enrichmentmap.commands.ExportModelJsonCommandTask;
|
13 | 9 | import org.baderlab.csplugins.enrichmentmap.commands.ExportPDFCommandTask;
|
| 10 | +import org.baderlab.csplugins.enrichmentmap.commands.MastermapCommandTask; |
| 11 | +import org.baderlab.csplugins.enrichmentmap.commands.MastermapListCommandTask; |
14 | 12 | import org.baderlab.csplugins.enrichmentmap.commands.PAKnownSignatureCommandTask;
|
15 |
| -import org.baderlab.csplugins.enrichmentmap.commands.ResolverCommandTask; |
16 | 13 | import org.baderlab.csplugins.enrichmentmap.commands.TableCommandTask;
|
17 |
| -import org.cytoscape.work.AbstractTaskFactory; |
18 |
| -import org.cytoscape.work.Task; |
19 |
| -import org.cytoscape.work.TaskFactory; |
20 |
| -import org.cytoscape.work.TaskIterator; |
21 | 14 |
|
22 | 15 | import com.google.inject.AbstractModule;
|
23 |
| -import com.google.inject.BindingAnnotation; |
24 | 16 | import com.google.inject.Provider;
|
25 |
| -import com.google.inject.Provides; |
| 17 | +import com.google.inject.multibindings.MultibindingsScanner; |
| 18 | +import com.google.inject.multibindings.ProvidesIntoSet; |
26 | 19 |
|
27 | 20 | public class CommandModule extends AbstractModule {
|
28 | 21 |
|
29 |
| - @BindingAnnotation @Retention(RUNTIME) public @interface BuildCommand { } |
30 |
| - @BindingAnnotation @Retention(RUNTIME) public @interface GSEACommand { } |
31 |
| - @BindingAnnotation @Retention(RUNTIME) public @interface ResolveCommand { } |
32 |
| - @BindingAnnotation @Retention(RUNTIME) public @interface PACommand { } |
33 |
| - @BindingAnnotation @Retention(RUNTIME) public @interface JsonCommand { } |
34 |
| - @BindingAnnotation @Retention(RUNTIME) public @interface BuildTableCommand { } |
35 |
| - @BindingAnnotation @Retention(RUNTIME) public @interface DatasetShowCommand { } |
36 |
| - @BindingAnnotation @Retention(RUNTIME) public @interface DatasetHideCommand { } |
37 |
| - @BindingAnnotation @Retention(RUNTIME) public @interface ChartCommand { } |
38 |
| - @BindingAnnotation @Retention(RUNTIME) public @interface ExportPDFCommand { } |
39 |
| - |
40 | 22 | @Override
|
41 |
| - protected void configure() { |
| 23 | + protected void configure() { |
| 24 | + install(MultibindingsScanner.asModule()); |
42 | 25 | }
|
43 | 26 |
|
44 |
| - @Provides @BuildCommand |
45 |
| - public TaskFactory provideBuild(Provider<EMBuildCommandTask> taskProvider, OpenEnrichmentMapAction showTask) { |
46 |
| - return createTaskFactory(taskProvider, showTask); |
47 |
| - } |
48 | 27 |
|
49 |
| - @Provides @GSEACommand |
50 |
| - public TaskFactory provideGSEA(Provider<EMGseaCommandTask> taskProvider, OpenEnrichmentMapAction showTask) { |
51 |
| - return createTaskFactory(taskProvider, showTask); |
| 28 | + @ProvidesIntoSet |
| 29 | + public CommandTaskFactory provideBuild(Provider<EMBuildCommandTask> taskProvider, OpenEnrichmentMapAction showTask) { |
| 30 | + String desc = "Creates an EnrichmentMap network containing one or two data sets."; |
| 31 | + return CommandTaskFactory.create("build", desc, null, taskProvider, showTask); |
52 | 32 | }
|
53 | 33 |
|
54 |
| - @Provides @ResolveCommand |
55 |
| - public TaskFactory provideResolve(Provider<ResolverCommandTask> taskProvider, OpenEnrichmentMapAction showTask) { |
56 |
| - return createTaskFactory(taskProvider, showTask); |
| 34 | + @ProvidesIntoSet |
| 35 | + public CommandTaskFactory provideGSEA(Provider<EMGseaCommandTask> taskProvider, OpenEnrichmentMapAction showTask) { |
| 36 | + String desc = "Creates an EnrichmetMap network from one or two GSEA results. (Deprecated, use 'build' or 'mastermap' command instead.)"; |
| 37 | + return CommandTaskFactory.create("gseabuild", desc, null, taskProvider, showTask); |
57 | 38 | }
|
58 | 39 |
|
59 |
| - @Provides @PACommand |
60 |
| - public TaskFactory providePA(Provider<PAKnownSignatureCommandTask> taskProvider) { |
61 |
| - return createTaskFactory(taskProvider); |
| 40 | + @ProvidesIntoSet |
| 41 | + public CommandTaskFactory provideMastermap(Provider<MastermapCommandTask> taskProvider, OpenEnrichmentMapAction showTask) { |
| 42 | + String desc = "Creates an EnrichmentMap network containing any number of data sets by scanning files in a folder."; |
| 43 | + String longDesc = "Uses the same algorithm as the Create EnrichmentMap Dialog to scan the files in a folder and " |
| 44 | + + "automatically group them into data sets. Sub-folders will be scanned up to one level deep, allowing you to " |
| 45 | + + "organize your data sets into sub-folders under the root folder. Please see the EnrichmentMap documentation " |
| 46 | + + "for more details on how files are chosen for each data set."; |
| 47 | + return CommandTaskFactory.create("mastermap", desc, longDesc, taskProvider, showTask); |
62 | 48 | }
|
63 | 49 |
|
64 |
| - @Provides @JsonCommand |
65 |
| - public TaskFactory provideJson(Provider<ExportModelJsonCommandTask> taskProvider) { |
66 |
| - return createTaskFactory(taskProvider); |
| 50 | + @ProvidesIntoSet |
| 51 | + public CommandTaskFactory provideMastermapList(Provider<MastermapListCommandTask> taskProvider) { |
| 52 | + String desc = "Scans files in a folder and prints out how they would be grouped into data sets, but does not create a network. " |
| 53 | + + "This command is intended to help debug the 'mastermap' command by showing how the files will be grouped into data sets " |
| 54 | + + "without actually creating the network."; |
| 55 | + return CommandTaskFactory.create("mastermap list", desc, null, taskProvider); |
67 | 56 | }
|
68 | 57 |
|
69 |
| - @Provides @BuildTableCommand |
70 |
| - public TaskFactory provideBuildTable(Provider<TableCommandTask> taskProvider, OpenEnrichmentMapAction showTask) { |
71 |
| - return createTaskFactory(taskProvider, showTask); |
| 58 | + @ProvidesIntoSet |
| 59 | + public CommandTaskFactory providePA(Provider<PAKnownSignatureCommandTask> taskProvider) { |
| 60 | + String desc = "Adds more gene sets to an existing network. This is done by calculating the overlap between gene sets of the " |
| 61 | + + "current EnrichmentMap network and all the gene sets contained in the provided signature gene set file."; |
| 62 | + return CommandTaskFactory.create("pa", desc, null, taskProvider); |
72 | 63 | }
|
73 | 64 |
|
74 |
| - @Provides @DatasetShowCommand |
75 |
| - public TaskFactory provideDatasetShow(DatasetShowCommandTask.Factory taskFactory) { |
76 |
| - return createTaskFactory(() -> taskFactory.create(true)); |
| 65 | + @ProvidesIntoSet |
| 66 | + public CommandTaskFactory provideJson(Provider<ExportModelJsonCommandTask> taskProvider) { |
| 67 | + String desc = "Exports the EnrichmentMap data model to a file. Intended mainly for debugging."; |
| 68 | + return CommandTaskFactory.create("export model", desc, null, taskProvider); |
77 | 69 | }
|
78 | 70 |
|
79 |
| - @Provides @DatasetHideCommand |
80 |
| - public TaskFactory provideDatasetHide(DatasetShowCommandTask.Factory taskFactory) { |
81 |
| - return createTaskFactory(() -> taskFactory.create(false)); |
| 71 | + @ProvidesIntoSet |
| 72 | + public CommandTaskFactory provideBuildTable(Provider<TableCommandTask> taskProvider, OpenEnrichmentMapAction showTask) { |
| 73 | + String desc = "Creates an EnrichmentMap network from values in a table."; |
| 74 | + String longDesc = "Intended mainly for other Apps to programatically create an EnrichmentMap network."; |
| 75 | + return CommandTaskFactory.create("build-table", desc, longDesc, taskProvider, showTask); |
82 | 76 | }
|
83 | 77 |
|
84 |
| - @Provides @ChartCommand |
85 |
| - public TaskFactory provideChart(Provider<ChartCommandTask> taskFactory) { |
86 |
| - return createTaskFactory(taskFactory); |
| 78 | + @ProvidesIntoSet |
| 79 | + public CommandTaskFactory provideDatasetShow(DatasetShowCommandTask.Factory taskFactory) { |
| 80 | + String desc = "Allows to select the data sets to show in an EnrichmentMap network."; |
| 81 | + String longDesc = "This command is basically the same as clicking the checkboxes next to the data sets in the main EnrichmentMap panel."; |
| 82 | + return CommandTaskFactory.create("dataset show", desc, longDesc, () -> taskFactory.create(true)); |
87 | 83 | }
|
88 | 84 |
|
89 |
| - @Provides @ExportPDFCommand |
90 |
| - public TaskFactory provideExportPDF(Provider<ExportPDFCommandTask> taskProvider) { |
91 |
| - return createTaskFactory(taskProvider); |
| 85 | + @ProvidesIntoSet |
| 86 | + public CommandTaskFactory provideDatasetHide(DatasetShowCommandTask.Factory taskFactory) { |
| 87 | + String desc = "Allows to de-select the data sets to show in an EnrichmentMap network."; |
| 88 | + String longDesc = "This command is basically the same as clicking the checkboxes next to the data sets in the main EnrichmentMap panel."; |
| 89 | + return CommandTaskFactory.create("dataset hide", desc, longDesc, () -> taskFactory.create(false)); |
92 | 90 | }
|
93 | 91 |
|
94 |
| - |
95 |
| - private static TaskFactory createTaskFactory(Provider<? extends Task> taskProvider, Task ... tasks) { |
96 |
| - return new AbstractTaskFactory() { |
97 |
| - @Override |
98 |
| - public TaskIterator createTaskIterator() { |
99 |
| - TaskIterator taskIterator = new TaskIterator(taskProvider.get()); |
100 |
| - for(Task task : tasks) { |
101 |
| - taskIterator.append(task); |
102 |
| - } |
103 |
| - return taskIterator; |
104 |
| - } |
105 |
| - }; |
| 92 | + @ProvidesIntoSet |
| 93 | + public CommandTaskFactory provideChart(Provider<ChartCommandTask> taskFactory) { |
| 94 | + String desc = "Sets the chart options for an EnrichmentMap network."; |
| 95 | + String longDesc = "This command is basically the same as setting the chart options in the main EnrichmentMap panel."; |
| 96 | + return CommandTaskFactory.create("chart", desc, longDesc, taskFactory); |
106 | 97 | }
|
107 | 98 |
|
| 99 | + @ProvidesIntoSet |
| 100 | + public CommandTaskFactory provideExportPDF(Provider<ExportPDFCommandTask> taskProvider) { |
| 101 | + String desc = "Exports the contents of the Heat Map panel to a PDF file."; |
| 102 | + return CommandTaskFactory.create("export pdf", desc, null, taskProvider); |
| 103 | + } |
| 104 | + |
108 | 105 | }
|
0 commit comments