From 5395d75189f8e0445f5f40a44f2151c2478a6716 Mon Sep 17 00:00:00 2001 From: Ilya Soifer Date: Wed, 24 May 2023 22:14:24 +0300 Subject: [PATCH] Fixed tests --- .../utils/read/FlowBasedReadUtils.java | 38 +++++++++++++------ .../read/FlowBasedReadUtilsUnitTest.java | 12 +++++- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/utils/read/FlowBasedReadUtils.java b/src/main/java/org/broadinstitute/hellbender/utils/read/FlowBasedReadUtils.java index f5b251393e4..d7a7a76faaf 100644 --- a/src/main/java/org/broadinstitute/hellbender/utils/read/FlowBasedReadUtils.java +++ b/src/main/java/org/broadinstitute/hellbender/utils/read/FlowBasedReadUtils.java @@ -15,8 +15,15 @@ import java.util.LinkedHashMap; import java.util.Map; + /** - * utility class for flow based read + * Utility class for working with flow-based reads + * + * The main member static class is {@code ReadGroupInfo} that contains methods that allow + * working with headers of flow based reads and extracting the flow order and the maximal hmer class called. + * It also contains methods to check how the read was clipped ({@code readEndMarkedUnclipped}, {@code readEndMarkedUncertain}) + * Lastly, {@code FlowBasedReadUtils.isFlowPlatform} is **the** function to determine if the data are flow-based + * */ public class FlowBasedReadUtils { @@ -37,20 +44,19 @@ public ReadGroupInfo(final SAMReadGroupRecord readGroup) { isFlowPlatform = false; } else if (NGSPlatform.fromReadGroupPL(readGroup.getPlatform())==NGSPlatform.UNKNOWN){ isFlowPlatform = false; - } else { - //old Ultima data can have PLATFORM==LS454 - // we require also FO field to consider ReadGroup to come from the flow - boolean tmp = (NGSPlatform.fromReadGroupPL(readGroup.getPlatform()) == NGSPlatform.LS454) || - (NGSPlatform.fromReadGroupPL(readGroup.getPlatform()) == NGSPlatform.ULTIMA); - tmp = tmp & (readGroup!=null); - tmp = tmp & (readGroup.getFlowOrder()!=null); - isFlowPlatform = tmp; - - //in addition validate that the ultima data has FO tag, otherwise break - if ((NGSPlatform.fromReadGroupPL(readGroup.getPlatform()) == NGSPlatform.ULTIMA) & (!isFlowPlatform)){ + } else if (NGSPlatform.fromReadGroupPL(readGroup.getPlatform()) == NGSPlatform.LS454) { + //old Ultima data can have PLATFORM==LS454 and not have FO tag + isFlowPlatform = true; + } else if (NGSPlatform.fromReadGroupPL(readGroup.getPlatform()) == NGSPlatform.ULTIMA){ + if (readGroup.getFlowOrder()!=null) { + isFlowPlatform = true; + } else { throw new RuntimeException("Malformed Ultima read group identified, aborting: " + readGroup); } + } else { + isFlowPlatform = false; } + if (isFlowPlatform) { this.flowOrder = readGroup.getFlowOrder(); String mc = readGroup.getAttribute(FlowBasedRead.MAX_CLASS_READ_GROUP_TAG); @@ -154,6 +160,14 @@ public static boolean hasFlowTags(final SAMRecord rec) { } + /** + * + * This is the function to run if you want to ask if the data are flow-based + * + * @param hdr - file header + * @param read - the read + * @return true if the read is flow-based + */ public static boolean isFlowPlatform(final SAMFileHeader hdr, final GATKRead read) { if (!hasFlowTags(read)){ return false; diff --git a/src/test/java/org/broadinstitute/hellbender/utils/read/FlowBasedReadUtilsUnitTest.java b/src/test/java/org/broadinstitute/hellbender/utils/read/FlowBasedReadUtilsUnitTest.java index ec935c1f68e..b249b21461b 100644 --- a/src/test/java/org/broadinstitute/hellbender/utils/read/FlowBasedReadUtilsUnitTest.java +++ b/src/test/java/org/broadinstitute/hellbender/utils/read/FlowBasedReadUtilsUnitTest.java @@ -97,7 +97,7 @@ Object[][] getIsFlowPlatformInputs() { rg3.setPlatform("LS454"); read3.setReadGroup("rg3"); hdr.addReadGroup(rg3); - tests.add(new Object[]{hdr, read3, false}); + tests.add(new Object[]{hdr, read3, true}); GATKRead read4 = makeRead(new byte[]{'T','A','G','C','G','A'}, false); read4.setAttribute("tp",new byte[6]); @@ -108,6 +108,16 @@ Object[][] getIsFlowPlatformInputs() { hdr.addReadGroup(rg4); tests.add(new Object[]{hdr, read4, true}); + GATKRead read5 = makeRead(new byte[]{'T','A','G','C','G','A'}, false); + read5.setAttribute("tp",new byte[6]); + SAMReadGroupRecord rg5 = new SAMReadGroupRecord("rg5"); + rg5.setPlatform("LS454"); + rg5.setAttribute("FO","TGCATGCA"); + read5.setReadGroup("rg5"); + hdr.addReadGroup(rg5); + tests.add(new Object[]{hdr, read5, true}); + + return tests.toArray(new Object[][]{}); }