Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Innocuous housekeeping changes in the partially determined haplotypes code #8361

Merged
merged 33 commits into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
953cb12
simplify signature of generatePDHaplotypes
davidbenjamin Jun 12, 2023
1b41ec3
renamed debugSite -> debug
davidbenjamin Jun 12, 2023
47dc12e
exploiting the syntax of putIfAbsent to save a couple of lines
davidbenjamin Jun 12, 2023
030da29
introduced Utils.printIf to organize all the if (debug) System.out.pr…
davidbenjamin Jun 12, 2023
c1509cb
introduced a method for making a dragen debug string from Collections…
davidbenjamin Jun 12, 2023
3af87a1
Haplotype implements Locatable
davidbenjamin Jun 12, 2023
dfeb18e
extracted a dragenStart method
davidbenjamin Jun 12, 2023
f1f08e1
replaced a loop with a Collector
davidbenjamin Jun 12, 2023
ce5f0d9
extracted several debug message methods
davidbenjamin Jun 12, 2023
bfb1553
using a Comparator instead of an anonymous class
davidbenjamin Jun 12, 2023
957994c
using a continue statement to reduce some deep nesting
davidbenjamin Jun 12, 2023
9671131
Renamed a couple of variables
davidbenjamin Jun 12, 2023
a6526f4
eliminated an intermediate bookkeeping variable
davidbenjamin Jun 12, 2023
c332780
eliminated a non-final variable
davidbenjamin Jun 12, 2023
b029aa7
populateBitset is void
davidbenjamin Jun 12, 2023
9f5fe0c
simplify code for choosing final list of events to use in PD haplotypes
davidbenjamin Jun 12, 2023
9ed08f2
fixed some typos
davidbenjamin Jun 12, 2023
8bddd48
got rid of an extraneous variable that basically copied a list gratui…
davidbenjamin Jun 13, 2023
624d4ec
renaming variant -> event within the EventGroup class
davidbenjamin Jun 13, 2023
78757b0
cleaned eventsOverlapForPDHapsCode
davidbenjamin Jun 13, 2023
616073a
used a groupingBy for eventsByDragenCoordinates
davidbenjamin Jun 13, 2023
d54daed
rewrote a for loop over indices as a forEach
davidbenjamin Jun 15, 2023
889c488
extracted method for making final list of events in order
davidbenjamin Jun 15, 2023
6ae6abf
more printIf
davidbenjamin Jun 15, 2023
5dafa42
machinery for debug dot file bookkeeeping
davidbenjamin Jun 20, 2023
f5d2026
further Boy Scout rule activity in ReadThreadingAssembler
davidbenjamin Jun 20, 2023
0c30de3
bit more of that
davidbenjamin Jun 20, 2023
68b8aa0
some more review edits
davidbenjamin Jun 20, 2023
aebb186
more review
davidbenjamin Jun 20, 2023
b7d9343
polished a for loop
davidbenjamin Jun 20, 2023
ecb07c1
unit test for overlap
davidbenjamin Jun 20, 2023
c89bd0f
Boy Scout Rule in PDHCEUnitTest
davidbenjamin Jun 21, 2023
637d3b6
rename
davidbenjamin Jun 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -420,18 +420,15 @@ private static List<List<Event>> smithWatermanRealignPairsOfVariantsForEquivalen
* at the same base.
*
*/
@VisibleForTesting
static boolean eventsOverlapForPDHapsCode(Event e1, Event e2){
davidbenjamin marked this conversation as resolved.
Show resolved Hide resolved
if (!e1.getContig().equals(e2.getContig())) {
return false;
}

double start1 = dragenStart(e1);
double end1 = e1.getEnd() + (e1.isSimpleInsertion() ? 0.5 : 0);
double start2 = dragenStart(e2);
double end2 = e2.getEnd() + (e2.isSimpleInsertion() ? 0.5 : 0);

//Pulled directly from CoordMath.java (not using here because of doubles)
return (start2 >= start1 && start2 <= end1) || (end2 >=start1 && end2 <= end1) || start1 >= start2 && end1 <= end2;
return !(dragenStart(e1) > end2 || dragenStart(e2) > end1);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.BiPredicate;

public class PartiallyDeterminedHaplotypeComputationEngineUnitTest extends GATKBaseTest {

Expand Down Expand Up @@ -214,4 +215,42 @@ public void testDeletionUnderlapingDeterminedBases() {
Assert.assertEquals(result.getCigar(), TextCigarCodec.decode("10M"));
Assert.assertEquals(result.getDeterminedPosition(), DEL_AA_105.getStart());
}

@Test
public void testEventsOverlapForPDHapsCode() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 i think we are going to appreciate having this unit test in some vague undetermined point in the future

final BiPredicate<Event, Event> overlaps = ((e1, e2) -> PartiallyDeterminedHaplotypeComputationEngine.eventsOverlapForPDHapsCode(e1,e2));

// easy SNP cases
Assert.assertFalse(overlaps.test(SNP_C_100, SNP_G_101));
Assert.assertFalse(overlaps.test(SNP_C_100, SNP_G_102));
Assert.assertFalse(overlaps.test(SNP_C_107, SNP_G_105));
Assert.assertTrue(overlaps.test(SNP_C_105, SNP_G_105));
Assert.assertTrue(overlaps.test(SNP_T_106, SNP_T_106));

// overlap of SNP and deletion -- note that we add 1 to deletion start but not to deletion end
Assert.assertFalse(overlaps.test(DEL_AAA_102, SNP_G_101));
Assert.assertFalse(overlaps.test(DEL_AAA_102, SNP_G_102));
Assert.assertTrue(overlaps.test(DEL_AAA_102, SNP_C_104));
Assert.assertFalse(overlaps.test(DEL_AAA_102, SNP_C_105));

// overlap of SNP and insertion -- note that we add 0.5 to insertion start and end
Assert.assertFalse(overlaps.test(SNP_G_102, INS_TT_103));
Assert.assertFalse(overlaps.test(SNP_C_104, INS_TT_103));
Assert.assertFalse(overlaps.test(SNP_C_105, INS_TT_105));

// two insertions should overlap only if they occur at the same position
Assert.assertTrue(overlaps.test(INS_TT_105, INS_TT_105));
Assert.assertFalse(overlaps.test(INS_TT_105, INS_GGG_106));

// two deletions
Assert.assertTrue(overlaps.test(DEL_AAAAAAA_102, DEL_AAA_102));
Assert.assertTrue(overlaps.test(DEL_AA_105, DEL_AAAAAAA_102));
Assert.assertFalse(overlaps.test(DEL_AA_100, DEL_AAA_102));

// deletion and insertion
Assert.assertFalse(overlaps.test(INS_TT_105, DEL_AA_105)); // add 1 to deletion start but only 0.5 to insertion end
Assert.assertFalse(overlaps.test(INS_TT_103, DEL_AA_105));
Assert.assertTrue(overlaps.test(DEL_AAAAAAA_102, INS_GGG_106));
Assert.assertTrue(overlaps.test(INS_TT_103, DEL_AAA_102));
}
}