Skip to content

Commit e0866a8

Browse files
committed
Migrate DepthOfCoverage to GARK4
1 parent 4854557 commit e0866a8

File tree

5 files changed

+89
-36
lines changed

5 files changed

+89
-36
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/bampostprocessing/IndelRealignerStep.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public Provider()
3838
{{
3939
put("checked", false);
4040
}}, false),
41+
//TODO: consider supporting:
42+
//--maxReadsForRealignment
43+
//--maxReadsForConsensuses
44+
4145
ToolParameterDescriptor.create("minRamPerQueueJob", "Min RAM Per Queue Job", "This only applies if queue is checked. If provided, the scatter count (number of jobs) for queue will be adjusted to ensure at least this amount of RAM, in GB, is available for each job", "ldk-integerfield", null, null)
4246
), null, "http://www.broadinstitute.org/gatk/gatkdocs/org_broadinstitute_sting_gatk_walkers_indels_IndelRealigner.html");
4347
}

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/util/DepthOfCoverageWrapper.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.apache.log4j.Logger;
44
import org.jetbrains.annotations.Nullable;
55
import org.labkey.api.pipeline.PipelineJobException;
6-
import org.labkey.api.sequenceanalysis.run.AbstractGatkWrapper;
6+
import org.labkey.api.sequenceanalysis.run.AbstractGatk4Wrapper;
77

88
import java.io.File;
99
import java.util.ArrayList;
@@ -13,7 +13,7 @@
1313
/**
1414
* Created by bimber on 4/24/2017.
1515
*/
16-
public class DepthOfCoverageWrapper extends AbstractGatkWrapper
16+
public class DepthOfCoverageWrapper extends AbstractGatk4Wrapper
1717
{
1818
public DepthOfCoverageWrapper(Logger log)
1919
{
@@ -28,7 +28,6 @@ public void run(List<File> inputBams, String outputBaseName, File referenceFasta
2828
public void run(List<File> inputBams, String outputBaseName, File referenceFasta, @Nullable List<String> options, boolean deleteExtraFiles) throws PipelineJobException
2929
{
3030
List<String> args = new ArrayList<>(getBaseArgs());
31-
args.add("-T");
3231
args.add("DepthOfCoverage");
3332
args.add("-R");
3433
args.add(referenceFasta.getPath());
@@ -37,7 +36,7 @@ public void run(List<File> inputBams, String outputBaseName, File referenceFasta
3736
args.add("-I");
3837
args.add(f.getPath());
3938
}
40-
args.add("-o");
39+
args.add("-O");
4140
args.add(outputBaseName);
4241
if (options != null)
4342
{

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/variant/DepthOfCoverageHandler.java

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import au.com.bytecode.opencsv.CSVReader;
44
import au.com.bytecode.opencsv.CSVWriter;
5-
import htsjdk.samtools.util.Interval;
5+
import htsjdk.variant.utils.SAMSequenceDictionaryExtractor;
66
import org.apache.commons.lang3.StringUtils;
77
import org.json.JSONObject;
88
import org.labkey.api.module.ModuleLoader;
@@ -15,7 +15,6 @@
1515
import org.labkey.api.sequenceanalysis.pipeline.ReferenceGenome;
1616
import org.labkey.api.sequenceanalysis.pipeline.SequenceAnalysisJobSupport;
1717
import org.labkey.api.sequenceanalysis.pipeline.SequenceOutputHandler;
18-
import org.labkey.api.sequenceanalysis.pipeline.SequencePipelineService;
1918
import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor;
2019
import org.labkey.api.util.PageFlowUtil;
2120
import org.labkey.api.writer.PrintWriters;
@@ -25,9 +24,9 @@
2524

2625
import java.io.File;
2726
import java.io.IOException;
27+
import java.io.PrintWriter;
2828
import java.util.ArrayList;
2929
import java.util.Arrays;
30-
import java.util.Collections;
3130
import java.util.HashSet;
3231
import java.util.LinkedHashSet;
3332
import java.util.List;
@@ -107,6 +106,20 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
107106
throw new PipelineJobException("No basename was provided");
108107
}
109108

109+
List<File> inputBams = new ArrayList<>();
110+
Set<Integer> libraryIds = new HashSet<>();
111+
for (SequenceOutputFile so : inputFiles)
112+
{
113+
inputBams.add(so.getFile());
114+
libraryIds.add(so.getLibrary_id());
115+
}
116+
117+
if (libraryIds.size() != 1)
118+
{
119+
throw new PipelineJobException("Not all files use the same reference library");
120+
}
121+
ReferenceGenome rg = ctx.getSequenceSupport().getCachedGenome(libraryIds.iterator().next());
122+
110123
String intervalString = StringUtils.trimToNull(ctx.getParams().optString("intervals"));
111124
if (intervalString != null)
112125
{
@@ -118,46 +131,42 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
118131
extraArgs.add(i);
119132
}
120133
}
134+
else
135+
{
136+
//GATK4 now requires intervals:
137+
File intervalList = new File(ctx.getOutputDir(), "depthOfCoverageIntervals.intervals");
138+
ctx.getFileManager().addIntermediateFile(intervalList);
139+
try (PrintWriter writer = PrintWriters.getPrintWriter(intervalList))
140+
{
141+
SAMSequenceDictionaryExtractor.extractDictionary(rg.getSequenceDictionary().toPath()).getSequences().forEach(x -> writer.println(x.getSequenceName()));
142+
}
143+
catch (IOException e)
144+
{
145+
throw new PipelineJobException(e);
146+
}
147+
148+
extraArgs.add("-L");
149+
extraArgs.add(intervalList.getPath());
150+
}
121151

122152
Integer mmq = ctx.getParams().optInt("mmq");
123153
if (mmq > 0)
124154
{
125-
extraArgs.add("-mmq");
155+
extraArgs.add("--read-filter");
156+
extraArgs.add("MappingQualityReadFilter");
157+
extraArgs.add("--minimum-mapping-quality");
126158
extraArgs.add(mmq.toString());
127159
}
128160

129161
Integer mbq = ctx.getParams().optInt("mbq");
130162
if (mbq > 0)
131163
{
132-
extraArgs.add("-mbq");
164+
extraArgs.add("--min-base-quality");
133165
extraArgs.add(mbq.toString());
134166
}
135167

136-
extraArgs.add("-omitLocusTable");
137-
extraArgs.add("-omitIntervals");
138-
139-
if (SequencePipelineService.get().getMaxThreads(ctx.getLogger()) != null)
140-
{
141-
extraArgs.add("-nt");
142-
extraArgs.add(SequencePipelineService.get().getMaxThreads(ctx.getLogger()).toString());
143-
}
144-
145-
extraArgs.add("-U");
146-
extraArgs.add("ALLOW_N_CIGAR_READS");
147-
148-
List<File> inputBams = new ArrayList<>();
149-
Set<Integer> libraryIds = new HashSet<>();
150-
for (SequenceOutputFile so : inputFiles)
151-
{
152-
inputBams.add(so.getFile());
153-
libraryIds.add(so.getLibrary_id());
154-
}
155-
156-
if (libraryIds.size() != 1)
157-
{
158-
throw new PipelineJobException("Not all files use the same reference library");
159-
}
160-
ReferenceGenome rg = ctx.getSequenceSupport().getCachedGenome(libraryIds.iterator().next());
168+
extraArgs.add("--omit-locus-table");
169+
extraArgs.add("--omit-interval-statistics");
161170

162171
File outputFile = new File(ctx.getOutputDir(), basename + ".coverage");
163172

jbrowse/resources/views/databaseDetails.html

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
'<br>' +
1616
'<div id="members_'+webpart.wrapperDivId+'"></div>' +
1717
'<br>' +
18+
'<div id="jsonfiles2_'+webpart.wrapperDivId+'"></div>' +
19+
'<br>' +
1820
'<div id="jsonfiles_'+webpart.wrapperDivId+'"></div>'
1921
);
2022

@@ -30,7 +32,7 @@
3032
}
3133
});
3234

