|
15 | 15 | import org.labkey.api.sequenceanalysis.run.AbstractGatk4Wrapper; |
16 | 16 | import org.labkey.api.util.FileUtil; |
17 | 17 | import org.labkey.api.writer.PrintWriters; |
| 18 | +import org.labkey.sequenceanalysis.util.SequenceUtil; |
18 | 19 |
|
19 | 20 | import java.io.File; |
20 | 21 | import java.io.IOException; |
@@ -70,29 +71,39 @@ public File execute(File bam, File fasta, File output, @Nullable File knownVaria |
70 | 71 | argsRecal.add(recalTable.getPath()); |
71 | 72 | execute(argsRecal); |
72 | 73 |
|
73 | | - List<String> argsApply = new ArrayList<>(getBaseArgs()); |
74 | | - argsApply.add("ApplyBQSR"); |
75 | | - argsApply.add("-I"); |
76 | | - argsApply.add(bam.getPath()); |
77 | | - argsApply.add("-R"); |
78 | | - argsApply.add(fasta.getPath()); |
79 | | - argsApply.add("--bqsr-recal-file"); |
80 | | - argsApply.add(recalTable.getPath()); |
81 | | - argsApply.add("-O"); |
82 | | - argsApply.add(output.getPath()); |
83 | | - execute(argsApply); |
| 74 | + // If there is not recal possible, the output has 132 lines. |
| 75 | + long lineCount = SequenceUtil.getLineCount(recalTable); |
| 76 | + if (lineCount > 132) |
| 77 | + { |
| 78 | + List<String> argsApply = new ArrayList<>(getBaseArgs()); |
| 79 | + argsApply.add("ApplyBQSR"); |
| 80 | + argsApply.add("-I"); |
| 81 | + argsApply.add(bam.getPath()); |
| 82 | + argsApply.add("-R"); |
| 83 | + argsApply.add(fasta.getPath()); |
| 84 | + argsApply.add("--bqsr-recal-file"); |
| 85 | + argsApply.add(recalTable.getPath()); |
| 86 | + argsApply.add("-O"); |
| 87 | + argsApply.add(output.getPath()); |
| 88 | + execute(argsApply); |
| 89 | + |
| 90 | + if (!output.exists()) |
| 91 | + { |
| 92 | + throw new PipelineJobException("Expected output not created: " + output.getPath()); |
| 93 | + } |
| 94 | + } |
| 95 | + else |
| 96 | + { |
| 97 | + getLogger().info("No recalibration was possible, skipping ApplyBQSR"); |
| 98 | + output = bam; |
| 99 | + } |
84 | 100 |
|
85 | 101 | if (deleteKnownVariantFile) |
86 | 102 | { |
87 | 103 | knownVariants.delete(); |
88 | 104 | new File(knownVariants.getPath() + ".idx").delete(); |
89 | 105 | } |
90 | 106 |
|
91 | | - if (!output.exists()) |
92 | | - { |
93 | | - throw new PipelineJobException("Expected output not created: " + output.getPath()); |
94 | | - } |
95 | | - |
96 | 107 | return output; |
97 | 108 | } |
98 | 109 |
|
@@ -138,7 +149,7 @@ public Output processBam(Readset rs, File inputBam, ReferenceGenome referenceGen |
138 | 149 | } |
139 | 150 | } |
140 | 151 |
|
141 | | - getWrapper().execute(inputBam, referenceGenome.getWorkingFastaFile(), outputBam, knownVariants); |
| 152 | + outputBam = getWrapper().execute(inputBam, referenceGenome.getWorkingFastaFile(), outputBam, knownVariants); |
142 | 153 |
|
143 | 154 | output.setBAM(outputBam); |
144 | 155 |
|
|
0 commit comments