@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void testRegisterGA4GH() throws IOException, ClassNotFoundException, InterruptedException, ParseException, NoSuchAlgorithmException, ExternalDbUnavailableException, VcfReadingException { String fetchRes1 = readFile("GA4GH_id10473.json"); String fetchRes2 = readFile("GA4GH_id10473_variant.json"); Mockito.when( httpDataManager.fetchData(Mockito.any(), Mockito.any(JSONObject.class))) .thenReturn(fetchRes1) .thenReturn(fetchRes2); String fetchRes5 = readFile("GA4GH_id10473_param.json"); Mockito.when( httpDataManager.fetchData(Mockito.any(), Mockito.any(ParameterNameValue[].class))) .thenReturn(fetchRes5); FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest(); VcfFile vcfFileGA4GH = regesterVcfGA4GH(); vcfFileGA4GH.setType(BiologicalDataItemResourceType.GA4GH); List<VcfSample> vcfSamples = vcfFileGA4GH.getSamples(); Long sampleId = 0L; for (VcfSample sample : vcfSamples) { if (sample.getName().equals(SAMPLE_NAME)) { sampleId = sample.getId(); } } Track<Variation> trackResultGA4GH = testLoadGA4GH(vcfFileGA4GH, 1D, true, sampleId); VariationQuery query = new VariationQuery(); query.setChromosomeId(testChrGA4GH.getId()); query.setId(vcfFileGA4GH.getId()); Assert.assertNotNull(vcfFileGA4GH); Assert.assertNotNull(vcfFileGA4GH.getId()); Assert.assertFalse(trackResultGA4GH.getBlocks().isEmpty()); Resource resource = context.getResource(CLASSPATH_TEMPLATES_FELIS_CATUS_VCF_GOOGLE); request.setReferenceId(referenceIdGA4GH); request.setPath(resource.getFile().getAbsolutePath()); request.setType(BiologicalDataItemResourceType.FILE); VcfFile vcfFileFile = vcfManager.registerVcfFile(request); Assert.assertNotNull(vcfFileFile); Assert.assertNotNull(vcfFileFile.getId()); vcfSamples = vcfFileFile.getSamples(); for (VcfSample sample : vcfSamples) { if (sample.getName().equals(SAMPLE_NAME)) { sampleId = sample.getId(); } } Track<Variation> trackResultFile = testLoadGA4GH(vcfFileFile, 1D, true, sampleId); Assert.assertFalse(trackResultFile.getBlocks().isEmpty()); Variation varGA4GH = trackResultGA4GH.getBlocks().get(0); Variation varFILE = trackResultFile.getBlocks().get(0); Assert.assertEquals(varGA4GH.getInfo().get("AC").getValue(), varFILE.getInfo().get("AC").getValue()); Assert.assertEquals(varGA4GH.getGenotypeData().getGenotype().length, varFILE.getGenotypeData().getGenotype() .length); Assert.assertEquals(varGA4GH.getGenotypeData().getOrganismType(), varFILE.getGenotypeData().getOrganismType()); Assert.assertEquals(varGA4GH.getGenotypeData().getGenotypeString(), varFILE.getGenotypeData() .getGenotypeString()); Assert.assertEquals(varGA4GH.getType(), varFILE.getType()); Assert.assertEquals(varGA4GH.getStartIndex(), varFILE.getStartIndex()); Assert.assertEquals(varGA4GH.getReferenceAllele(), varFILE.getReferenceAllele()); Assert.assertEquals(varGA4GH.getGeneNames(), varFILE.getGeneNames()); }
public VcfFile registerVcfFile(FeatureIndexedFileRegistrationRequest request) { final String requestPath = request.getPath(); Assert.isTrue(StringUtils.isNotBlank(requestPath), getMessage( MessagesConstants.ERROR_NULL_PARAM, "path")); Assert.notNull(request.getReferenceId(), getMessage(MessagesConstants.ERROR_NULL_PARAM, "referenceId")); VcfFile vcfFile; Reference reference = referenceGenomeManager.load(request.getReferenceId()); Map<String, Chromosome> chromosomeMap = reference.getChromosomes().stream().collect( Collectors.toMap(BaseEntity::getName, chromosome -> chromosome)); if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } switch (request.getType()) { case GA4GH: vcfFile = getVcfFileFromGA4GH(request, requestPath); break; case FILE: case S3: vcfFile = createVcfFromFile(request, chromosomeMap, reference, request.isDoIndex()); break; case DOWNLOAD: vcfFile = downloadVcfFile(request, requestPath, chromosomeMap, reference, request.isDoIndex()); break; case URL: vcfFile = createVcfFromUrl(request, chromosomeMap, reference); break; default: throw new IllegalArgumentException( getMessage(MessagesConstants.ERROR_INVALID_PARAM)); } return vcfFile; }
VcfManager { public VcfFile registerVcfFile(FeatureIndexedFileRegistrationRequest request) { final String requestPath = request.getPath(); Assert.isTrue(StringUtils.isNotBlank(requestPath), getMessage( MessagesConstants.ERROR_NULL_PARAM, "path")); Assert.notNull(request.getReferenceId(), getMessage(MessagesConstants.ERROR_NULL_PARAM, "referenceId")); VcfFile vcfFile; Reference reference = referenceGenomeManager.load(request.getReferenceId()); Map<String, Chromosome> chromosomeMap = reference.getChromosomes().stream().collect( Collectors.toMap(BaseEntity::getName, chromosome -> chromosome)); if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } switch (request.getType()) { case GA4GH: vcfFile = getVcfFileFromGA4GH(request, requestPath); break; case FILE: case S3: vcfFile = createVcfFromFile(request, chromosomeMap, reference, request.isDoIndex()); break; case DOWNLOAD: vcfFile = downloadVcfFile(request, requestPath, chromosomeMap, reference, request.isDoIndex()); break; case URL: vcfFile = createVcfFromUrl(request, chromosomeMap, reference); break; default: throw new IllegalArgumentException( getMessage(MessagesConstants.ERROR_INVALID_PARAM)); } return vcfFile; } }
VcfManager { public VcfFile registerVcfFile(FeatureIndexedFileRegistrationRequest request) { final String requestPath = request.getPath(); Assert.isTrue(StringUtils.isNotBlank(requestPath), getMessage( MessagesConstants.ERROR_NULL_PARAM, "path")); Assert.notNull(request.getReferenceId(), getMessage(MessagesConstants.ERROR_NULL_PARAM, "referenceId")); VcfFile vcfFile; Reference reference = referenceGenomeManager.load(request.getReferenceId()); Map<String, Chromosome> chromosomeMap = reference.getChromosomes().stream().collect( Collectors.toMap(BaseEntity::getName, chromosome -> chromosome)); if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } switch (request.getType()) { case GA4GH: vcfFile = getVcfFileFromGA4GH(request, requestPath); break; case FILE: case S3: vcfFile = createVcfFromFile(request, chromosomeMap, reference, request.isDoIndex()); break; case DOWNLOAD: vcfFile = downloadVcfFile(request, requestPath, chromosomeMap, reference, request.isDoIndex()); break; case URL: vcfFile = createVcfFromUrl(request, chromosomeMap, reference); break; default: throw new IllegalArgumentException( getMessage(MessagesConstants.ERROR_INVALID_PARAM)); } return vcfFile; }  }
VcfManager { public VcfFile registerVcfFile(FeatureIndexedFileRegistrationRequest request) { final String requestPath = request.getPath(); Assert.isTrue(StringUtils.isNotBlank(requestPath), getMessage( MessagesConstants.ERROR_NULL_PARAM, "path")); Assert.notNull(request.getReferenceId(), getMessage(MessagesConstants.ERROR_NULL_PARAM, "referenceId")); VcfFile vcfFile; Reference reference = referenceGenomeManager.load(request.getReferenceId()); Map<String, Chromosome> chromosomeMap = reference.getChromosomes().stream().collect( Collectors.toMap(BaseEntity::getName, chromosome -> chromosome)); if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } switch (request.getType()) { case GA4GH: vcfFile = getVcfFileFromGA4GH(request, requestPath); break; case FILE: case S3: vcfFile = createVcfFromFile(request, chromosomeMap, reference, request.isDoIndex()); break; case DOWNLOAD: vcfFile = downloadVcfFile(request, requestPath, chromosomeMap, reference, request.isDoIndex()); break; case URL: vcfFile = createVcfFromUrl(request, chromosomeMap, reference); break; default: throw new IllegalArgumentException( getMessage(MessagesConstants.ERROR_INVALID_PARAM)); } return vcfFile; }  VcfFile registerVcfFile(FeatureIndexedFileRegistrationRequest request); @Transactional(propagation = Propagation.REQUIRED) VcfFile unregisterVcfFile(final Long vcfFileId); Track<Variation> loadVariations(final Track<Variation> track, final Long sampleId, boolean loadInfo,
                                           final boolean collapse); Track<Variation> loadVariations(final Track<Variation> track, String fileUrl, String indexUrl,
                                           final Integer sampleIndex, final boolean loadInfo, final boolean collapse); Variation loadVariation(final VariationQuery query); Variation loadVariation(final VariationQuery query, String fileUrl, String indexUrl); Variation getNextOrPreviousVariation(final int fromPosition, final Long vcfFileId, final Long sampleId,
                                                final long chromosomeId, final boolean forward, String fileUrl,
                                                String indexUrl); VcfFilterInfo getFiltersInfo(Collection<Long> vcfFileIds); VcfFile reindexVcfFile(long vcfFileId, Boolean rewriteTabixIndex); InfoFieldParser getExtendedInfoParser(); void setIndexBufferSize(int indexBufferSize); }
