Skip to content

Commit c793392

Browse files
committed
Allow NextClade results where clade assignment failed.
1 parent 52c26f8 commit c793392

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/analysis/NextCladeHandler.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,18 @@ public static File runNextClade(File consensusFasta, Logger log, PipelineOutputT
210210
return jsonFile;
211211
}
212212

213-
private static JSONObject parseNextClade(File jsonFile) throws PipelineJobException
213+
private static JSONObject parseNextClade(File jsonFile, Logger log) throws PipelineJobException
214214
{
215215
try (InputStream is = IOUtil.openFileForReading(jsonFile))
216216
{
217217
JSONObject results = new JSONObject(IOUtil.readFully(is));
218218
JSONArray samples = results.getJSONArray("results");
219-
if (samples.length() != 1)
219+
if (samples.length() == 0)
220+
{
221+
log.info("No samples found in NextClade JSON, this probably means no clade was assigned");
222+
return null;
223+
}
224+
else if (samples.length() != 1)
220225
{
221226
throw new PipelineJobException("Expected a single sample, was: " + samples.length());
222227
}
@@ -231,7 +236,11 @@ private static JSONObject parseNextClade(File jsonFile) throws PipelineJobExcept
231236

232237
public static void processAndImportNextCladeAa(PipelineJob job, File jsonFile, int analysisId, int libraryId, int alignmentId, int readsetId, File consensusVCF, boolean dbImport) throws PipelineJobException
233238
{
234-
JSONObject sample = parseNextClade(jsonFile);
239+
JSONObject sample = parseNextClade(jsonFile, job.getLogger());
240+
if (sample == null)
241+
{
242+
return;
243+
}
235244

236245
ReferenceGenome genome = SequenceAnalysisService.get().getReferenceGenome(libraryId, job.getUser());
237246
String clade = sample.getString("clade");

0 commit comments

Comments
 (0)