33-
LDK.Utils.getReadOnlyQWP({
35+
LDK.Utils.getBasicQWP({
3436
title: 'Resources Displayed In This Session',
3537
schemaName: 'jbrowse',
3638
queryName: 'database_members',
@@ -51,7 +53,7 @@
5153
var genomeId = results.rows[0].libraryId;
5254
var container = results.rows[0].container;
5355

54-
LDK.Utils.getReadOnlyQWP({
56+
LDK.Utils.getBasicQWP({
5557
title: 'Additional Tracks Provided By The Base Genome',
5658
schemaName: 'jbrowse',
5759
queryName: 'jsonfiles',
@@ -61,6 +63,39 @@
6163
}
6264
}
6365
});
66+
67+
LABKEY.Query.selectRows({
68+
containerPath: Laboratory.Utils.getQueryContainerPath(),
69+
schemaName: 'jbrowse',
70+
queryName: 'database_members',
71+
columns: 'jsonfile,container',
72+
filterArray: [LABKEY.Filter.create('database', objectid, LABKEY.Filter.Types.EQUAL)],
73+
scope: this,
74+
error: LDK.Utils.getErrorCallback(),
75+
success: function (results) {
76+
if (results.rows && results.rows.length) {
77+
var jsonFiles = [];
78+
var containers = [];
79+
Ext4.Array.forEach(results.rows, function(r){
80+
jsonFiles.push(r.jsonfile);
81+
containers.push(r.container);
82+
}, this);
83+
84+
jsonFiles = Ext4.unique(jsonFiles);
85+
containers = Ext4.unique(containers);
86+
var container = containers[0];
87+
88+
LDK.Utils.getReadOnlyQWP({
89+
title: 'Tracks Provided By This Session',
90+
schemaName: 'jbrowse',
91+
queryName: 'jsonfiles',
92+
containerPath: container,
93+
filterArray: [LABKEY.Filter.create('objectid', jsonFiles.join(';'), LABKEY.Filter.Types.IN)]
94+
}).render('jsonfiles2_' + webpart.wrapperDivId);
95+
}
96+
}
97+
});
98+
6499
});
65100

66101
</script>

jbrowse/resources/web/jbrowse/window/ModifyJsonConfigWindow.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ Ext4.define('JBrowse.window.ModifyJsonConfigWindow', {
6565
handler: function (gridBtn) {
6666
this.addAttribute('chunkSizeLimit', null, 'INT');
6767
}
68+
},{
69+
text: 'Max Track Height',
70+
scope: this,
71+
handler: function (gridBtn) {
72+
this.addAttribute('maxHeight', 1000, 'INT');
73+
}
6874
},{
6975
text: 'XY Plot',
7076
scope: this,

0 commit comments

Comments
 (0)