@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void testRegisterWithGeneFile() throws IOException { Resource resource = context.getResource(A3_FA_PATH); ReferenceRegistrationRequest request = new ReferenceRegistrationRequest(); request.setName("testReference1 " + this.getClass().getSimpleName()); request.setPath(resource.getFile().getPath()); request.setType(BiologicalDataItemResourceType.FILE); FeatureIndexedFileRegistrationRequest geneRequest = new FeatureIndexedFileRegistrationRequest(); resource = context.getResource("classpath:templates/genes_sorted.gtf"); geneRequest.setPath(resource.getFile().getAbsolutePath()); request.setGeneFileRequest(geneRequest); Reference testRef = referenceManager.registerGenome(request); assertNotNull(testRef); assertNotNull(testRef.getGeneFile()); Reference loadedReference = referenceGenomeManager.load(testRef.getId()); assertNotNull(loadedReference); assertNotNull(loadedReference.getGeneFile()); assertNotNull(loadedReference.getGeneFile().getId()); assertNotNull(loadedReference.getGeneFile().getPath()); assertNotNull(loadedReference.getGeneFile().getIndex()); loadedReference = referenceGenomeManager.updateReferenceGeneFileId(testRef.getId(), null); assertNull(loadedReference.getGeneFile()); loadedReference = referenceGenomeManager .updateReferenceGeneFileId(testRef.getId(), testRef.getGeneFile().getId()); assertNotNull(loadedReference.getGeneFile()); resource = context.getResource(A3_FA_PATH); request = new ReferenceRegistrationRequest(); request.setName("testReference2 " + this.getClass().getSimpleName()); request.setPath(resource.getFile().getPath()); request.setType(BiologicalDataItemResourceType.FILE); request.setGeneFileId(testRef.getGeneFile().getId()); Reference testRef2 = referenceManager.registerGenome(request); loadedReference = referenceGenomeManager.load(testRef2.getId()); assertNotNull(loadedReference); assertNotNull(loadedReference.getGeneFile()); assertNotNull(loadedReference.getGeneFile().getId()); assertNotNull(loadedReference.getGeneFile().getPath()); assertNotNull(loadedReference.getGeneFile().getIndex()); assertEquals(testRef.getGeneFile().getId(), loadedReference.getGeneFile().getId()); }
@Transactional(propagation = Propagation.REQUIRED) public Reference registerGenome(final ReferenceRegistrationRequest request) throws IOException { final String name; if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } if (request.getType() == BiologicalDataItemResourceType.GA4GH) { name = request.getName(); } else { name = parse(request.getPath(), request.getName()); } final Long referenceId = referenceGenomeManager.createReferenceId(); final Reference reference = new Reference(referenceId, name); reference.setPath(request.getPath()); reference.setPrettyName(request.getPrettyName()); if (!request.isNoGCContent()) { fileManager.makeReferenceDir(reference); } reference.setType(request.getType()); boolean succeeded = false; try { if (reference.getCreatedDate() == null) { reference.setCreatedDate(new Date()); } if (reference.getType() == null) { reference.setType(BiologicalDataItemResourceType.FILE); } biologicalDataItemManager.createBiologicalDataItem(reference); reference.setBioDataItemId(reference.getId()); reference.setId(referenceId); long lengthOfGenome; if (request.getType() == BiologicalDataItemResourceType.GA4GH) { lengthOfGenome = registerGA4GH(request, referenceId, reference); } else { lengthOfGenome = registerReference(referenceId, reference, !request.isNoGCContent()); } reference.setSize(lengthOfGenome); if (request.getGeneFileId() != null) { Assert.isTrue(request.getGeneFileRequest() == null, getMessage(MessagesConstants.ERROR_REFERENCE_REGISTRATION_PARAMS)); GeneFile geneFile = geneFileManager.load(request.getGeneFileId()); reference.setGeneFile(geneFile); } if (request.getSpecies() != null) { String version = request.getSpecies().getVersion(); Species species = referenceGenomeManager.loadSpeciesByVersion(version); Assert.notNull(species, getMessage(MessageCode.NO_SUCH_SPECIES, version)); reference.setSpecies(species); } referenceGenomeManager.create(reference); processGeneRegistrationRequest(request, reference); succeeded = true; } catch (InterruptedException | ExternalDbUnavailableException e) { LOG.info(String.format("Failed to register reference %s.", request.getName()), e); } finally { if (!succeeded) { fileManager.deleteReferenceDir(reference); if (reference.getBioDataItemId() != null && !referenceGenomeManager .isRegistered(reference.getId())) { biologicalDataItemManager .deleteBiologicalDataItem(reference.getBioDataItemId()); } } } return reference; }
ReferenceManager { @Transactional(propagation = Propagation.REQUIRED) public Reference registerGenome(final ReferenceRegistrationRequest request) throws IOException { final String name; if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } if (request.getType() == BiologicalDataItemResourceType.GA4GH) { name = request.getName(); } else { name = parse(request.getPath(), request.getName()); } final Long referenceId = referenceGenomeManager.createReferenceId(); final Reference reference = new Reference(referenceId, name); reference.setPath(request.getPath()); reference.setPrettyName(request.getPrettyName()); if (!request.isNoGCContent()) { fileManager.makeReferenceDir(reference); } reference.setType(request.getType()); boolean succeeded = false; try { if (reference.getCreatedDate() == null) { reference.setCreatedDate(new Date()); } if (reference.getType() == null) { reference.setType(BiologicalDataItemResourceType.FILE); } biologicalDataItemManager.createBiologicalDataItem(reference); reference.setBioDataItemId(reference.getId()); reference.setId(referenceId); long lengthOfGenome; if (request.getType() == BiologicalDataItemResourceType.GA4GH) { lengthOfGenome = registerGA4GH(request, referenceId, reference); } else { lengthOfGenome = registerReference(referenceId, reference, !request.isNoGCContent()); } reference.setSize(lengthOfGenome); if (request.getGeneFileId() != null) { Assert.isTrue(request.getGeneFileRequest() == null, getMessage(MessagesConstants.ERROR_REFERENCE_REGISTRATION_PARAMS)); GeneFile geneFile = geneFileManager.load(request.getGeneFileId()); reference.setGeneFile(geneFile); } if (request.getSpecies() != null) { String version = request.getSpecies().getVersion(); Species species = referenceGenomeManager.loadSpeciesByVersion(version); Assert.notNull(species, getMessage(MessageCode.NO_SUCH_SPECIES, version)); reference.setSpecies(species); } referenceGenomeManager.create(reference); processGeneRegistrationRequest(request, reference); succeeded = true; } catch (InterruptedException | ExternalDbUnavailableException e) { LOG.info(String.format("Failed to register reference %s.", request.getName()), e); } finally { if (!succeeded) { fileManager.deleteReferenceDir(reference); if (reference.getBioDataItemId() != null && !referenceGenomeManager .isRegistered(reference.getId())) { biologicalDataItemManager .deleteBiologicalDataItem(reference.getBioDataItemId()); } } } return reference; } }
ReferenceManager { @Transactional(propagation = Propagation.REQUIRED) public Reference registerGenome(final ReferenceRegistrationRequest request) throws IOException { final String name; if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } if (request.getType() == BiologicalDataItemResourceType.GA4GH) { name = request.getName(); } else { name = parse(request.getPath(), request.getName()); } final Long referenceId = referenceGenomeManager.createReferenceId(); final Reference reference = new Reference(referenceId, name); reference.setPath(request.getPath()); reference.setPrettyName(request.getPrettyName()); if (!request.isNoGCContent()) { fileManager.makeReferenceDir(reference); } reference.setType(request.getType()); boolean succeeded = false; try { if (reference.getCreatedDate() == null) { reference.setCreatedDate(new Date()); } if (reference.getType() == null) { reference.setType(BiologicalDataItemResourceType.FILE); } biologicalDataItemManager.createBiologicalDataItem(reference); reference.setBioDataItemId(reference.getId()); reference.setId(referenceId); long lengthOfGenome; if (request.getType() == BiologicalDataItemResourceType.GA4GH) { lengthOfGenome = registerGA4GH(request, referenceId, reference); } else { lengthOfGenome = registerReference(referenceId, reference, !request.isNoGCContent()); } reference.setSize(lengthOfGenome); if (request.getGeneFileId() != null) { Assert.isTrue(request.getGeneFileRequest() == null, getMessage(MessagesConstants.ERROR_REFERENCE_REGISTRATION_PARAMS)); GeneFile geneFile = geneFileManager.load(request.getGeneFileId()); reference.setGeneFile(geneFile); } if (request.getSpecies() != null) { String version = request.getSpecies().getVersion(); Species species = referenceGenomeManager.loadSpeciesByVersion(version); Assert.notNull(species, getMessage(MessageCode.NO_SUCH_SPECIES, version)); reference.setSpecies(species); } referenceGenomeManager.create(reference); processGeneRegistrationRequest(request, reference); succeeded = true; } catch (InterruptedException | ExternalDbUnavailableException e) { LOG.info(String.format("Failed to register reference %s.", request.getName()), e); } finally { if (!succeeded) { fileManager.deleteReferenceDir(reference); if (reference.getBioDataItemId() != null && !referenceGenomeManager .isRegistered(reference.getId())) { biologicalDataItemManager .deleteBiologicalDataItem(reference.getBioDataItemId()); } } } return reference; }  }
ReferenceManager { @Transactional(propagation = Propagation.REQUIRED) public Reference registerGenome(final ReferenceRegistrationRequest request) throws IOException { final String name; if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } if (request.getType() == BiologicalDataItemResourceType.GA4GH) { name = request.getName(); } else { name = parse(request.getPath(), request.getName()); } final Long referenceId = referenceGenomeManager.createReferenceId(); final Reference reference = new Reference(referenceId, name); reference.setPath(request.getPath()); reference.setPrettyName(request.getPrettyName()); if (!request.isNoGCContent()) { fileManager.makeReferenceDir(reference); } reference.setType(request.getType()); boolean succeeded = false; try { if (reference.getCreatedDate() == null) { reference.setCreatedDate(new Date()); } if (reference.getType() == null) { reference.setType(BiologicalDataItemResourceType.FILE); } biologicalDataItemManager.createBiologicalDataItem(reference); reference.setBioDataItemId(reference.getId()); reference.setId(referenceId); long lengthOfGenome; if (request.getType() == BiologicalDataItemResourceType.GA4GH) { lengthOfGenome = registerGA4GH(request, referenceId, reference); } else { lengthOfGenome = registerReference(referenceId, reference, !request.isNoGCContent()); } reference.setSize(lengthOfGenome); if (request.getGeneFileId() != null) { Assert.isTrue(request.getGeneFileRequest() == null, getMessage(MessagesConstants.ERROR_REFERENCE_REGISTRATION_PARAMS)); GeneFile geneFile = geneFileManager.load(request.getGeneFileId()); reference.setGeneFile(geneFile); } if (request.getSpecies() != null) { String version = request.getSpecies().getVersion(); Species species = referenceGenomeManager.loadSpeciesByVersion(version); Assert.notNull(species, getMessage(MessageCode.NO_SUCH_SPECIES, version)); reference.setSpecies(species); } referenceGenomeManager.create(reference); processGeneRegistrationRequest(request, reference); succeeded = true; } catch (InterruptedException | ExternalDbUnavailableException e) { LOG.info(String.format("Failed to register reference %s.", request.getName()), e); } finally { if (!succeeded) { fileManager.deleteReferenceDir(reference); if (reference.getBioDataItemId() != null && !referenceGenomeManager .isRegistered(reference.getId())) { biologicalDataItemManager .deleteBiologicalDataItem(reference.getBioDataItemId()); } } } return reference; }  Track<Sequence> getNucleotidesResultFromNib(Track<Sequence> track); @Transactional(propagation = Propagation.REQUIRED) Reference registerGenome(final ReferenceRegistrationRequest request); List<Sequence> getNucleotidesFromNibFile(int startPosition, final int endPosition,
            final long referenceId, final String chromosomeName); @Transactional(propagation = Propagation.REQUIRED) Reference unregisterGenome(final long referenceId); String getSequenceString(final int startIndex, final int endIndex,
            final Long referenceId, final String chromosomeName); byte[] getSequenceByteArray(final int startIndex, final int endIndex,
            final Long referenceId, final String chromosomeName); }
