Skip to content

Commit 28bd6bb

Browse files
committed
Retain pangolin output
1 parent 2704f8d commit 28bd6bb

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/analysis/PangolinHandler.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import au.com.bytecode.opencsv.CSVReader;
44
import au.com.bytecode.opencsv.CSVWriter;
55
import htsjdk.samtools.util.IOUtil;
6+
import org.apache.commons.io.FileUtils;
67
import org.apache.commons.lang3.StringUtils;
78
import org.apache.logging.log4j.Logger;
89
import org.json.JSONObject;
@@ -30,6 +31,7 @@
3031
import org.labkey.api.sequenceanalysis.pipeline.SequenceOutputHandler;
3132
import org.labkey.api.sequenceanalysis.pipeline.SequencePipelineService;
3233
import org.labkey.api.sequenceanalysis.run.SimpleScriptWrapper;
34+
import org.labkey.api.util.FileUtil;
3335
import org.labkey.api.util.PageFlowUtil;
3436
import org.labkey.sequenceanalysis.SequenceAnalysisModule;
3537
import org.labkey.sequenceanalysis.SequenceAnalysisSchema;
@@ -192,6 +194,11 @@ public static void updatePangolinRefs(Logger log) throws PipelineJobException
192194
wrapper.execute(Arrays.asList("/bin/bash", pangolin.getPath()));
193195
}
194196

197+
public static File getRenamedPangolinOutput(File consensusFasta)
198+
{
199+
return new File(consensusFasta.getParentFile(), FileUtil.getBaseName(consensusFasta) + ".pandolin.csv");
200+
}
201+
195202
public static String[] runPangolin(File consensusFasta, Logger log, PipelineOutputTracker tracker) throws PipelineJobException
196203
{
197204
SimpleScriptWrapper wrapper = new SimpleScriptWrapper(log);
@@ -211,17 +218,21 @@ public static String[] runPangolin(File consensusFasta, Logger log, PipelineOutp
211218
throw new PipelineJobException("Pangolin output not found: " + output.getPath());
212219
}
213220

214-
tracker.addIntermediateFile(output);
215-
try (CSVReader reader = new CSVReader(Readers.getReader(output)))
221+
try
216222
{
217-
reader.readNext(); //header
218-
String[] line = reader.readNext();
223+
File outputMoved = getRenamedPangolinOutput(consensusFasta);
224+
FileUtils.moveFile(output, outputMoved);
225+
try (CSVReader reader = new CSVReader(Readers.getReader(outputMoved)))
226+
{
227+
reader.readNext(); //header
228+
String[] line = reader.readNext();
219229

220-
return line;
230+
return line;
231+
}
221232
}
222233
catch (IOException e)
223234
{
224-
throw new PipelineJobException();
235+
throw new PipelineJobException(e);
225236
}
226237
}
227238
}

0 commit comments

Comments
 (0)