@@ -153,28 +153,18 @@ public void prepareGenome(int genomeId) throws PipelineJobException
153153 throw new PipelineJobException (e );
154154 }
155155
156- File indexDir = AlignerIndexUtil .getIndexDir (rg , "nimble" );
157- if (!indexDir .exists ())
158- {
159- indexDir .mkdir ();
160- }
156+ AlignerIndexUtil .saveCachedIndex (false , getPipelineCtx (), getLocalIndexDir (genomeId , true ), "nimble" , rg );
157+ }
161158
162- for (File f : Arrays .asList (csv , fasta ))
159+ private File getLocalIndexDir (int genomeId , boolean createIfMissing )
160+ {
161+ File dir = new File (getPipelineCtx ().getSourceDirectory (), "genome." + genomeId );
162+ if (createIfMissing && !dir .exists ())
163163 {
164- File cached = new File (indexDir , f .getName ());
165- if (!cached .exists ())
166- {
167- try
168- {
169- getPipelineCtx ().getLogger ().debug ("Caching file: " + cached .getPath ());
170- FileUtils .copyFile (f , cached );
171- }
172- catch (IOException e )
173- {
174- throw new PipelineJobException (e );
175- }
176- }
164+ dir .mkdir ();
177165 }
166+
167+ return dir ;
178168 }
179169
180170 private File getGenomeCsv (int genomeId ) throws PipelineJobException
@@ -196,7 +186,7 @@ private File getGenomeCsv(int genomeId, boolean forceWorkDir) throws PipelineJob
196186 return new File (indexDir , "genome." + genomeId + ".csv" );
197187 }
198188
199- return new File (getPipelineCtx (). getSourceDirectory () , "genome." + genomeId + ".csv" );
189+ return checkForLegacyGenome ( new File (getLocalIndexDir ( genomeId , true ) , "genome." + genomeId + ".csv" ) );
200190 }
201191
202192 private File getGenomeFasta (int genomeId ) throws PipelineJobException
@@ -218,7 +208,37 @@ private File getGenomeFasta(int genomeId, boolean forceWorkDir) throws PipelineJ
218208 return new File (indexDir , "genome." + genomeId + ".fasta" );
219209 }
220210
221- return new File (getPipelineCtx ().getSourceDirectory (), "genome." + genomeId + ".fasta" );
211+ return checkForLegacyGenome (new File (getLocalIndexDir (genomeId , true ), "genome." + genomeId + ".fasta" ));
212+ }
213+
214+ // TODO: This should ultimately be removed:
215+ private File checkForLegacyGenome (File fileNewLocation ) throws PipelineJobException
216+ {
217+ if (fileNewLocation .exists ())
218+ {
219+ return fileNewLocation ;
220+ }
221+
222+ File oldLocation = new File (fileNewLocation .getParentFile ().getParentFile (), fileNewLocation .getName ());
223+ if (oldLocation .exists ())
224+ {
225+ getPipelineCtx ().getLogger ().debug ("Genome file found in old location, moving: " + oldLocation .getPath ());
226+ if (!fileNewLocation .getParentFile ().exists ())
227+ {
228+ fileNewLocation .getParentFile ().mkdir ();
229+ }
230+
231+ try
232+ {
233+ FileUtils .moveFile (oldLocation , fileNewLocation );
234+ }
235+ catch (IOException e )
236+ {
237+ throw new PipelineJobException (e );
238+ }
239+ }
240+
241+ return fileNewLocation ;
222242 }
223243
224244 public void doNimbleAlign (File bam , PipelineStepOutput output , Readset rs , String basename ) throws UnsupportedOperationException , PipelineJobException
0 commit comments