From fa54c856b6e0a85868aba388cc2e5892348a099a Mon Sep 17 00:00:00 2001 From: bow <bow@bow.web.id> Date: Wed, 25 Mar 2015 10:32:39 +0100 Subject: [PATCH] Properly open and close files in ExtractAlignedFastq --- .../biopet/tools/ExtractAlignedFastq.scala | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/ExtractAlignedFastq.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/ExtractAlignedFastq.scala index 9620e6bc6..501c406c7 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/ExtractAlignedFastq.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/ExtractAlignedFastq.scala @@ -261,17 +261,25 @@ object ExtractAlignedFastq extends ToolCommand { logger.info("Writing to output file(s) ...") (commandArgs.inputFastq2, commandArgs.outputFastq2) match { - case (None, None) => extractReads(memFunc, - new FastqReader(commandArgs.inputFastq1), - new BasicFastqWriter(commandArgs.outputFastq1)) - - case (Some(i2), Some(o2)) => extractReads(memFunc, - new FastqReader(commandArgs.inputFastq1), - new BasicFastqWriter(commandArgs.outputFastq1), - new FastqReader(i2), - new BasicFastqWriter(o2)) - - case _ => // handled by the command line config check above + case (None, None) => + val in = new FastqReader(commandArgs.inputFastq1) + val out = new BasicFastqWriter(commandArgs.outputFastq1) + extractReads(memFunc, in, out) + in.close() + out.close() + + case (Some(i2), Some(o2)) => + val in1 = new FastqReader(commandArgs.inputFastq1) + val in2 = new FastqReader(i2) + val out1 = new BasicFastqWriter(commandArgs.outputFastq1) + val out2 = new BasicFastqWriter(o2) + extractReads(memFunc, in1, out1, in2, out2) + in1.close() + in2.close() + out1.close() + out2.close() + + case _ => ; // handled by the command line config check above } } } -- GitLab