|
37 | 37 | * Date: 6/15/2014 |
38 | 38 | * Time: 12:39 PM |
39 | 39 | */ |
40 | | -public class GroupCompareStep extends AbstractCommandPipelineStep<GroupCompareStep.GroupComparison> implements VariantProcessingStep |
| 40 | +public class GroupCompareStep extends AbstractCommandPipelineStep<GroupCompareStep.GroupComparison> implements VariantProcessingStep, VariantProcessingStep.SupportsScatterGather |
41 | 41 | { |
42 | 42 | public static final String REF_VCF = "refVcf"; |
43 | 43 | public static String GROUP1 = "group1"; |
@@ -81,64 +81,64 @@ public GroupCompareStep create(PipelineContext ctx) |
81 | 81 | { |
82 | 82 | return new GroupCompareStep(this, ctx); |
83 | 83 | } |
| 84 | + } |
84 | 85 |
|
85 | | - @Override |
86 | | - public void performAdditionalMergeTasks(SequenceOutputHandler.JobContext ctx, PipelineJob job, TaskFileManager manager, ReferenceGenome genome, List<File> orderedScatterOutputs, List<String> orderedJobDirs) throws PipelineJobException |
87 | | - { |
88 | | - job.getLogger().info("Merging variant tables"); |
89 | | - List<File> toConcat = orderedScatterOutputs.stream().map(f -> { |
90 | | - f = new File(f.getParentFile(), f.getName().replaceAll("vcf.gz", "txt")); |
91 | | - if (!f.exists()) |
92 | | - { |
93 | | - throw new IllegalStateException("Missing file: " + f.getPath()); |
94 | | - } |
| 86 | + @Override |
| 87 | + public void performAdditionalMergeTasks(SequenceOutputHandler.JobContext ctx, PipelineJob job, TaskFileManager manager, ReferenceGenome genome, List<File> orderedScatterOutputs, List<String> orderedJobDirs) throws PipelineJobException |
| 88 | + { |
| 89 | + job.getLogger().info("Merging variant tables"); |
| 90 | + List<File> toConcat = orderedScatterOutputs.stream().map(f -> { |
| 91 | + f = new File(f.getParentFile(), f.getName().replaceAll("vcf.gz", "txt")); |
| 92 | + if (!f.exists()) |
| 93 | + { |
| 94 | + throw new IllegalStateException("Missing file: " + f.getPath()); |
| 95 | + } |
95 | 96 |
|
96 | | - ctx.getFileManager().addIntermediateFile(f); |
| 97 | + ctx.getFileManager().addIntermediateFile(f); |
97 | 98 |
|
98 | | - return f; |
99 | | - }).toList(); |
| 99 | + return f; |
| 100 | + }).toList(); |
100 | 101 |
|
101 | | - String basename = SequenceAnalysisService.get().getUnzippedBaseName(toConcat.get(0).getName()); |
102 | | - File combined = new File(ctx.getSourceDirectory(), basename + ".txt"); |
103 | | - try (PrintWriter writer = PrintWriters.getPrintWriter(combined)) |
| 102 | + String basename = SequenceAnalysisService.get().getUnzippedBaseName(toConcat.get(0).getName()); |
| 103 | + File combined = new File(ctx.getSourceDirectory(), basename + ".txt"); |
| 104 | + try (PrintWriter writer = PrintWriters.getPrintWriter(combined)) |
| 105 | + { |
| 106 | + boolean hasWrittenHeader = false; |
| 107 | + for (File f : toConcat) |
104 | 108 | { |
105 | | - boolean hasWrittenHeader = false; |
106 | | - for (File f : toConcat) |
| 109 | + try (BufferedReader reader = Readers.getReader(f)) |
107 | 110 | { |
108 | | - try (BufferedReader reader = Readers.getReader(f)) |
| 111 | + String line; |
| 112 | + int idx = 0; |
| 113 | + while ((line = reader.readLine()) != null) |
109 | 114 | { |
110 | | - String line; |
111 | | - int idx = 0; |
112 | | - while ((line = reader.readLine()) != null) |
| 115 | + idx++; |
| 116 | + if (idx == 1) |
113 | 117 | { |
114 | | - idx++; |
115 | | - if (idx == 1) |
116 | | - { |
117 | | - if (!hasWrittenHeader) { |
118 | | - writer.println(line); |
119 | | - hasWrittenHeader = true; |
120 | | - } |
121 | | - } |
122 | | - else |
123 | | - { |
| 118 | + if (!hasWrittenHeader) { |
124 | 119 | writer.println(line); |
| 120 | + hasWrittenHeader = true; |
125 | 121 | } |
126 | 122 | } |
| 123 | + else |
| 124 | + { |
| 125 | + writer.println(line); |
| 126 | + } |
127 | 127 | } |
128 | 128 | } |
129 | 129 | } |
130 | | - catch (IOException e) |
131 | | - { |
132 | | - throw new PipelineJobException(e); |
133 | | - } |
134 | | - |
135 | | - SequenceOutputFile so = new SequenceOutputFile(); |
136 | | - so.setName(basename + ": Selected Variants"); |
137 | | - so.setFile(combined); |
138 | | - so.setCategory("Variant List"); |
139 | | - so.setLibrary_id(genome.getGenomeId()); |
140 | | - manager.addSequenceOutput(so); |
141 | 130 | } |
| 131 | + catch (IOException e) |
| 132 | + { |
| 133 | + throw new PipelineJobException(e); |
| 134 | + } |
| 135 | + |
| 136 | + SequenceOutputFile so = new SequenceOutputFile(); |
| 137 | + so.setName(basename + ": Selected Variants"); |
| 138 | + so.setFile(combined); |
| 139 | + so.setCategory("Variant List"); |
| 140 | + so.setLibrary_id(genome.getGenomeId()); |
| 141 | + manager.addSequenceOutput(so); |
142 | 142 | } |
143 | 143 |
|
144 | 144 | @Override |
|
0 commit comments