|
1 | 1 | package org.labkey.sequenceanalysis.analysis; |
2 | 2 |
|
| 3 | +import com.google.common.io.Files; |
3 | 4 | import htsjdk.samtools.SAMFileHeader; |
4 | 5 | import htsjdk.samtools.SAMFileWriter; |
5 | 6 | import htsjdk.samtools.SAMFileWriterFactory; |
@@ -111,6 +112,10 @@ else if (SequenceUtil.FILETYPE.gvcf.getFileType().isType(so.getFile()) | Sequenc |
111 | 112 | { |
112 | 113 | getAndValidateHeaderForVcf(so, newRsName); |
113 | 114 | } |
| 115 | + else |
| 116 | + { |
| 117 | + throw new PipelineJobException("Unexpected file type: " + so.getFile().getPath()); |
| 118 | + } |
114 | 119 |
|
115 | 120 | ctx.getSequenceSupport().cacheObject("readsetId", newRsName); |
116 | 121 | } |
@@ -207,6 +212,18 @@ private void reheaderVcf(SequenceOutputFile so, JobContext ctx, String newRsName |
207 | 212 | String existingSample = header.getGenotypeSamples().get(0); |
208 | 213 |
|
209 | 214 | File sampleNamesFile = new File(ctx.getWorkingDirectory(), "sampleNames.txt"); |
| 215 | + if (!sampleNamesFile.exists()) |
| 216 | + { |
| 217 | + try |
| 218 | + { |
| 219 | + Files.touch(sampleNamesFile); |
| 220 | + } |
| 221 | + catch (IOException e) |
| 222 | + { |
| 223 | + throw new PipelineJobException(e); |
| 224 | + } |
| 225 | + } |
| 226 | + |
210 | 227 | try (PrintWriter writer = PrintWriters.getPrintWriter(sampleNamesFile, StandardOpenOption.APPEND)) |
211 | 228 | { |
212 | 229 | writer.println(newRsName); |
@@ -243,6 +260,11 @@ private void addTracker(SequenceOutputFile so, String existingSample, String new |
243 | 260 | { |
244 | 261 | File tracker = new File(so.getFile().getParentFile(), "reheaderHistory.txt"); |
245 | 262 | boolean preExisting = tracker.exists(); |
| 263 | + if (!preExisting) |
| 264 | + { |
| 265 | + Files.touch(tracker); |
| 266 | + } |
| 267 | + |
246 | 268 | try (PrintWriter writer = PrintWriters.getPrintWriter(tracker, StandardOpenOption.APPEND)) |
247 | 269 | { |
248 | 270 | if (!preExisting) |
|
0 commit comments