ReferenceManager { @Transactional(propagation = Propagation.REQUIRED) public Reference registerGenome(final ReferenceRegistrationRequest request) throws IOException { final String name; if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } if (request.getType() == BiologicalDataItemResourceType.GA4GH) { name = request.getName(); } else { name = parse(request.getPath(), request.getName()); } final Long referenceId = referenceGenomeManager.createReferenceId(); final Reference reference = new Reference(referenceId, name); reference.setPath(request.getPath()); reference.setPrettyName(request.getPrettyName()); if (!request.isNoGCContent()) { fileManager.makeReferenceDir(reference); } reference.setType(request.getType()); boolean succeeded = false; try { if (reference.getCreatedDate() == null) { reference.setCreatedDate(new Date()); } if (reference.getType() == null) { reference.setType(BiologicalDataItemResourceType.FILE); } biologicalDataItemManager.createBiologicalDataItem(reference); reference.setBioDataItemId(reference.getId()); reference.setId(referenceId); long lengthOfGenome; if (request.getType() == BiologicalDataItemResourceType.GA4GH) { lengthOfGenome = registerGA4GH(request, referenceId, reference); } else { lengthOfGenome = registerReference(referenceId, reference, !request.isNoGCContent()); } reference.setSize(lengthOfGenome); if (request.getGeneFileId() != null) { Assert.isTrue(request.getGeneFileRequest() == null, getMessage(MessagesConstants.ERROR_REFERENCE_REGISTRATION_PARAMS)); GeneFile geneFile = geneFileManager.load(request.getGeneFileId()); reference.setGeneFile(geneFile); } if (request.getSpecies() != null) { String version = request.getSpecies().getVersion(); Species species = referenceGenomeManager.loadSpeciesByVersion(version); Assert.notNull(species, getMessage(MessageCode.NO_SUCH_SPECIES, version)); reference.setSpecies(species); } referenceGenomeManager.create(reference); processGeneRegistrationRequest(request, reference); succeeded = true; } catch (InterruptedException | ExternalDbUnavailableException e) { LOG.info(String.format("Failed to register reference %s.", request.getName()), e); } finally { if (!succeeded) { fileManager.deleteReferenceDir(reference); if (reference.getBioDataItemId() != null && !referenceGenomeManager .isRegistered(reference.getId())) { biologicalDataItemManager .deleteBiologicalDataItem(reference.getBioDataItemId()); } } } return reference; }  Track<Sequence> getNucleotidesResultFromNib(Track<Sequence> track); @Transactional(propagation = Propagation.REQUIRED) Reference registerGenome(final ReferenceRegistrationRequest request); List<Sequence> getNucleotidesFromNibFile(int startPosition, final int endPosition,
            final long referenceId, final String chromosomeName); @Transactional(propagation = Propagation.REQUIRED) Reference unregisterGenome(final long referenceId); String getSequenceString(final int startIndex, final int endIndex,
            final Long referenceId, final String chromosomeName); byte[] getSequenceByteArray(final int startIndex, final int endIndex,
            final Long referenceId, final String chromosomeName);  }