-
Notifications
You must be signed in to change notification settings - Fork 2
Let users launch NextFlow from file browser #470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
labkey-jeckels
merged 1 commit into
release24.11-SNAPSHOT
from
24.11_fb_nextFlowLauncher
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
98 changes: 87 additions & 11 deletions
98
nextflow/src/org/labkey/nextflow/pipeline/NextFlowPipelineJob.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,44 +1,120 @@ | ||
| package org.labkey.nextflow.pipeline; | ||
|
|
||
| import lombok.Getter; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.labkey.api.data.Container; | ||
| import org.labkey.api.files.FileContentService; | ||
| import org.labkey.api.pipeline.ParamParser; | ||
| import org.labkey.api.pipeline.PipeRoot; | ||
| import org.labkey.api.pipeline.PipelineJob; | ||
| import org.labkey.api.pipeline.PipelineJobService; | ||
| import org.labkey.api.pipeline.TaskId; | ||
| import org.labkey.api.pipeline.TaskPipeline; | ||
| import org.labkey.api.pipeline.file.AbstractFileAnalysisJob; | ||
| import org.labkey.api.util.FileUtil; | ||
| import org.labkey.api.util.URLHelper; | ||
| import org.labkey.api.util.PageFlowUtil; | ||
| import org.labkey.api.view.ViewBackgroundInfo; | ||
|
|
||
| import java.io.BufferedWriter; | ||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.util.List; | ||
|
|
||
| public class NextFlowPipelineJob extends PipelineJob | ||
| @Getter | ||
| public class NextFlowPipelineJob extends AbstractFileAnalysisJob | ||
| { | ||
| private Path config; | ||
|
|
||
| @SuppressWarnings("unused") // For serialization | ||
| protected NextFlowPipelineJob() | ||
| {} | ||
|
|
||
| public NextFlowPipelineJob(ViewBackgroundInfo info, @NotNull PipeRoot root) | ||
| public static NextFlowPipelineJob create(ViewBackgroundInfo info, @NotNull PipeRoot root, Path templateConfig, List<Path> inputFiles) throws IOException | ||
| { | ||
| super(null, info, root); | ||
| setLogFile(new File(String.valueOf(root.getLogDirectory()), FileUtil.makeFileNameWithTimestamp("NextFlowPipelineJob", "log")).toPath()); | ||
| Path parentDir = inputFiles.get(0).getParent(); | ||
|
|
||
| String jobName = FileUtil.makeFileNameWithTimestamp("NextFlow"); | ||
| Path jobDir = parentDir.resolve(jobName); | ||
| Path log = jobDir.resolve(jobName + ".log"); | ||
| FileUtil.createDirectory(jobDir); | ||
|
|
||
| Path config = createConfig(templateConfig, log.getParent(), jobDir, info.getContainer()); | ||
|
|
||
| return new NextFlowPipelineJob(info, root, config, inputFiles, log); | ||
| } | ||
|
|
||
| @Override | ||
| public URLHelper getStatusHref() | ||
| public NextFlowPipelineJob(ViewBackgroundInfo info, @NotNull PipeRoot root, Path config, List<Path> inputFiles, Path log) throws IOException | ||
| { | ||
| return null; | ||
| super(new NextFlowProtocol(), NextFlowPipelineProvider.NAME, info, root, config.getFileName().toString(), config, inputFiles, false, false); | ||
| this.config = config; | ||
| setLogFile(log); | ||
| } | ||
|
|
||
| @Override | ||
| public ParamParser getInputParameters() | ||
| { | ||
| return PipelineJobService.get().createParamParser(); | ||
| } | ||
|
|
||
| /** Take the template config file and substitute in the values for this job */ | ||
| private static Path createConfig(Path configTemplate, Path parentDir, Path jobDir, Container container) throws IOException | ||
| { | ||
| String template; | ||
| try (InputStream in = Files.newInputStream(configTemplate)) | ||
| { | ||
| template = PageFlowUtil.getStreamContentsAsString(in); | ||
| } | ||
|
|
||
| String webdavUrl = FileContentService.get().getWebDavUrl(parentDir, container, FileContentService.PathType.full); | ||
| webdavUrl = StringUtils.stripEnd(webdavUrl, "/"); | ||
|
|
||
| String substitutedContent = template.replace("${quant_spectra_dir}", "quant_spectra_dir = '" + webdavUrl + "'"); | ||
|
|
||
| Path substitutedFile = jobDir.resolve(configTemplate.getFileName()); | ||
| try (BufferedWriter writer = Files.newBufferedWriter(substitutedFile)) | ||
| { | ||
| writer.write(substitutedContent); | ||
| } | ||
| return substitutedFile; | ||
| } | ||
|
|
||
| @Override | ||
| public String getDescription() | ||
| { | ||
| return "NextFlow Job"; | ||
| return "NextFlow analysis using " + config.getFileName() + " of " + getInputFilePaths().size() + " files"; | ||
| } | ||
|
|
||
| @Override | ||
| public TaskPipeline<?> getTaskPipeline() | ||
| { | ||
| return PipelineJobService.get().getTaskPipeline(new TaskId(NextFlowPipelineJob.class)); | ||
| return PipelineJobService.get().getTaskPipeline(getTaskPipelineId()); | ||
| } | ||
|
|
||
| @Override | ||
| public TaskId getTaskPipelineId() | ||
| { | ||
| return new TaskId(NextFlowPipelineJob.class); | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractFileAnalysisJob createSingleFileJob(File file) | ||
| { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public File findInputFile(String name) | ||
| { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public File findOutputFile(String name) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.