Skip to content

Commit e759e99

Browse files
committed
Allow user-supplied minInsertSize param for pindel
1 parent f9d6ead commit e759e99

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/analysis/LofreqAnalysis.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,13 @@ public Provider()
125125
ToolParameterDescriptor.create("minDepth", "Pindel Min Depth To Report", "Only variants representing at least this many reads (based on depth at the start position) will be reported.", "ldk-integerfield", new JSONObject()
126126
{{
127127
put("minValue", 0);
128-
}}, 10)
128+
}}, 10),
129+
ToolParameterDescriptor.create("minInsertSize", "Min Insert Size", "Normally this tool will use the value of Picard CollectInsertSizeMetrics as the mean insert size to pass to pindel; however, this value can be used to set a minimum.", "ldk-integerfield", new JSONObject()
130+
{{
131+
put("minValue", 0);
132+
}}, 200)
129133

130-
), PageFlowUtil.set("sequenceanalysis/field/GenomeFileSelectorField.js"), "http://csb5.github.io/lofreq/");
134+
), PageFlowUtil.set("sequenceanalysis/field/GenomeFileSelectorField.js"), "http://csb5.github.io/lofreq/");
131135
}
132136

133137

@@ -583,7 +587,9 @@ public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, Referenc
583587

584588
Double minFraction = getProvider().getParameterByName("minFraction").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Double.class, 0.0);
585589
int minDepth = getProvider().getParameterByName("minDepth").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Integer.class, 0);
586-
PindelAnalysis.runPindel(output, getPipelineCtx(), rs, outputDir, inputBam, referenceGenome.getWorkingFastaFile(), minFraction, minDepth, true, coverageOut);
590+
int minInsertSize = getProvider().getParameterByName("minInsertSize").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Integer.class, 0);
591+
592+
PindelAnalysis.runPindel(output, getPipelineCtx(), rs, outputDir, inputBam, referenceGenome.getWorkingFastaFile(), minFraction, minDepth, true, coverageOut, minInsertSize);
587593

588594
return output;
589595
}

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/analysis/PindelAnalysis.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public Provider()
5858
{{
5959
put("minValue", 0);
6060
}}, 10),
61+
ToolParameterDescriptor.create("minInsertSize", "Min Insert Size", "Normally this tool will use the value of Picard CollectInsertSizeMetrics as the mean insert size to pass to pindel; however, this value can be used to set a minimum.", "ldk-integerfield", new JSONObject()
62+
{{
63+
put("minValue", 0);
64+
}}, 200),
6165
ToolParameterDescriptor.create("writeToBamDir", "Write To BAM Dir", "If checked, outputs will be written to the BAM folder, as opposed to the output folder for this job.", "checkbox", new JSONObject(){{
6266

6367
}}, false),
@@ -84,12 +88,13 @@ public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, Referenc
8488
boolean removeDuplicates = getProvider().getParameterByName("removeDuplicates").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Boolean.class, false);
8589
Double minFraction = getProvider().getParameterByName("minFraction").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Double.class, 0.0);
8690
int minDepth = getProvider().getParameterByName("minDepth").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Integer.class, 0);
91+
int minInsertSize = getProvider().getParameterByName("minInsertSize").extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx(), Integer.class, 200);
8792

8893
File gatkDepth = new File(inputBam.getParentFile(), FileUtil.getBaseName(inputBam) + ".coverage");
8994
LofreqAnalysis.runDepthOfCoverage(getPipelineCtx(), output, outputDir, referenceGenome, inputBam, gatkDepth);
9095

