-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSawfishAnalysis.java
More file actions
105 lines (87 loc) · 3.75 KB
/
SawfishAnalysis.java
File metadata and controls
105 lines (87 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package org.labkey.sequenceanalysis.run.analysis;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.pipeline.PipelineJobException;
import org.labkey.api.sequenceanalysis.model.AnalysisModel;
import org.labkey.api.sequenceanalysis.model.Readset;
import org.labkey.api.sequenceanalysis.pipeline.AbstractAnalysisStepProvider;
import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStep;
import org.labkey.api.sequenceanalysis.pipeline.AnalysisOutputImpl;
import org.labkey.api.sequenceanalysis.pipeline.AnalysisStep;
import org.labkey.api.sequenceanalysis.pipeline.PipelineContext;
import org.labkey.api.sequenceanalysis.pipeline.PipelineStepProvider;
import org.labkey.api.sequenceanalysis.pipeline.ReferenceGenome;
import org.labkey.api.sequenceanalysis.pipeline.SamtoolsIndexer;
import org.labkey.api.sequenceanalysis.pipeline.SamtoolsRunner;
import org.labkey.api.sequenceanalysis.pipeline.SequencePipelineService;
import org.labkey.api.sequenceanalysis.run.SimpleScriptWrapper;
import org.labkey.sequenceanalysis.util.SequenceUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class SawfishAnalysis extends AbstractPipelineStep implements AnalysisStep
{
public SawfishAnalysis(PipelineStepProvider<?> provider, PipelineContext ctx)
{
super(provider, ctx);
}
public static class Provider extends AbstractAnalysisStepProvider<SawfishAnalysis>
{
public Provider()
{
super("sawfish", "Sawfish Analysis", null, "This will run sawfish SV dicvoery and calling on the selected BAMs", List.of(), null, null);
}
@Override
public SawfishAnalysis create(PipelineContext ctx)
{
return new SawfishAnalysis(this, ctx);
}
}
@Override
public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, ReferenceGenome referenceGenome, File outputDir) throws PipelineJobException
{
AnalysisOutputImpl output = new AnalysisOutputImpl();
List<String> args = new ArrayList<>();
args.add(getExe().getPath());
args.add("discover");
args.add("--bam");
args.add(inputBam.getPath());
// NOTE: sawfish stores the absolute path of the FASTA in the output JSON, so dont rely on working copies:
args.add("--ref");
args.add(referenceGenome.getSourceFastaFile().getPath());
File svOutDir = new File(outputDir, "sawfish");
args.add("--output-dir");
args.add(svOutDir.getPath());
Integer maxThreads = SequencePipelineService.get().getMaxThreads(getPipelineCtx().getLogger());
if (maxThreads != null)
{
args.add("--threads");
args.add(String.valueOf(maxThreads));
}
File bcf = new File(svOutDir, "candidate.sv.bcf");
File bcfIdx = new File(bcf.getPath() + ".csi");
if (bcfIdx.exists())
{
getPipelineCtx().getLogger().debug("BCF index already exists, reusing output");
}
else
{
new SimpleScriptWrapper(getPipelineCtx().getLogger()).execute(args);
}
if (!bcf.exists())
{
throw new PipelineJobException("Unable to find file: " + bcf.getPath());
}
output.addSequenceOutput(bcf, rs.getName() + ": sawfish", "Sawfish SV Discovery", rs.getReadsetId(), null, referenceGenome.getGenomeId(), null);
return output;
}
@Override
public Output performAnalysisPerSampleLocal(AnalysisModel model, File inputBam, File referenceFasta, File outDir) throws PipelineJobException
{
return null;
}
private File getExe()
{
return SequencePipelineService.get().getExeForPackage("SAWFISHPATH", "sawfish");
}
}