5050import org .labkey .api .sequenceanalysis .SequenceAnalysisService ;
5151import org .labkey .api .sequenceanalysis .SequenceOutputFile ;
5252import org .labkey .api .sequenceanalysis .pipeline .AbstractParameterizedOutputHandler ;
53+ import org .labkey .api .sequenceanalysis .pipeline .HasJobParams ;
5354import org .labkey .api .sequenceanalysis .pipeline .ReferenceGenome ;
5455import org .labkey .api .sequenceanalysis .pipeline .SequenceAnalysisJobSupport ;
5556import org .labkey .api .sequenceanalysis .pipeline .SequenceOutputHandler ;
@@ -280,17 +281,27 @@ public void init(JobContext ctx, List<SequenceOutputFile> inputFiles, List<Recor
280281 throw new PipelineJobException ("Some ids are missing demographics data: " + StringUtils .join (ids , "," ));
281282 }
282283
283- // NOTE: this is a bit of a cludge
284- Integer luceneIndexId = ctx .getParams ().optInt ("luceneIndex" );
285- if (luceneIndexId == null )
284+ getAndValidateLuceneIndex (ctx .getJob (), ctx .getParams ());
285+ }
286+
287+ private SequenceOutputFile getAndValidateLuceneIndex (PipelineJob job , JSONObject params ) throws PipelineJobException
288+ {
289+ Integer luceneIndexId = params .optInt ("luceneIndex" );
290+ if (luceneIndexId == null || luceneIndexId == 0 )
286291 {
287292 throw new PipelineJobException ("Missing luceneIndex ID" );
288293 }
289294
290- ExpData d = ExperimentService .get ().getExpData (luceneIndexId );
295+ SequenceOutputFile so = SequenceOutputFile .getForId (luceneIndexId );
296+ if (so == null )
297+ {
298+ throw new PipelineJobException ("Unable to find lucene index output file for: " + luceneIndexId );
299+ }
300+
301+ ExpData d = so .getExpData ();
291302 if (d == null )
292303 {
293- throw new PipelineJobException ("Unable to find lucene index file for: " + luceneIndexId );
304+ throw new PipelineJobException ("Unable to find lucene index expdata for: " + luceneIndexId );
294305 }
295306
296307 if (d .getFile () == null || !d .getFile ().exists ())
@@ -301,7 +312,7 @@ public void init(JobContext ctx, List<SequenceOutputFile> inputFiles, List<Recor
301312 File fieldList = new File (d .getFile ().getParentFile (), "fieldList.txt" );
302313 if (!fieldList .exists ())
303314 {
304- throw new PipelineJobException ("Lucene index missing fieldList.txt: " + luceneIndexId );
315+ throw new PipelineJobException ("Lucene index missing fieldList.txt: " + fieldList . getPath () );
305316 }
306317
307318 List <String > fields = new ArrayList <>();
@@ -322,10 +333,18 @@ public void init(JobContext ctx, List<SequenceOutputFile> inputFiles, List<Recor
322333 throw new PipelineJobException (e );
323334 }
324335
325- if (!IndexVariantsForMgapStep .getInfoFieldsToIndex (ctx .getJob ().getContainer (), ctx .getJob ().getUser ()).equals (fields ))
336+ List <String > expectedFields = IndexVariantsForMgapStep .getInfoFieldsToIndex (job .getContainer (), job .getUser ());
337+ if (!expectedFields .equals (fields ))
326338 {
339+ job .getLogger ().warn ("Expected fields:" );
340+ job .getLogger ().warn (StringUtils .join (expectedFields , ";" ));
341+ job .getLogger ().warn ("Found:" );
342+ job .getLogger ().warn (StringUtils .join (fields , ";" ));
343+
327344 throw new PipelineJobException ("The fields in the lucene index do not match the expected fields: " + luceneIndexId );
328345 }
346+
347+ return so ;
329348 }
330349
331350 private File getTrackListFile (File outputDir )
@@ -432,7 +451,12 @@ else if (so.getCategory().endsWith("Release Track"))
432451 throw new PipelineJobException ("Unable to find novel sites VCF for release: " + release );
433452 }
434453
435- SequenceOutputFile luceneIndex = JBrowseService .get ().findMatchingLuceneIndex (so , IndexVariantsForMgapStep .getInfoFieldsToIndex (job .getContainer (), job .getUser ()), job .getUser (), job .getLogger ());
454+ if (!(job instanceof HasJobParams hjp ))
455+ {
456+ throw new PipelineJobException ("Expected PipelineJob to implement HasJobParams" );
457+ }
458+
459+ SequenceOutputFile luceneIndex = getAndValidateLuceneIndex (job , hjp .getParameterJson ());
436460 if (luceneIndex == null )
437461 {
438462 throw new PipelineJobException ("Unable to lucene index matching the input VCF: " + so .getFile ().getPath ());
0 commit comments