VcfManager { public VcfFile registerVcfFile(FeatureIndexedFileRegistrationRequest request) { final String requestPath = request.getPath(); Assert.isTrue(StringUtils.isNotBlank(requestPath), getMessage( MessagesConstants.ERROR_NULL_PARAM, "path")); Assert.notNull(request.getReferenceId(), getMessage(MessagesConstants.ERROR_NULL_PARAM, "referenceId")); VcfFile vcfFile; Reference reference = referenceGenomeManager.load(request.getReferenceId()); Map<String, Chromosome> chromosomeMap = reference.getChromosomes().stream().collect( Collectors.toMap(BaseEntity::getName, chromosome -> chromosome)); if (request.getType() == null) { request.setType(BiologicalDataItemResourceType.FILE); } switch (request.getType()) { case GA4GH: vcfFile = getVcfFileFromGA4GH(request, requestPath); break; case FILE: case S3: vcfFile = createVcfFromFile(request, chromosomeMap, reference, request.isDoIndex()); break; case DOWNLOAD: vcfFile = downloadVcfFile(request, requestPath, chromosomeMap, reference, request.isDoIndex()); break; case URL: vcfFile = createVcfFromUrl(request, chromosomeMap, reference); break; default: throw new IllegalArgumentException( getMessage(MessagesConstants.ERROR_INVALID_PARAM)); } return vcfFile; }  VcfFile registerVcfFile(FeatureIndexedFileRegistrationRequest request); @Transactional(propagation = Propagation.REQUIRED) VcfFile unregisterVcfFile(final Long vcfFileId); Track<Variation> loadVariations(final Track<Variation> track, final Long sampleId, boolean loadInfo,
                                           final boolean collapse); Track<Variation> loadVariations(final Track<Variation> track, String fileUrl, String indexUrl,
                                           final Integer sampleIndex, final boolean loadInfo, final boolean collapse); Variation loadVariation(final VariationQuery query); Variation loadVariation(final VariationQuery query, String fileUrl, String indexUrl); Variation getNextOrPreviousVariation(final int fromPosition, final Long vcfFileId, final Long sampleId,
                                                final long chromosomeId, final boolean forward, String fileUrl,
                                                String indexUrl); VcfFilterInfo getFiltersInfo(Collection<Long> vcfFileIds); VcfFile reindexVcfFile(long vcfFileId, Boolean rewriteTabixIndex); InfoFieldParser getExtendedInfoParser(); void setIndexBufferSize(int indexBufferSize); static final double HTSJDK_WRONG_QUALITY; }