private static void addSpan(final int seqId, final int start, final int span, final int count, final Map<Integer, AlignmentSpan> map) { if (map.containsKey(seqId)) { map.get(seqId).add(start, span, count); } else { map.put(seqId, new AlignmentSpan(start, span, count)); } }
private static void addSpan(final int seqId, final int start, final int span, final int count, final Map<Integer, AlignmentSpan> map) { if (map.containsKey(seqId)) { map.get(seqId).add(start, span, count); } else { map.put(seqId, new AlignmentSpan(start, span, count)); } }
private static void addSpan(final int seqId, final int start, final int span, final int count, final Map<Integer, AlignmentSpan> map) { if (map.containsKey(seqId)) { map.get(seqId).add(start, span, count); } else { map.put(seqId, new AlignmentSpan(start, span, count)); } }
private void readCramRecord() { final CramCompressionRecord cramRecord = new CramCompressionRecord(); super.read(cramRecord); if (APDelta) { currentAlignmentStart += cramRecord.alignmentDelta; } else { currentAlignmentStart = cramRecord.alignmentStart; } if (!spans.containsKey(cramRecord.sequenceId)) { spans.put(cramRecord.sequenceId, new AlignmentSpan(currentAlignmentStart, cramRecord.readLength)); } else { spans.get(cramRecord.sequenceId).addSingle(currentAlignmentStart, cramRecord.readLength); } } }
private void readCramRecord() { final CramCompressionRecord cramRecord = new CramCompressionRecord(); super.read(cramRecord); if (APDelta) { currentAlignmentStart += cramRecord.alignmentDelta; } else { currentAlignmentStart = cramRecord.alignmentStart; } if (!spans.containsKey(cramRecord.sequenceId)) { spans.put(cramRecord.sequenceId, new AlignmentSpan(currentAlignmentStart, cramRecord.readLength)); } else { spans.get(cramRecord.sequenceId).addSingle(currentAlignmentStart, cramRecord.readLength); } } }
public static Map<Integer, AlignmentSpan> getSpans(List<SAMRecord> samRecords) { Map<Integer, AlignmentSpan> spans = new HashMap<Integer, AlignmentSpan>(); int unmapped = 0; for (final SAMRecord r : samRecords) { int refId = r.getReferenceIndex(); if (refId == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX) { unmapped++; continue; } int start = r.getAlignmentStart(); int end = r.getAlignmentEnd(); if (spans.containsKey(refId)) { spans.get(refId).add(start, end - start, 1); } else { spans.put(refId, new AlignmentSpan(start, end - start)); } } if (unmapped > 0) { AlignmentSpan span = new AlignmentSpan(AlignmentSpan.UNMAPPED_SPAN.getStart(), AlignmentSpan.UNMAPPED_SPAN.getSpan(), unmapped); spans.put(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX, span); } return spans; }
@Test public void testMultirefContainerWithUnmapped() { final List<AlignmentSpan> expectedSpans = new ArrayList<>(); expectedSpans.add(new AlignmentSpan(1, 3, 1)); expectedSpans.add(new AlignmentSpan(2, 3, 1));
Assert.assertTrue(spans.containsKey(2)); Assert.assertTrue(spans.containsKey(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX)); Assert.assertEquals(spans.get(1), new AlignmentSpan(1, 5, 2)); Assert.assertEquals(spans.get(2), new AlignmentSpan(2, 3, 1)); Assert.assertNotNull(spans.get(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX));
@Test public void testMultirefContainer() { final Map<Integer, AlignmentSpan> expectedSpans = new HashMap<>(); for (int i = 0; i < 10; i++) { expectedSpans.put(i, new AlignmentSpan(i + 1, 3, 1)); } final ContainerFactory factory = new ContainerFactory(ContainerFactoryTest.getSAMFileHeaderForTests(), TEST_RECORD_COUNT); final Container container = factory.buildContainer(ContainerFactoryTest.getMultiRefRecords()); final ContainerParser parser = new ContainerParser(ContainerFactoryTest.getSAMFileHeaderForTests()); final Map<Integer, AlignmentSpan> referenceSet = parser.getReferences(container, ValidationStringency.STRICT); Assert.assertEquals(referenceSet, expectedSpans); }