33import au .com .bytecode .opencsv .CSVWriter ;
44import org .apache .commons .io .FileUtils ;
55import org .apache .commons .io .IOUtils ;
6+ import org .apache .commons .io .output .StringBuilderWriter ;
67import org .apache .commons .lang3 .StringUtils ;
78import org .json .JSONArray ;
89import org .json .JSONObject ;
@@ -201,7 +202,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
201202 File genomeFasta = getGenomeFasta (genomeId , ctx );
202203
203204 File refJson = prepareReference (ctx , genomeCsv , genomeFasta );
204- File results = doAlignment (ctx , genomeId , refJson , genomeFasta , so );
205+ File results = doAlignment (ctx , genomeId , refJson , so );
205206
206207 ctx .getFileManager ().addIntermediateFile (genomeCsv );
207208 ctx .getFileManager ().addIntermediateFile (genomeFasta );
@@ -231,26 +232,19 @@ private File prepareReference(JobContext ctx, File genomeCsv, File genomeFasta)
231232 private void updateNimbleConfigFile (JobContext ctx , File configFile ) throws PipelineJobException
232233 {
233234 JSONArray json ;
234- try (BufferedReader reader = Readers .getReader (configFile ))
235+ try (BufferedReader reader = Readers .getReader (configFile ); StringBuilderWriter writer = new StringBuilderWriter (); )
235236 {
236- String line ;
237- StringBuilder stringBuilder = new StringBuilder ();
238- String ls = System .getProperty ("line.separator" );
239-
240- while ((line = reader .readLine ()) != null )
241- {
242- stringBuilder .append (line );
243- stringBuilder .append (ls );
244- }
245-
246- json = new JSONArray (stringBuilder .toString ());
237+ IOUtils .copy (reader , writer );
238+ json = new JSONArray (writer .toString ());
247239 }
248240 catch (IOException e )
249241 {
250242 throw new PipelineJobException (e );
251243 }
252244
253245 JSONObject config = json .getJSONObject (0 );
246+ ctx .getLogger ().info ("Initial config:" );
247+ ctx .getLogger ().info (config .toString (1 ));
254248 try (PrintWriter writer = PrintWriters .getPrintWriter (configFile ))
255249 {
256250 String alignTemplate = ctx .getParams ().optString (ALIGN_TEMPLATE , "lenient" );
@@ -278,6 +272,9 @@ else if ("strict".equals(alignTemplate))
278272 config .put ("group_on" , "lineage" );
279273 }
280274
275+ ctx .getLogger ().info ("Final config:" );
276+ ctx .getLogger ().info (config .toString (1 ));
277+
281278 json .put (0 , config );
282279 IOUtils .write (json .toString (), writer );
283280 }
@@ -287,7 +284,7 @@ else if ("strict".equals(alignTemplate))
287284 }
288285 }
289286
290- private File doAlignment (JobContext ctx , int genomeId , File refJson , File refFasta , SequenceOutputFile so ) throws PipelineJobException
287+ private File doAlignment (JobContext ctx , int genomeId , File refJson , SequenceOutputFile so ) throws PipelineJobException
291288 {
292289 File localBam = ensureLocalCopy (so .getFile (), ctx );
293290 ensureLocalCopy (new File (so .getFile ().getPath () + ".bai" ), ctx );
0 commit comments