@@ -214,7 +214,8 @@ private static JSONObject parseNextClade(File jsonFile) throws PipelineJobExcept
214214 {
215215 try (InputStream is = IOUtil .openFileForReading (jsonFile ))
216216 {
217- JSONArray samples = new JSONArray (IOUtil .readFully (is ));
217+ JSONObject results = new JSONObject (IOUtil .readFully (is ));
218+ JSONArray samples = results .getJSONArray ("results" );
218219 if (samples .length () != 1 )
219220 {
220221 throw new PipelineJobException ("Expected a single sample, was: " + samples .length ());
@@ -250,7 +251,9 @@ public static void processAndImportNextCladeAa(PipelineJob job, File jsonFile, i
250251 return ;
251252 }
252253
253- JSONArray aaSubstitutions = sample .getJSONArray ("aaSubstitutions" );
254+ List <JSONObject > aaSubstitutions = new ArrayList <>(Arrays .asList (sample .getJSONArray ("aaSubstitutions" ).toJSONObjectArray ()));
255+ aaSubstitutions .addAll (Arrays .asList (sample .getJSONArray ("aaDeletions" ).toJSONObjectArray ()));
256+
254257 Map <Integer , List <VariantContext >> consensusMap = ViralSnpUtil .readVcfToMap (consensusVCF );
255258
256259 TableInfo aaTable = SequenceAnalysisSchema .getInstance ().getSchema ().getTable (SequenceAnalysisSchema .TABLE_AA_SNP_BY_CODON );
@@ -264,9 +267,8 @@ public static void processAndImportNextCladeAa(PipelineJob job, File jsonFile, i
264267
265268 int refNtId = ts .getObject (Integer .class );
266269
267- for (int i = 0 ; i < aaSubstitutions . length (); i ++ )
270+ for (JSONObject aa : aaSubstitutions )
268271 {
269- JSONObject aa = aaSubstitutions .getJSONObject (i );
270272 int pos = aa .getInt ("codon" );
271273 pos = pos + 1 ; //make 1-based
272274
@@ -342,6 +344,7 @@ public static void processAndImportNextCladeAa(PipelineJob job, File jsonFile, i
342344 Double af ;
343345 Double dp ;
344346
347+ List <String > ntPositions = new ArrayList <>();
345348 if (vcList .size () == 1 )
346349 {
347350 depth = (double )vcList .get (0 ).getAttributeAsInt ("GATK_DP" , 0 );
@@ -350,6 +353,8 @@ public static void processAndImportNextCladeAa(PipelineJob job, File jsonFile, i
350353 alleleDepth = (double )depths .get (2 ) + depths .get (3 );
351354 dp = (double )vcList .get (0 ).getAttributeAsInt ("DP" , 0 );
352355 af = vcList .get (0 ).getAttributeAsDouble ("AF" , 0.0 );
356+
357+ ntPositions .add (String .valueOf (vcList .get (0 ).getStart ()));
353358 }
354359 else
355360 {
@@ -363,6 +368,8 @@ public static void processAndImportNextCladeAa(PipelineJob job, File jsonFile, i
363368
364369 af = vcList .stream ().mapToDouble (x -> x .getAttributeAsDouble ("AF" , 0 )).summaryStatistics ().getAverage ();
365370 dp = vcList .stream ().mapToDouble (x -> x .getAttributeAsDouble ("DP" , 0 )).summaryStatistics ().getAverage ();
371+
372+ vcList .forEach (vc -> ntPositions .add (String .valueOf (vc .getStart ())));
366373 }
367374
368375 int refAaId = ViralSnpUtil .resolveGene (refNtId , aaName );
@@ -376,7 +383,7 @@ public static void processAndImportNextCladeAa(PipelineJob job, File jsonFile, i
376383 aaRow .put ("ref_aa" , aa .getString ("refAA" ));
377384 aaRow .put ("q_aa" , aa .getString ("queryAA" ));
378385 aaRow .put ("codon" , aa .getString ("queryCodon" ));
379- aaRow .put ("ref_nt_positions" , StringUtils .join (positions , "," ));
386+ aaRow .put ("ref_nt_positions" , StringUtils .join (ntPositions , "," ));
380387
381388 aaRow .put ("readcount" , alleleDepth );
382389 aaRow .put ("depth" , depth );
0 commit comments