@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void saveBamTest() throws IOException, InterruptedException { final String path = resource.getFile().getAbsolutePath() + TEST_BAM_NAME; IndexedFileRegistrationRequest request = new IndexedFileRegistrationRequest(); request.setPath(path); request.setIndexPath(path + BAI_EXTENSION); request.setName(TEST_NSAME); request.setReferenceId(testReference.getId()); request.setPrettyName(PRETTY_NAME); request.setType(BiologicalDataItemResourceType.FILE); BamFile bamFile = bamManager.registerBam(request); Assert.assertNotNull(bamFile); final BamFile loadBamFile = bamFileManager.load(bamFile.getId()); Assert.assertNotNull(loadBamFile); Assert.assertTrue(bamFile.getId().equals(loadBamFile.getId())); Assert.assertTrue(bamFile.getName().equals(loadBamFile.getName())); Assert.assertEquals(PRETTY_NAME, bamFile.getPrettyName()); Assert.assertTrue(bamFile.getCreatedDate().equals(loadBamFile.getCreatedDate())); Assert.assertTrue(bamFile.getReferenceId().equals(loadBamFile.getReferenceId())); Assert.assertTrue(bamFile.getPath().equals(loadBamFile.getPath())); Assert.assertTrue(bamFile.getIndex().getPath().equals(loadBamFile.getIndex().getPath())); assertTrackLoading(bamFile, (option) -> {}, (track) -> { testBamTrack(track); Read testRead = track.getBlocks().get(0); testRead(testRead); }); assertTrackLoading(bamFile, (option) -> option.setTrackDirection(TrackDirectionType.RIGHT), this::testBamTrack); assertTrackLoading(bamFile, (option) -> option.setTrackDirection(TrackDirectionType.MIDDLE), this::testBamTrack); assertTrackLoading(bamFile, (option) -> option.setTrackDirection(null), this::testBamTrack); assertTrackLoading(bamFile, (option) -> option.setShowSpliceJunction(false), this::testBamTrack); assertTrackLoading(bamFile, (option) -> option.setShowSpliceJunction(null), this::testBamTrack); assertTrackLoading(bamFile, (option) -> option.setShowClipping(false), this::testBamTrack); assertTrackLoading(bamFile, (option) -> option.setShowClipping(null), this::testBamTrack); assertTrackLoading(bamFile, (option) -> option.setFilterDuplicate(true), this::testBamTrack); assertTrackLoading(bamFile, (option) -> { option.setFilterDuplicate(false); option.setFilterNotPrimary(true); }, this::testBamTrack); assertTrackLoading(bamFile, (option) -> { option.setFilterNotPrimary(false); option.setFilterVendorQualityFail(true); }, this::testBamTrack); assertTrackLoading(bamFile, (option) -> { option.setFilterVendorQualityFail(false); option.setFilterSupplementaryAlignment(true); }, this::testBamTrack); assertTrackLoading(bamFile, (option) -> { option.setFilterSupplementaryAlignment(false); option.setFrame(0); option.setDownSampling(false); }, (track) -> Assert.assertTrue(track.getDownsampleCoverage() == null)); assertTrackLoading(bamFile, (option) -> { option.setFrame(-TEST_FRAME_SIZE); option.setDownSampling(false); }, (track) -> Assert.assertTrue(track.getDownsampleCoverage() == null)); assertTrackLoading(bamFile, (option) -> { option.setCount(LARGE_TEST_COUNT); option.setDownSampling(false); }, (track) -> Assert.assertTrue(track.getDownsampleCoverage() == null)); assertTrackLoading(bamFile, (option) -> { option.setFrame(LARGE_FRAME_SIZE); option.setDownSampling(false); }, (track) -> Assert.assertTrue(track.getDownsampleCoverage() == null)); assertTrackLoading(bamFile, (option) -> { option.setCount(null); option.setDownSampling(false); }, (track) -> Assert.assertTrue(track.getDownsampleCoverage() == null)); assertTrackLoading(bamFile, (option) -> { option.setCount(null); option.setDownSampling(false); }, (track) -> Assert.assertTrue(track.getDownsampleCoverage() == null)); assertTrackLoading(bamFile, (option) -> { option.setTrackDirection(TrackDirectionType.MIDDLE); }, (track) -> { testBamTrack(track); Read testRead = track.getBlocks().get(0); testRead(testRead); } ); assertTrackLoading(bamFile, (option) -> { option.setTrackDirection(TrackDirectionType.LEFT); option.setShowClipping(false); option.setShowSpliceJunction(true); }, (track) -> { Assert.assertTrue(!track.getBlocks().isEmpty()); Read testRead = track.getBlocks().get(0); testRead(testRead); } ); assertTrackLoading(bamFile, (option) -> { option.setTrackDirection(TrackDirectionType.RIGHT); option.setShowClipping(true); option.setShowSpliceJunction(false); }, (track) -> { Assert.assertTrue(!track.getBlocks().isEmpty()); Read testRead = track.getBlocks().get(0); testRead(testRead); } ); }
public BamFile registerBam(final IndexedFileRegistrationRequest request) throws IOException { Assert.notNull(request, getMessage(MessagesConstants.ERROR_NULL_PARAM)); Assert.notNull(request.getPath(), getMessage(MessagesConstants.ERROR_NULL_PARAM)); Assert.notNull(request.getReferenceId(), getMessage(NO_SUCH_REFERENCE)); Assert.notNull(request.getIndexPath(), getMessage(MessagesConstants.WRONG_BAM_INDEX_FILE)); if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } final BamFile newBamFile = bamHelper.fillBamFile(request); try { biologicalDataItemManager.createBiologicalDataItem(newBamFile); Reference reference = referenceGenomeManager.load(request.getReferenceId()); List<Chromosome> chromosomes = reference.getChromosomes(); LOGGER.debug(getMessage(MessagesConstants.DEBUG_FILE_READING, request.getPath())); bamHelper.parseBamFile(newBamFile, chromosomes, reference.getId()); biologicalDataItemManager.createBiologicalDataItem(newBamFile.getIndex()); bamFileManager.create(newBamFile); } finally { if (newBamFile != null && newBamFile.getId() != null && bamFileManager.load(newBamFile.getId()) == null) { biologicalDataItemManager.deleteBiologicalDataItem(newBamFile.getId()); } } return newBamFile; }
BamManager { public BamFile registerBam(final IndexedFileRegistrationRequest request) throws IOException { Assert.notNull(request, getMessage(MessagesConstants.ERROR_NULL_PARAM)); Assert.notNull(request.getPath(), getMessage(MessagesConstants.ERROR_NULL_PARAM)); Assert.notNull(request.getReferenceId(), getMessage(NO_SUCH_REFERENCE)); Assert.notNull(request.getIndexPath(), getMessage(MessagesConstants.WRONG_BAM_INDEX_FILE)); if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } final BamFile newBamFile = bamHelper.fillBamFile(request); try { biologicalDataItemManager.createBiologicalDataItem(newBamFile); Reference reference = referenceGenomeManager.load(request.getReferenceId()); List<Chromosome> chromosomes = reference.getChromosomes(); LOGGER.debug(getMessage(MessagesConstants.DEBUG_FILE_READING, request.getPath())); bamHelper.parseBamFile(newBamFile, chromosomes, reference.getId()); biologicalDataItemManager.createBiologicalDataItem(newBamFile.getIndex()); bamFileManager.create(newBamFile); } finally { if (newBamFile != null && newBamFile.getId() != null && bamFileManager.load(newBamFile.getId()) == null) { biologicalDataItemManager.deleteBiologicalDataItem(newBamFile.getId()); } } return newBamFile; } }
BamManager { public BamFile registerBam(final IndexedFileRegistrationRequest request) throws IOException { Assert.notNull(request, getMessage(MessagesConstants.ERROR_NULL_PARAM)); Assert.notNull(request.getPath(), getMessage(MessagesConstants.ERROR_NULL_PARAM)); Assert.notNull(request.getReferenceId(), getMessage(NO_SUCH_REFERENCE)); Assert.notNull(request.getIndexPath(), getMessage(MessagesConstants.WRONG_BAM_INDEX_FILE)); if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } final BamFile newBamFile = bamHelper.fillBamFile(request); try { biologicalDataItemManager.createBiologicalDataItem(newBamFile); Reference reference = referenceGenomeManager.load(request.getReferenceId()); List<Chromosome> chromosomes = reference.getChromosomes(); LOGGER.debug(getMessage(MessagesConstants.DEBUG_FILE_READING, request.getPath())); bamHelper.parseBamFile(newBamFile, chromosomes, reference.getId()); biologicalDataItemManager.createBiologicalDataItem(newBamFile.getIndex()); bamFileManager.create(newBamFile); } finally { if (newBamFile != null && newBamFile.getId() != null && bamFileManager.load(newBamFile.getId()) == null) { biologicalDataItemManager.deleteBiologicalDataItem(newBamFile.getId()); } } return newBamFile; }  }
BamManager { public BamFile registerBam(final IndexedFileRegistrationRequest request) throws IOException { Assert.notNull(request, getMessage(MessagesConstants.ERROR_NULL_PARAM)); Assert.notNull(request.getPath(), getMessage(MessagesConstants.ERROR_NULL_PARAM)); Assert.notNull(request.getReferenceId(), getMessage(NO_SUCH_REFERENCE)); Assert.notNull(request.getIndexPath(), getMessage(MessagesConstants.WRONG_BAM_INDEX_FILE)); if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } final BamFile newBamFile = bamHelper.fillBamFile(request); try { biologicalDataItemManager.createBiologicalDataItem(newBamFile); Reference reference = referenceGenomeManager.load(request.getReferenceId()); List<Chromosome> chromosomes = reference.getChromosomes(); LOGGER.debug(getMessage(MessagesConstants.DEBUG_FILE_READING, request.getPath())); bamHelper.parseBamFile(newBamFile, chromosomes, reference.getId()); biologicalDataItemManager.createBiologicalDataItem(newBamFile.getIndex()); bamFileManager.create(newBamFile); } finally { if (newBamFile != null && newBamFile.getId() != null && bamFileManager.load(newBamFile.getId()) == null) { biologicalDataItemManager.deleteBiologicalDataItem(newBamFile.getId()); } } return newBamFile; }  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 BamFile registerBam(final IndexedFileRegistrationRequest request) throws IOException { Assert.notNull(request, getMessage(MessagesConstants.ERROR_NULL_PARAM)); Assert.notNull(request.getPath(), getMessage(MessagesConstants.ERROR_NULL_PARAM)); Assert.notNull(request.getReferenceId(), getMessage(NO_SUCH_REFERENCE)); Assert.notNull(request.getIndexPath(), getMessage(MessagesConstants.WRONG_BAM_INDEX_FILE)); if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } final BamFile newBamFile = bamHelper.fillBamFile(request); try { biologicalDataItemManager.createBiologicalDataItem(newBamFile); Reference reference = referenceGenomeManager.load(request.getReferenceId()); List<Chromosome> chromosomes = reference.getChromosomes(); LOGGER.debug(getMessage(MessagesConstants.DEBUG_FILE_READING, request.getPath())); bamHelper.parseBamFile(newBamFile, chromosomes, reference.getId()); biologicalDataItemManager.createBiologicalDataItem(newBamFile.getIndex()); bamFileManager.create(newBamFile); } finally { if (newBamFile != null && newBamFile.getId() != null && bamFileManager.load(newBamFile.getId()) == null) { biologicalDataItemManager.deleteBiologicalDataItem(newBamFile.getId()); } } return newBamFile; }  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);  }