@@ -162,7 +162,7 @@ public void prepareGenome(int genomeId) throws PipelineJobException
162162
163163 private File getLocalIndexDir (int genomeId , boolean createIfMissing )
164164 {
165- File dir = new File (getPipelineCtx ().getSourceDirectory (), "genome." + genomeId );
165+ File dir = FileUtil . appendName (getPipelineCtx ().getSourceDirectory (), "genome." + genomeId );
166166 if (createIfMissing && !dir .exists ())
167167 {
168168 dir .mkdir ();
@@ -187,10 +187,10 @@ private File getGenomeCsv(int genomeId, boolean forceWorkDir) throws PipelineJob
187187 if (!forceWorkDir && AlignerIndexUtil .hasCachedIndex (getPipelineCtx (), "nimble" , rg ))
188188 {
189189 File indexDir = AlignerIndexUtil .getIndexDir (rg , "nimble" );
190- return new File (indexDir , "genome." + genomeId + ".csv" );
190+ return FileUtil . appendName (indexDir , "genome." + genomeId + ".csv" );
191191 }
192192
193- return checkForLegacyGenome ( new File ( getLocalIndexDir (genomeId , true ), "genome." + genomeId + ".csv" ) );
193+ return FileUtil . appendName ( getLocalIndexDir (genomeId , true ), "genome." + genomeId + ".csv" );
194194 }
195195
196196 private File getGenomeFasta (int genomeId ) throws PipelineJobException
@@ -209,43 +209,13 @@ private File getGenomeFasta(int genomeId, boolean forceWorkDir) throws PipelineJ
209209 if (!forceWorkDir && AlignerIndexUtil .hasCachedIndex (getPipelineCtx (), "nimble" , rg ))
210210 {
211211 File indexDir = AlignerIndexUtil .getIndexDir (rg , "nimble" );
212- return new File (indexDir , "genome." + genomeId + ".fasta" );
212+ return FileUtil . appendName (indexDir , "genome." + genomeId + ".fasta" );
213213 }
214214
215- return checkForLegacyGenome ( new File ( getLocalIndexDir (genomeId , true ), "genome." + genomeId + ".fasta" ) );
215+ return FileUtil . appendName ( getLocalIndexDir (genomeId , true ), "genome." + genomeId + ".fasta" );
216216 }
217217
218- // TODO: This should ultimately be removed:
219- private File checkForLegacyGenome (File fileNewLocation ) throws PipelineJobException
220- {
221- if (fileNewLocation .exists ())
222- {
223- return fileNewLocation ;
224- }
225-
226- File oldLocation = new File (fileNewLocation .getParentFile ().getParentFile (), fileNewLocation .getName ());
227- if (oldLocation .exists ())
228- {
229- getPipelineCtx ().getLogger ().debug ("Genome file found in old location, moving: " + oldLocation .getPath ());
230- if (!fileNewLocation .getParentFile ().exists ())
231- {
232- fileNewLocation .getParentFile ().mkdir ();
233- }
234-
235- try
236- {
237- FileUtils .moveFile (oldLocation , fileNewLocation );
238- }
239- catch (IOException e )
240- {
241- throw new PipelineJobException (e );
242- }
243- }
244-
245- return fileNewLocation ;
246- }
247-
248- public void doNimbleAlign (File bam , PipelineStepOutput output , Readset rs , String basename ) throws UnsupportedOperationException , PipelineJobException
218+ public void doNimbleAlign (File bam , PipelineStepOutput output , Readset rs , String basename , boolean doTsoTrimming ) throws UnsupportedOperationException , PipelineJobException
249219 {
250220 getPipelineCtx ().getJob ().setStatus (PipelineJob .TaskStatus .running , "Running Nimble Align" );
251221 List <NimbleGenome > genomes = getGenomes ();
@@ -274,7 +244,7 @@ public void doNimbleAlign(File bam, PipelineStepOutput output, Readset rs, Strin
274244 jsons .add (refJson );
275245 }
276246
277- Map <NimbleGenome , File > resultMap = doAlignment (genomes , jsons , bam , output );
247+ Map <NimbleGenome , File > resultMap = doAlignment (genomes , jsons , bam , output , doTsoTrimming );
278248 for (NimbleGenome genome : genomes )
279249 {
280250 File results = resultMap .get (genome );
@@ -307,7 +277,7 @@ public void doNimbleAlign(File bam, PipelineStepOutput output, Readset rs, Strin
307277
308278 private File prepareReference (File genomeCsv , File genomeFasta , NimbleGenome genome , PipelineStepOutput output ) throws PipelineJobException
309279 {
310- File nimbleJson = new File (getPipelineCtx ().getWorkingDirectory (), genome .genomeId + ".json" );
280+ File nimbleJson = FileUtil . appendName (getPipelineCtx ().getWorkingDirectory (), genome .genomeId + ".json" );
311281 runUsingDocker (Arrays .asList ("python3" , "-m" , "nimble" , "generate" , "--opt-file" , genomeFasta .getPath (), "--file" , genomeCsv .getPath (), "--output_path" , nimbleJson .getPath ()), output , "generate-" + genome .genomeId );
312282 if (!nimbleJson .exists ())
313283 {
@@ -401,7 +371,7 @@ else if ("strict".equals(alignTemplate))
401371 }
402372 }
403373
404- private Map <NimbleGenome , File > doAlignment (List <NimbleGenome > genomes , List <File > refJsons , File bam , PipelineStepOutput output ) throws PipelineJobException
374+ private Map <NimbleGenome , File > doAlignment (List <NimbleGenome > genomes , List <File > refJsons , File bam , PipelineStepOutput output , boolean skipTsoTrimming ) throws PipelineJobException
405375 {
406376 Map <NimbleGenome , File > resultMap = new HashMap <>();
407377
@@ -425,7 +395,12 @@ private Map<NimbleGenome, File> doAlignment(List<NimbleGenome> genomes, List<Fil
425395 alignArgs .add (strandedness );
426396 }
427397
428- File alignmentTsvBase = new File (getPipelineCtx ().getWorkingDirectory (), "alignResults." + (genomes .size () == 1 ? genomes .get (0 ).genomeId + "." : "" ) + "txt.gz" );
398+ if (skipTsoTrimming )
399+ {
400+ alignArgs .add ("--skip_tso_trimming" );
401+ }
402+
403+ File alignmentTsvBase = FileUtil .appendName (getPipelineCtx ().getWorkingDirectory (), "alignResults." + (genomes .size () == 1 ? genomes .get (0 ).genomeId + "." : "" ) + "txt.gz" );
429404
430405 alignArgs .add ("--reference" );
431406 alignArgs .add (refJsons .stream ().map (File ::getPath ).collect (Collectors .joining ("," )));
@@ -437,7 +412,7 @@ private Map<NimbleGenome, File> doAlignment(List<NimbleGenome> genomes, List<Fil
437412 alignArgs .add (bam .getPath ());
438413
439414 // Create temp folder:
440- File tmpDir = new File (getPipelineCtx ().getWorkingDirectory (), "tmpDir" );
415+ File tmpDir = FileUtil . appendName (getPipelineCtx ().getWorkingDirectory (), "tmpDir" );
441416 if (tmpDir .exists ())
442417 {
443418 try
@@ -473,7 +448,7 @@ private Map<NimbleGenome, File> doAlignment(List<NimbleGenome> genomes, List<Fil
473448
474449 for (NimbleGenome genome : genomes )
475450 {
476- File alignResultsGz = new File (getPipelineCtx ().getWorkingDirectory (), "alignResults." + genome .genomeId + ".txt.gz" );
451+ File alignResultsGz = FileUtil . appendName (getPipelineCtx ().getWorkingDirectory (), "alignResults." + genome .genomeId + ".txt.gz" );
477452 if (dockerRan && !alignResultsGz .exists ())
478453 {
479454 File doneFile = getNimbleDoneFile (getPipelineCtx ().getWorkingDirectory (), "align.all" );
@@ -508,7 +483,7 @@ public static void write10xBarcodes(File bam, Logger log, Readset rs, ReferenceG
508483 barcodeArgs .add ("-I" );
509484 barcodeArgs .add (bam .getPath ());
510485
511- File bcOutput = new File (bam .getParentFile (), SequenceAnalysisService .get ().getUnzippedBaseName (bam .getName ()) + ".cb.txt.gz" );
486+ File bcOutput = FileUtil . appendName (bam .getParentFile (), SequenceAnalysisService .get ().getUnzippedBaseName (bam .getName ()) + ".cb.txt.gz" );
512487 barcodeArgs .add ("--output" );
513488 barcodeArgs .add (bcOutput .getPath ());
514489
@@ -531,7 +506,7 @@ public static File runNimbleReport(File alignResultsGz, int genomeId, PipelineSt
531506 String resumeString = "nimble.report." + genomeId ;
532507 File doneFile = getNimbleDoneFile (ctx .getWorkingDirectory (), resumeString );
533508
534- File reportResultsGz = new File (ctx .getWorkingDirectory (), "reportResults." + genomeId + ".txt.gz" );
509+ File reportResultsGz = FileUtil . appendName (ctx .getWorkingDirectory (), "reportResults." + genomeId + ".txt.gz" );
535510 if (reportResultsGz .exists () && !doneFile .exists ())
536511 {
537512 ctx .getLogger ().debug ("Deleting existing result file: " + reportResultsGz .getPath ());
@@ -591,7 +566,7 @@ public static File getReportHtmlFileFromResults(File reportResults)
591566
592567 private static File getNimbleDoneFile (File parentDir , String resumeString )
593568 {
594- return new File (parentDir , "nimble." + resumeString + ".done" );
569+ return FileUtil . appendName (parentDir , "nimble." + resumeString + ".done" );
595570 }
596571
597572 public static File runFastqToBam (PipelineStepOutput output , PipelineContext ctx , Readset rs , List <File > inputFastqs1 , List <File > inputFastqs2 , File loupeFile ) throws PipelineJobException
@@ -600,7 +575,7 @@ public static File runFastqToBam(PipelineStepOutput output, PipelineContext ctx,
600575 int bamIdx = 0 ;
601576 while (bamIdx < inputFastqs1 .size ())
602577 {
603- File outputBam = new File (ctx .getWorkingDirectory (), FileUtil .makeLegalName (rs .getName ()) + ".unmapped." + bamIdx + ".bam" );
578+ File outputBam = FileUtil . appendName (ctx .getWorkingDirectory (), FileUtil .makeLegalName (rs .getName ()) + ".unmapped." + bamIdx + ".bam" );
604579
605580 List <String > args = new ArrayList <>();
606581 args .add ("python3" );
@@ -641,7 +616,7 @@ public static File runFastqToBam(PipelineStepOutput output, PipelineContext ctx,
641616 File outputBam ;
642617 if (outputBams .size () > 1 )
643618 {
644- outputBam = new File (ctx .getWorkingDirectory (), FileUtil .makeLegalName (rs .getName ()) + ".unmapped.bam" );
619+ outputBam = FileUtil . appendName (ctx .getWorkingDirectory (), FileUtil .makeLegalName (rs .getName ()) + ".unmapped.bam" );
645620 outputBams .forEach (output ::addIntermediateFile );
646621
647622 SamtoolsRunner st = new SamtoolsRunner (ctx .getLogger ());
@@ -777,7 +752,7 @@ private String getVersion(PipelineStepOutput output) throws PipelineJobException
777752
778753 runUsingDocker (nimbleArgs , output , null );
779754
780- File outFile = new File (getPipelineCtx ().getWorkingDirectory (), "nimbleVersion.txt" );
755+ File outFile = FileUtil . appendName (getPipelineCtx ().getWorkingDirectory (), "nimbleVersion.txt" );
781756 if (!outFile .exists ())
782757 {
783758 throw new PipelineJobException ("Unable to find file: " + outFile .getPath ());
0 commit comments