Skip to content

Commit

Permalink
analysis: improve vcfDestination support, #TASK-7064, #TASK-7049
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Oct 10, 2024
1 parent a53b083 commit ff2a28c
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,15 @@ protected void check() throws Exception {
} else if (!LIFTOVER_VCF_INPUT_FOLDER.equals(vcfDest)) {
File opencgaFile = getCatalogManager().getFileManager().get(study, analysisParams.getVcfDestination(), QueryOptions.empty(),
token).first();
vcfDest = Paths.get(opencgaFile.getUri().getPath()).toAbsolutePath().toString();
if (!Files.exists(Paths.get(vcfDest))) {
throw new ToolException("Liftover 'vcfDestination' parameter (" + analysisParams.getVcfDestination() + ") with folder ("
+ vcfDest + ") does not exist");
Path path = Paths.get(opencgaFile.getUri().getPath()).toAbsolutePath();
if (!Files.exists(path)) {
getCatalogManager().getIoManagerFactory().get(path.toUri()).createDirectory(path.toUri(), true);
}
if (!Files.exists(path)) {
throw new ToolException("Liftover 'vcfDestination' parameter (" + analysisParams.getVcfDestination() + ") but folder ("
+ path + ") does not exist");
}
vcfDest = path.toString();
}
}

Expand Down Expand Up @@ -204,7 +208,8 @@ private void linkOutFile(Path outFile) throws CatalogException, ToolException {
StopWatch stopWatch = StopWatch.createStarted();
FileLinkParams linkParams = new FileLinkParams().setUri(uri.toString());
logger.info("Linking file {}", uri);
OpenCGAResult<File> result = catalogManager.getFileManager().link(getStudy(), linkParams, false, getToken());
// Link 'parents' to true to ensure the directory is created
OpenCGAResult<File> result = catalogManager.getFileManager().link(getStudy(), linkParams, true, getToken());
if (result.getEvents().stream().anyMatch(e -> e.getMessage().equals(ParamConstants.FILE_ALREADY_LINKED))) {
logger.info("File already linked - SKIP");
} else {
Expand Down

0 comments on commit ff2a28c

Please sign in to comment.