|
2 | 2 |
|
3 | 3 | import au.com.bytecode.opencsv.CSVReader; |
4 | 4 | import au.com.bytecode.opencsv.CSVWriter; |
| 5 | +import htsjdk.samtools.SAMFileHeader; |
5 | 6 | import org.apache.logging.log4j.Logger; |
6 | 7 | import org.jetbrains.annotations.Nullable; |
7 | 8 | import org.json.JSONObject; |
|
14 | 15 | import org.labkey.api.sequenceanalysis.pipeline.AlignmentStepProvider; |
15 | 16 | import org.labkey.api.sequenceanalysis.pipeline.PipelineContext; |
16 | 17 | import org.labkey.api.sequenceanalysis.pipeline.ReferenceGenome; |
| 18 | +import org.labkey.api.sequenceanalysis.pipeline.SamSorter; |
| 19 | +import org.labkey.api.sequenceanalysis.pipeline.SamtoolsRunner; |
17 | 20 | import org.labkey.api.sequenceanalysis.pipeline.SequencePipelineService; |
18 | 21 | import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor; |
19 | 22 | import org.labkey.api.sequenceanalysis.run.AbstractCommandWrapper; |
@@ -149,6 +152,13 @@ public File runVelocytoFor10x(File localBam, File gtf, File outputFolder, @Nulla |
149 | 152 |
|
150 | 153 | getLogger().debug("Using BAM: " + localBam.getPath()); |
151 | 154 |
|
| 155 | + //Pre-sort since velocyto dies when doing this itself: |
| 156 | + //samtools ``sort -l [compression] -m [mb_to_use]M -t [tagname] -O BAM -@ [threads_to_use] -o cellsorted_[bamfile] [bamfile] |
| 157 | + List<String> sortArgs = Arrays.asList("-t", "CB"); |
| 158 | + File sortedBam = new File(localBam.getParentFile(), "cellsorted_" + localBam.getName()); |
| 159 | + new SamSorter(getLogger()).execute(localBam, sortedBam, SAMFileHeader.SortOrder.unknown, sortArgs); |
| 160 | + |
| 161 | + |
152 | 162 | SimpleScriptWrapper wrapper = new SimpleScriptWrapper(getLogger()); |
153 | 163 | List<String> args = new ArrayList<>(); |
154 | 164 | args.add(SequencePipelineService.get().getExeForPackage("VELOCYTOPATH", "velocyto").getPath()); |
@@ -205,6 +215,8 @@ public File runVelocytoFor10x(File localBam, File gtf, File outputFolder, @Nulla |
205 | 215 | throw new PipelineJobException("Missing expected file: " + loom.getPath()); |
206 | 216 | } |
207 | 217 |
|
| 218 | + sortedBam.delete(); |
| 219 | + |
208 | 220 | return loom; |
209 | 221 | } |
210 | 222 | } |
|
0 commit comments