@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void testCalculateConsensusSequencePerformance() throws IOException { boolean isPerformanceTest = true; BamFile bamFile = setUpTestFile(); int i = 0; double avTime1 = 0.0; double avTime2 = 0.0; double avTime3 = 0.0; do { Track<Sequence> track = new Track<>(); track.setStartIndex(TEST_START_INDEX_SMALL_RANGE); track.setEndIndex(TEST_END_INDEX_SMALL_RANGE); track.setScaleFactor(SCALE_FACTOR_SMALL); track.setChromosome(testChromosome); track.setId(bamFile.getId()); long start = System.currentTimeMillis(); Track<Sequence> seq = bamManager.calculateConsensusSequence(track); long end = System.currentTimeMillis(); Assert.assertNotNull(seq); avTime1 += (end - start); track.setStartIndex(TEST_START_INDEX_LARGE_RANGE); track.setEndIndex(TEST_END_INDEX_LARGE_RANGE); track.setScaleFactor(SCALE_FACTOR_LARGE); start = System.currentTimeMillis(); seq = bamManager.calculateConsensusSequence(track); end = System.currentTimeMillis(); Assert.assertNotNull(seq); avTime2 += (end - start); track.setStartIndex(TEST_START_INDEX_MEDIUM_RANGE); track.setEndIndex(TEST_END_INDEX_MEDIUM_RANGE); track.setScaleFactor(SCALE_FACTOR_MEDIUM); start = System.currentTimeMillis(); seq = bamManager.calculateConsensusSequence(track); end = System.currentTimeMillis(); Assert.assertNotNull(seq); avTime3 += (end - start); i++; if (i == 10) { avTime1 = avTime1 / 10; System.out.println("BAM seq (small scale) tooks " + avTime1 + "ms"); avTime2 = avTime2 / 10; System.out.println("BAM seq (large scale) tooks " + avTime2 + "ms"); avTime3 = avTime3 / 10; System.out.println("BAM seq (medium scale) tooks " + avTime3 + "ms"); isPerformanceTest = false; } } while (isPerformanceTest); }
public Track<Sequence> calculateConsensusSequence(final Track<Sequence> track) throws IOException { if (track.getEndIndex() - track.getStartIndex() > maxCoverageRange) { return new Track<>(track); } final Chromosome chromosome = trackHelper.validateTrackWithBlockCount(track); TrackHelper.fillBlocks(track, indexes -> new Sequence(indexes.getLeft(), indexes.getRight())); return bamHelper.calculateConsensusSequence(track, chromosome); }
BamManager { public Track<Sequence> calculateConsensusSequence(final Track<Sequence> track) throws IOException { if (track.getEndIndex() - track.getStartIndex() > maxCoverageRange) { return new Track<>(track); } final Chromosome chromosome = trackHelper.validateTrackWithBlockCount(track); TrackHelper.fillBlocks(track, indexes -> new Sequence(indexes.getLeft(), indexes.getRight())); return bamHelper.calculateConsensusSequence(track, chromosome); } }
BamManager { public Track<Sequence> calculateConsensusSequence(final Track<Sequence> track) throws IOException { if (track.getEndIndex() - track.getStartIndex() > maxCoverageRange) { return new Track<>(track); } final Chromosome chromosome = trackHelper.validateTrackWithBlockCount(track); TrackHelper.fillBlocks(track, indexes -> new Sequence(indexes.getLeft(), indexes.getRight())); return bamHelper.calculateConsensusSequence(track, chromosome); }  }
BamManager { public Track<Sequence> calculateConsensusSequence(final Track<Sequence> track) throws IOException { if (track.getEndIndex() - track.getStartIndex() > maxCoverageRange) { return new Track<>(track); } final Chromosome chromosome = trackHelper.validateTrackWithBlockCount(track); TrackHelper.fillBlocks(track, indexes -> new Sequence(indexes.getLeft(), indexes.getRight())); return bamHelper.calculateConsensusSequence(track, chromosome); }  BamFile registerBam(final IndexedFileRegistrationRequest request); BamFile unregisterBamFile(final long bamFileId); void sendBamTrackToEmitter(final Track<Read> track, BamQueryOption option, ResponseBodyEmitter emitter); void sendBamTrackToEmitterFromUrl(final Track<Read> track, BamQueryOption option, String bamUrl,
                                                       String indexUrl, ResponseBodyEmitter emitter); Track<Sequence> calculateConsensusSequence(final Track<Sequence> track); Read loadRead(final ReadQuery query, String fileUrl, String indexUrl); }
BamManager { public Track<Sequence> calculateConsensusSequence(final Track<Sequence> track) throws IOException { if (track.getEndIndex() - track.getStartIndex() > maxCoverageRange) { return new Track<>(track); } final Chromosome chromosome = trackHelper.validateTrackWithBlockCount(track); TrackHelper.fillBlocks(track, indexes -> new Sequence(indexes.getLeft(), indexes.getRight())); return bamHelper.calculateConsensusSequence(track, chromosome); }  BamFile registerBam(final IndexedFileRegistrationRequest request); BamFile unregisterBamFile(final long bamFileId); void sendBamTrackToEmitter(final Track<Read> track, BamQueryOption option, ResponseBodyEmitter emitter); void sendBamTrackToEmitterFromUrl(final Track<Read> track, BamQueryOption option, String bamUrl,
                                                       String indexUrl, ResponseBodyEmitter emitter); Track<Sequence> calculateConsensusSequence(final Track<Sequence> track); Read loadRead(final ReadQuery query, String fileUrl, String indexUrl);  }