@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void testLoadRead() throws IOException { 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.setType(BiologicalDataItemResourceType.FILE); BamFile bamFile = bamManager.registerBam(request); Assert.assertNotNull(bamFile); Track<Read> fullTrackQ = getBaseReadTrack(bamFile); BamQueryOption option = getBaseBamQueryOption(); ResponseEmitterMock emitterMock = new ResponseEmitterMock(); bamManager.sendBamTrackToEmitter(fullTrackQ, option, emitterMock); BamTrack<Read> fullTrack = emitterMock.getBamTrack(); Assert.assertTrue(!fullTrack.getBlocks().isEmpty()); Read read = fullTrack.getBlocks().get(0); ReadQuery query = new ReadQuery(); query.setName(read.getName()); query.setChromosomeId(testChromosome.getId()); query.setStartIndex(read.getStartIndex()); query.setEndIndex(read.getEndIndex()); query.setId(bamFile.getId()); Read loadedRead = bamManager.loadRead(query, null, null); Assert.assertNotNull(loadedRead); Assert.assertTrue(StringUtils.isNotBlank(loadedRead.getSequence())); Assert.assertTrue(!loadedRead.getTags().isEmpty()); Assert.assertTrue(StringUtils.isNotBlank(loadedRead.getQualities())); Assert.assertEquals(read.getName(), loadedRead.getName()); }
public Read loadRead(final ReadQuery query, String fileUrl, String indexUrl) throws IOException { Assert.notNull(query, MessagesConstants.ERROR_NULL_PARAM); Assert.isTrue(query.getId() != null || (StringUtils.isNotBlank(fileUrl) && StringUtils.isNotBlank(indexUrl)), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getChromosomeId(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getStartIndex(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getEndIndex(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getName(), MessagesConstants.ERROR_NULL_PARAM); final Chromosome chromosome = referenceGenomeManager.loadChromosome(query.getChromosomeId()); BamFile bamFile; if (query.getId() != null) { bamFile= bamFileManager.load(query.getId()); } else { bamFile = bamHelper.makeUrlBamFile(fileUrl, indexUrl, chromosome); } return getReadFromBamFile(query, chromosome, bamFile); }
BamManager { public Read loadRead(final ReadQuery query, String fileUrl, String indexUrl) throws IOException { Assert.notNull(query, MessagesConstants.ERROR_NULL_PARAM); Assert.isTrue(query.getId() != null || (StringUtils.isNotBlank(fileUrl) && StringUtils.isNotBlank(indexUrl)), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getChromosomeId(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getStartIndex(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getEndIndex(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getName(), MessagesConstants.ERROR_NULL_PARAM); final Chromosome chromosome = referenceGenomeManager.loadChromosome(query.getChromosomeId()); BamFile bamFile; if (query.getId() != null) { bamFile= bamFileManager.load(query.getId()); } else { bamFile = bamHelper.makeUrlBamFile(fileUrl, indexUrl, chromosome); } return getReadFromBamFile(query, chromosome, bamFile); } }
BamManager { public Read loadRead(final ReadQuery query, String fileUrl, String indexUrl) throws IOException { Assert.notNull(query, MessagesConstants.ERROR_NULL_PARAM); Assert.isTrue(query.getId() != null || (StringUtils.isNotBlank(fileUrl) && StringUtils.isNotBlank(indexUrl)), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getChromosomeId(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getStartIndex(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getEndIndex(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getName(), MessagesConstants.ERROR_NULL_PARAM); final Chromosome chromosome = referenceGenomeManager.loadChromosome(query.getChromosomeId()); BamFile bamFile; if (query.getId() != null) { bamFile= bamFileManager.load(query.getId()); } else { bamFile = bamHelper.makeUrlBamFile(fileUrl, indexUrl, chromosome); } return getReadFromBamFile(query, chromosome, bamFile); }  }
BamManager { public Read loadRead(final ReadQuery query, String fileUrl, String indexUrl) throws IOException { Assert.notNull(query, MessagesConstants.ERROR_NULL_PARAM); Assert.isTrue(query.getId() != null || (StringUtils.isNotBlank(fileUrl) && StringUtils.isNotBlank(indexUrl)), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getChromosomeId(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getStartIndex(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getEndIndex(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getName(), MessagesConstants.ERROR_NULL_PARAM); final Chromosome chromosome = referenceGenomeManager.loadChromosome(query.getChromosomeId()); BamFile bamFile; if (query.getId() != null) { bamFile= bamFileManager.load(query.getId()); } else { bamFile = bamHelper.makeUrlBamFile(fileUrl, indexUrl, chromosome); } return getReadFromBamFile(query, chromosome, bamFile); }  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 Read loadRead(final ReadQuery query, String fileUrl, String indexUrl) throws IOException { Assert.notNull(query, MessagesConstants.ERROR_NULL_PARAM); Assert.isTrue(query.getId() != null || (StringUtils.isNotBlank(fileUrl) && StringUtils.isNotBlank(indexUrl)), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getChromosomeId(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getStartIndex(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getEndIndex(), MessagesConstants.ERROR_NULL_PARAM); Assert.notNull(query.getName(), MessagesConstants.ERROR_NULL_PARAM); final Chromosome chromosome = referenceGenomeManager.loadChromosome(query.getChromosomeId()); BamFile bamFile; if (query.getId() != null) { bamFile= bamFileManager.load(query.getId()); } else { bamFile = bamHelper.makeUrlBamFile(fileUrl, indexUrl, chromosome); } return getReadFromBamFile(query, chromosome, bamFile); }  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);  }