9196
File out = writeToBamDir ? inputBam.getParentFile() : outputDir;
92-
File summary = runPindel(output, getPipelineCtx(), rs, out, inputBam, referenceGenome.getWorkingFastaFile(), minFraction, minDepth, removeDuplicates, gatkDepth);
97+
File summary = runPindel(output, getPipelineCtx(), rs, out, inputBam, referenceGenome.getWorkingFastaFile(), minFraction, minDepth, removeDuplicates, gatkDepth, minInsertSize);
9398
long lineCount = SequencePipelineService.get().getLineCount(summary) - 1;
9499
if (lineCount > 0)
95100
{
@@ -109,7 +114,7 @@ public Output performAnalysisPerSampleLocal(AnalysisModel model, File inputBam,
109114
return null;
110115
}
111116

112-
private static String parseInsertMetrics(File inputFile) throws IOException
117+
private static String parseInsertMetrics(File inputFile, int minInsertSize) throws IOException
113118
{
114119
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile), StringUtilsLabKey.DEFAULT_CHARSET)))
115120
{
@@ -121,20 +126,16 @@ private static String parseInsertMetrics(File inputFile) throws IOException
121126
if (m.PAIR_ORIENTATION == SamPairUtil.PairOrientation.FR)
122127
{
123128
Double insertSize = Math.ceil(m.MEAN_INSERT_SIZE);
124-
if (insertSize < 75)
125-
{
126-
insertSize = insertSize + 150;
127-
}
128129

129-
return String.valueOf(Math.max(200, insertSize.intValue()));
130+
return String.valueOf(Math.max(minInsertSize, insertSize.intValue()));
130131
}
131132
}
132133
}
133134

134135
return null;
135136
}
136137

137-
private static String inferInsertSize(PipelineContext ctx, File bam) throws PipelineJobException
138+
private static String inferInsertSize(PipelineContext ctx, File bam, int minInsertSize) throws PipelineJobException
138139
{
139140
File expectedPicard = new File(bam.getParentFile(), FileUtil.getBaseName(bam.getName()) + ".insertsize.metrics");
140141
if (!expectedPicard.exists())
@@ -147,14 +148,14 @@ private static String inferInsertSize(PipelineContext ctx, File bam) throws Pipe
147148

148149
if (!expectedPicard.exists())
149150
{
150-
ctx.getLogger().error("CollectInsertSizeMetrics output not found, defaulting to 100 as insert size");
151-
return("100");
151+
ctx.getLogger().error("CollectInsertSizeMetrics output not found, defaulting to " + minInsertSize + " as insert size");
152+
return(String.valueOf(minInsertSize));
152153
}
153154
}
154155

155156
try
156157
{
157-
String ret = parseInsertMetrics(expectedPicard);
158+
String ret = parseInsertMetrics(expectedPicard, minInsertSize);
158159
if (ret != null)
159160
{
160161
return ret;
@@ -170,7 +171,7 @@ private static String inferInsertSize(PipelineContext ctx, File bam) throws Pipe
170171
return "100";
171172
}
172173

173-
public static File runPindel(AnalysisOutputImpl output, PipelineContext ctx, Readset rs, File outDir, File inputBam, File fasta, double minFraction, int minDepth, boolean removeDuplicates, File gatkDepth) throws PipelineJobException
174+
public static File runPindel(AnalysisOutputImpl output, PipelineContext ctx, Readset rs, File outDir, File inputBam, File fasta, double minFraction, int minDepth, boolean removeDuplicates, File gatkDepth, int minInsertSize) throws PipelineJobException
174175
{
175176
File bamToUse = removeDuplicates ? new File(outDir, FileUtil.getBaseName(inputBam) + ".rmdup.bam") : inputBam;
176177
if (removeDuplicates)
@@ -194,7 +195,7 @@ public static File runPindel(AnalysisOutputImpl output, PipelineContext ctx, Rea
194195
File pindelParams = new File(outDir, "pindelCfg.txt");
195196
try (CSVWriter writer = new CSVWriter(PrintWriters.getPrintWriter(pindelParams), '\t', CSVWriter.NO_QUOTE_CHARACTER))
196197
{
197-
String insertSize = inferInsertSize(ctx, inputBam);
198+
String insertSize = inferInsertSize(ctx, inputBam, minInsertSize);
198199
writer.writeNext(new String[]{bamToUse.getPath(), insertSize, FileUtil.makeLegalName(rs.getName())});
199200
}
200201
catch (IOException e)

0 commit comments

Comments
 (0)