18
18
import java .util .stream .Collectors ;
19
19
import java .util .stream .Stream ;
20
20
21
+ import static htsjdk .variant .vcf .VCFConstants .MISSING_VALUE_v4 ;
21
22
import static org .broadinstitute .hellbender .tools .sv .SVCallRecord .UNDEFINED_LENGTH ;
22
23
23
24
public final class SVCallRecordUtils {
@@ -91,6 +92,9 @@ public static VariantContextBuilder getVariantBuilder(final SVCallRecord record)
91
92
&& record .getStrandA () != null && record .getStrandB () != null ) {
92
93
builder .attribute (GATKSVVCFConstants .STRANDS_ATTRIBUTE , getStrandString (record ));
93
94
}
95
+ if (!record .getEvidence ().isEmpty ()) {
96
+ builder .attribute (GATKSVVCFConstants .EVIDENCE , record .getEvidence ());
97
+ }
94
98
if (!record .getFilters ().isEmpty ()) {
95
99
builder .filters (record .getFilters ());
96
100
}
@@ -173,12 +177,12 @@ public static GenotypesContext populateGenotypesForMissingSamplesWithAlleles(fin
173
177
*/
174
178
public static SVCallRecord copyCallWithNewGenotypes (final SVCallRecord record , final GenotypesContext genotypes ) {
175
179
return new SVCallRecord (record .getId (), record .getContigA (), record .getPositionA (), record .getStrandA (), record .getContigB (),
176
- record .getPositionB (), record .getStrandB (), record .getType (), record .getComplexSubtype (), record .getComplexEventIntervals (), record .getLength (), record .getAlgorithms (), record .getAlleles (),
180
+ record .getPositionB (), record .getStrandB (), record .getType (), record .getComplexSubtype (), record .getComplexEventIntervals (), record .getLength (), record .getEvidence (), record . getAlgorithms (), record .getAlleles (),
177
181
genotypes , record .getAttributes (), record .getFilters (), record .getLog10PError ());
178
182
}
179
183
public static SVCallRecord copyCallWithNewAttributes (final SVCallRecord record , final Map <String , Object > attr ) {
180
184
return new SVCallRecord (record .getId (), record .getContigA (), record .getPositionA (), record .getStrandA (), record .getContigB (),
181
- record .getPositionB (), record .getStrandB (), record .getType (), record .getComplexSubtype (), record .getComplexEventIntervals (), record .getLength (), record .getAlgorithms (), record .getAlleles (),
185
+ record .getPositionB (), record .getStrandB (), record .getType (), record .getComplexSubtype (), record .getComplexEventIntervals (), record .getLength (), record .getEvidence (), record . getAlgorithms (), record .getAlleles (),
182
186
record .getGenotypes (), attr , record .getFilters (), record .getLog10PError ());
183
187
}
184
188
@@ -291,10 +295,10 @@ public static Stream<SVCallRecord> convertInversionsToBreakends(final SVCallReco
291
295
Utils .validateArg (record .isIntrachromosomal (), "Inversion " + record .getId () + " is not intrachromosomal" );
292
296
final SVCallRecord positiveBreakend = new SVCallRecord (record .getId (), record .getContigA (),
293
297
record .getPositionA (), true , record .getContigB (), record .getPositionB (), true , GATKSVVCFConstants .StructuralVariantAnnotationType .BND , null ,record .getComplexEventIntervals (), null ,
294
- record .getAlgorithms (), record .getAlleles (), record .getGenotypes (), record .getAttributes (), record .getFilters (), record .getLog10PError (), dictionary );
298
+ record .getEvidence (), record . getAlgorithms (), record .getAlleles (), record .getGenotypes (), record .getAttributes (), record .getFilters (), record .getLog10PError (), dictionary );
295
299
final SVCallRecord negativeBreakend = new SVCallRecord (record .getId (), record .getContigA (),
296
300
record .getPositionA (), false , record .getContigB (), record .getPositionB (), false , GATKSVVCFConstants .StructuralVariantAnnotationType .BND , null ,record .getComplexEventIntervals (), null ,
297
- record .getAlgorithms (), record .getAlleles (), record .getGenotypes (), record .getAttributes (), record .getFilters (), record .getLog10PError (), dictionary );
301
+ record .getEvidence (), record . getAlgorithms (), record .getAlleles (), record .getGenotypes (), record .getAttributes (), record .getFilters (), record .getLog10PError (), dictionary );
298
302
return Stream .of (positiveBreakend , negativeBreakend );
299
303
}
300
304
@@ -319,8 +323,9 @@ public static SVCallRecord create(final VariantContext variant, boolean keepVari
319
323
320
324
final GATKSVVCFConstants .StructuralVariantAnnotationType type = inferStructuralVariantType (variant );
321
325
final GATKSVVCFConstants .ComplexVariantSubtype cpxSubtype = getComplexSubtype (variant );
322
- final List <SVCallRecord .ComplexEventInterval > cpxIntervals = parseComplexIntervals (variant . getAttributeAsStringList ( GATKSVVCFConstants . CPX_INTERVALS , null ) , dictionary );
326
+ final List <SVCallRecord .ComplexEventInterval > cpxIntervals = parseComplexIntervals (variant , dictionary );
323
327
final List <String > algorithms = getAlgorithms (variant );
328
+ final List <GATKSVVCFConstants .EvidenceTypes > evidence = getEvidence (variant );
324
329
325
330
final String strands ;
326
331
if (type == GATKSVVCFConstants .StructuralVariantAnnotationType .DEL
@@ -375,12 +380,13 @@ public static SVCallRecord create(final VariantContext variant, boolean keepVari
375
380
376
381
final Map <String , Object > sanitizedAttributes = sanitizeAttributes (attributes );
377
382
return new SVCallRecord (id , contigA , positionA , strand1 , contigB , positionB , strand2 , type , cpxSubtype ,
378
- cpxIntervals , length , algorithms , variant .getAlleles (), variant .getGenotypes (), sanitizedAttributes ,
383
+ cpxIntervals , length , evidence , algorithms , variant .getAlleles (), variant .getGenotypes (), sanitizedAttributes ,
379
384
variant .getFilters (), log10PError );
380
385
}
381
386
382
- private static List <SVCallRecord .ComplexEventInterval > parseComplexIntervals (final List <String > intervals , final SAMSequenceDictionary dictionary ) {
383
- return intervals .stream ().map (i -> SVCallRecord .ComplexEventInterval .decode (i , dictionary )).toList ();
387
+ private static List <SVCallRecord .ComplexEventInterval > parseComplexIntervals (final VariantContext variant , final SAMSequenceDictionary dictionary ) {
388
+ return variant .getAttributeAsStringList (GATKSVVCFConstants .CPX_INTERVALS , null ).stream ()
389
+ .map (i -> SVCallRecord .ComplexEventInterval .decode (i , dictionary )).toList ();
384
390
}
385
391
386
392
private static Map <String , Object > sanitizeAttributes (final Map <String , Object > attributes ) {
@@ -402,6 +408,19 @@ private static Integer getLength(final VariantContext variant, final GATKSVVCFCo
402
408
return length ;
403
409
}
404
410
411
+ public static List <GATKSVVCFConstants .EvidenceTypes > getEvidence (final VariantContext variant ) {
412
+ Utils .nonNull (variant );
413
+ final List <String > value = variant .getAttributeAsStringList (GATKSVVCFConstants .EVIDENCE , null );
414
+ if (value == null ) {
415
+ return Collections .emptyList ();
416
+ } else {
417
+ return value .stream ()
418
+ .filter (v -> v != null && !v .equals (MISSING_VALUE_v4 ))
419
+ .map (GATKSVVCFConstants .EvidenceTypes ::valueOf )
420
+ .collect (Collectors .toList ());
421
+ }
422
+ }
423
+
405
424
public static List <String > getAlgorithms (final VariantContext variant ) {
406
425
Utils .nonNull (variant );
407
426
Utils .validateArg (variant .hasAttribute (GATKSVVCFConstants .ALGORITHMS_ATTRIBUTE ), "Expected " + GATKSVVCFConstants .ALGORITHMS_ATTRIBUTE + " field for variant " + variant .getID ());
0 commit comments