Allele extends Locus { public Allele doubleCrossover(final Allele right) throws IllegalSymbolException, IndexOutOfBoundsException, IllegalAlphabetException { if (this.overlaps(right)) { Locus homologue = intersection(right); SymbolList copy = DNATools.createDNA(this.sequence.seqString()); int length = homologue.getEnd() - homologue.getStart(); int target = homologue.getStart() - right.getStart() + 1; int from = homologue.getStart() - this.getStart() + 1; try { SymbolList replace = right.sequence.subList(target, target + length - 1); copy.edit(new Edit(from, length, replace)); } catch(ChangeVetoException e) { } return new Allele(this.name, this.contig, this.getStart(), this.getEnd(), copy, Lesion.UNKNOWN); } return new Allele(this.name, this.contig, this.getStart(), this.getEnd(), this.sequence, Lesion.UNKNOWN); } Allele(final String name, final String contig, final int start, final int end, final SymbolList sequence, final Lesion lesion); String getName(); void setName(final String name); static Builder builder(); @Override boolean equals(final Object right); @Override int hashCode(); Allele doubleCrossover(final Allele right); Allele merge(final Allele right, final long minimumOverlap); Allele leftHardClip(final String pattern); Allele rightHardClip(final String pattern); final SymbolList sequence; final Lesion lesion; }
@Test public void testDoubleCrossover() throws AlleleException { try { temp = allele1.doubleCrossover(allele2); assertEquals(temp.getStart(), 5); assertEquals(temp.getEnd(), 20); assertEquals(temp.sequence.seqString(), "-----aaaaa-----"); temp = allele2.doubleCrossover(allele1); assertEquals(temp.getStart(), 10); assertEquals(temp.getEnd(), 15); assertEquals(temp.sequence.seqString(), "-----"); temp = allele3.doubleCrossover(allele4); assertEquals(temp.getStart(), 5); assertEquals(temp.getEnd(), 15); assertEquals(temp.sequence.seqString(), "-----aaaaa"); temp = allele4.doubleCrossover(allele3); assertEquals(temp.getStart(), 10); assertEquals(temp.getEnd(), 20); assertEquals(temp.sequence.seqString(), "-----ttttt"); temp = allele4.doubleCrossover(allele4); assertEquals(temp.getStart(), 10); assertEquals(temp.getEnd(), 20); assertEquals(temp.sequence.seqString(), "aaaaattttt"); } catch (Exception e) { fail(); } }