@Test public void testCalculateConsensusSequence() { Track<Sequence> track = new Track<>(TrackType.BAM); track.setStartIndex(TRACK_START_INDEX); track.setEndIndex(TRACK_END_INDEX); Sequence sequence1 = new Sequence(SEQUENCE_1_START_INDEX, SEQUENCE_1_END_INDEX); Sequence sequence2 = new Sequence(SEQUENCE_2_START_INDEX, SEQUENCE_2_END_INDEX); Sequence sequence3 = new Sequence(SEQUENCE_3_START_INDEX, SEQUENCE_3_END_INDEX); track.setBlocks(Arrays.asList(sequence1, sequence2, sequence3)); Map<Sequence, List<SAMRecord>> blockToReadsMap = new HashMap<>(INITIAL_CAPACITY); SAMRecord samRecord1 = Mockito.mock(SAMRecord.class); Mockito.when(samRecord1.getReadString()).thenReturn(READ_1); SAMRecord samRecord2 = Mockito.mock(SAMRecord.class); Mockito.when(samRecord2.getReadString()).thenReturn(READ_2); SAMRecord samRecord3 = Mockito.mock(SAMRecord.class); Mockito.when(samRecord3.getReadString()).thenReturn(READ_3); SAMRecord samRecord4 = Mockito.mock(SAMRecord.class); Mockito.when(samRecord4.getReadString()).thenReturn(READ_4); SAMRecord samRecord5 = Mockito.mock(SAMRecord.class); Mockito.when(samRecord5.getReadString()).thenReturn(READ_5); SAMRecord samRecord6 = Mockito.mock(SAMRecord.class); Mockito.when(samRecord6.getReadString()).thenReturn(READ_6); SAMRecord samRecord7 = Mockito.mock(SAMRecord.class); Mockito.when(samRecord7.getReadString()).thenReturn(READ_7); blockToReadsMap.put(sequence1, Arrays.asList(samRecord1, samRecord2, samRecord3)); blockToReadsMap.put(sequence2, Arrays.asList(samRecord4, samRecord5)); blockToReadsMap.put(sequence3, Arrays.asList(samRecord6, samRecord7)); ConsensusSequenceUtils.calculateConsensusSequence(track, blockToReadsMap); Assert.assertNotNull(track); Assert.assertNotNull(track.getBlocks()); Assert.assertNotNull(track.getBlocks().get(0)); Assert.assertNotNull(track.getBlocks().get(1)); Assert.assertNotNull(track.getBlocks().get(2)); Assert.assertEquals(track.getBlocks().get(0).getText(), "T"); Assert.assertEquals(track.getBlocks().get(1).getText(), "[GC]"); Assert.assertEquals(track.getBlocks().get(2).getText(), "N"); }
public static void calculateConsensusSequence(final Track<Sequence> track, final Map<Sequence, List<SAMRecord>> blockToReadsMap) { for (Sequence sequence : track.getBlocks()) { final List<SAMRecord> blockReads = blockToReadsMap.get(sequence); final Map<String, Integer> atgcMap = new HashMap<>(); final NucleotideContent nucleotideContent = new NucleotideContent(); if (blockReads == null || blockReads.isEmpty()) { continue; } nucleotideContent.setTotalNumberOfNucleotides(calculateNucleotideFrequencies(blockReads, atgcMap, nucleotideContent)); String consensusNucleotide = checkFirstCriteria(atgcMap, nucleotideContent.getTotalNumberOfNucleotides()); if (consensusNucleotide == null) { consensusNucleotide = checkSecondCriteria(atgcMap, nucleotideContent.getTotalNumberOfNucleotides()); } if (consensusNucleotide == null) { consensusNucleotide = "N"; } sequence.setText(consensusNucleotide); } }
ConsensusSequenceUtils { public static void calculateConsensusSequence(final Track<Sequence> track, final Map<Sequence, List<SAMRecord>> blockToReadsMap) { for (Sequence sequence : track.getBlocks()) { final List<SAMRecord> blockReads = blockToReadsMap.get(sequence); final Map<String, Integer> atgcMap = new HashMap<>(); final NucleotideContent nucleotideContent = new NucleotideContent(); if (blockReads == null || blockReads.isEmpty()) { continue; } nucleotideContent.setTotalNumberOfNucleotides(calculateNucleotideFrequencies(blockReads, atgcMap, nucleotideContent)); String consensusNucleotide = checkFirstCriteria(atgcMap, nucleotideContent.getTotalNumberOfNucleotides()); if (consensusNucleotide == null) { consensusNucleotide = checkSecondCriteria(atgcMap, nucleotideContent.getTotalNumberOfNucleotides()); } if (consensusNucleotide == null) { consensusNucleotide = "N"; } sequence.setText(consensusNucleotide); } } }
ConsensusSequenceUtils { public static void calculateConsensusSequence(final Track<Sequence> track, final Map<Sequence, List<SAMRecord>> blockToReadsMap) { for (Sequence sequence : track.getBlocks()) { final List<SAMRecord> blockReads = blockToReadsMap.get(sequence); final Map<String, Integer> atgcMap = new HashMap<>(); final NucleotideContent nucleotideContent = new NucleotideContent(); if (blockReads == null || blockReads.isEmpty()) { continue; } nucleotideContent.setTotalNumberOfNucleotides(calculateNucleotideFrequencies(blockReads, atgcMap, nucleotideContent)); String consensusNucleotide = checkFirstCriteria(atgcMap, nucleotideContent.getTotalNumberOfNucleotides()); if (consensusNucleotide == null) { consensusNucleotide = checkSecondCriteria(atgcMap, nucleotideContent.getTotalNumberOfNucleotides()); } if (consensusNucleotide == null) { consensusNucleotide = "N"; } sequence.setText(consensusNucleotide); } } private  ConsensusSequenceUtils(); }
ConsensusSequenceUtils { public static void calculateConsensusSequence(final Track<Sequence> track, final Map<Sequence, List<SAMRecord>> blockToReadsMap) { for (Sequence sequence : track.getBlocks()) { final List<SAMRecord> blockReads = blockToReadsMap.get(sequence); final Map<String, Integer> atgcMap = new HashMap<>(); final NucleotideContent nucleotideContent = new NucleotideContent(); if (blockReads == null || blockReads.isEmpty()) { continue; } nucleotideContent.setTotalNumberOfNucleotides(calculateNucleotideFrequencies(blockReads, atgcMap, nucleotideContent)); String consensusNucleotide = checkFirstCriteria(atgcMap, nucleotideContent.getTotalNumberOfNucleotides()); if (consensusNucleotide == null) { consensusNucleotide = checkSecondCriteria(atgcMap, nucleotideContent.getTotalNumberOfNucleotides()); } if (consensusNucleotide == null) { consensusNucleotide = "N"; } sequence.setText(consensusNucleotide); } } private  ConsensusSequenceUtils(); static void calculateConsensusSequence(final Track<Sequence> track,
                                                  final Map<Sequence, List<SAMRecord>> blockToReadsMap); }
ConsensusSequenceUtils { public static void calculateConsensusSequence(final Track<Sequence> track, final Map<Sequence, List<SAMRecord>> blockToReadsMap) { for (Sequence sequence : track.getBlocks()) { final List<SAMRecord> blockReads = blockToReadsMap.get(sequence); final Map<String, Integer> atgcMap = new HashMap<>(); final NucleotideContent nucleotideContent = new NucleotideContent(); if (blockReads == null || blockReads.isEmpty()) { continue; } nucleotideContent.setTotalNumberOfNucleotides(calculateNucleotideFrequencies(blockReads, atgcMap, nucleotideContent)); String consensusNucleotide = checkFirstCriteria(atgcMap, nucleotideContent.getTotalNumberOfNucleotides()); if (consensusNucleotide == null) { consensusNucleotide = checkSecondCriteria(atgcMap, nucleotideContent.getTotalNumberOfNucleotides()); } if (consensusNucleotide == null) { consensusNucleotide = "N"; } sequence.setText(consensusNucleotide); } } private  ConsensusSequenceUtils(); static void calculateConsensusSequence(final Track<Sequence> track,
                                                  final Map<Sequence, List<SAMRecord>> blockToReadsMap);  }