33import au .com .bytecode .opencsv .CSVReader ;
44import au .com .bytecode .opencsv .CSVWriter ;
55import htsjdk .samtools .util .IOUtil ;
6+ import org .apache .commons .io .FileUtils ;
67import org .apache .commons .lang3 .StringUtils ;
78import org .apache .logging .log4j .Logger ;
89import org .json .JSONObject ;
3031import org .labkey .api .sequenceanalysis .pipeline .SequenceOutputHandler ;
3132import org .labkey .api .sequenceanalysis .pipeline .SequencePipelineService ;
3233import org .labkey .api .sequenceanalysis .run .SimpleScriptWrapper ;
34+ import org .labkey .api .util .FileUtil ;
3335import org .labkey .api .util .PageFlowUtil ;
3436import org .labkey .sequenceanalysis .SequenceAnalysisModule ;
3537import 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