Skip to content

Commit

Permalink
analysis: Fix NPE at relatedness tool. #TASK-6722
Browse files Browse the repository at this point in the history
  • Loading branch information
j-coll committed Nov 29, 2024
1 parent 1d86756 commit 5141031
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.opencb.opencga.analysis.variant.relatedness.RelatednessAnalysis;
import org.opencb.opencga.analysis.wrappers.plink.PlinkWrapperAnalysisExecutor;
import org.opencb.opencga.catalog.exceptions.CatalogException;
import org.opencb.opencga.core.config.Analysis;
import org.opencb.opencga.core.exceptions.ToolException;
import org.opencb.opencga.core.models.family.Family;
import org.opencb.opencga.core.models.individual.Individual;
Expand Down Expand Up @@ -117,7 +118,7 @@ public static RelatednessReport compute(String study, Family family, List<String
} catch (IOException e) {
throw new ToolException("Something wrong happened when copying files during the relatedness analysis execution");
}
File outFile = runIBD(FILTERED_BASENAME, freqPath, outDir);
File outFile = runIBD(FILTERED_BASENAME, freqPath, outDir, storageManager.getCatalogManager().getConfiguration().getAnalysis());

if (!outFile.exists()) {
throw new ToolException("Something wrong happened executing relatedness analysis");
Expand Down Expand Up @@ -298,7 +299,7 @@ public static void filterFamilyTpedFile(Path tPedPath, Path tPedFilteredPath, Pa
bw.close();
}

private static File runIBD(String basename, Path freqPath, Path outDir) throws ToolException {
private static File runIBD(String basename, Path freqPath, Path outDir, Analysis analysisConf) throws ToolException {
// Input bindings
List<AbstractMap.SimpleEntry<String, String>> inputBindings = new ArrayList<>();
inputBindings.add(new AbstractMap.SimpleEntry<>(freqPath.getParent().toString(), "/input"));
Expand All @@ -311,8 +312,8 @@ private static File runIBD(String basename, Path freqPath, Path outDir) throws T
String plinkParams = "plink1.9 --tfile /output/" + basename + " --genome rel-check --read-freq /input/" + FREQ_FILENAME
+ " --out /output/" + basename;
try {
PlinkWrapperAnalysisExecutor plinkExecutor = new PlinkWrapperAnalysisExecutor();
DockerUtils.run(plinkExecutor.getDockerImageName(), inputBindings, outputBinding, plinkParams, null);
String dockerImageName = PlinkWrapperAnalysisExecutor.getDockerImageName(analysisConf);
DockerUtils.run(dockerImageName, inputBindings, outputBinding, plinkParams, null);
} catch (IOException e) {
throw new ToolException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.opencb.opencga.analysis.wrappers.executors.DockerWrapperAnalysisExecutor;
import org.opencb.opencga.core.config.Analysis;
import org.opencb.opencga.core.exceptions.ToolException;
import org.opencb.opencga.core.tools.annotations.ToolExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -21,6 +23,15 @@ public class PlinkWrapperAnalysisExecutor extends DockerWrapperAnalysisExecutor

private Logger logger = LoggerFactory.getLogger(this.getClass());

public static String getDockerImageName(Analysis analysisConf) throws ToolException {
return analysisConf.getOpencgaExtTools().split(":")[0];
}

@Override
public String getDockerImageName() throws ToolException {
return getDockerImageName(getConfiguration().getAnalysis());
}

@Override
protected void run() throws Exception {
StringBuilder sb = initCommandLine();
Expand Down

0 comments on commit 5141031

Please sign in to comment.