@Test @Transactional(propagation = Propagation.REQUIRES_NEW) public void testWickedVcfIndex() throws IOException, InterruptedException, FeatureIndexException, NoSuchAlgorithmException, ParseException, VcfReadingException { Chromosome chr1 = EntityHelper.createNewChromosome("chr21"); chr1.setSize(TEST_WICKED_VCF_LENGTH); Chromosome chr2 = EntityHelper.createNewChromosome("chr22"); chr2.setSize(TEST_WICKED_VCF_LENGTH); Reference testHumanReference = EntityHelper.createNewReference(Arrays.asList(chr1, chr2), referenceGenomeManager.createReferenceId()); referenceGenomeManager.create(testHumanReference); Long humanReferenceId = testHumanReference.getId(); Project project = new Project(); project.setName(TEST_PROJECT_NAME + 1); project.setItems(singletonList(new ProjectItem( new BiologicalDataItem(testHumanReference.getBioDataItemId())))); projectManager.create(project); Resource resource = context.getResource("classpath:templates/Homo_sapiens.GRCh38.83.sorted.chr21-22.gtf"); FeatureIndexedFileRegistrationRequest geneRequest = new FeatureIndexedFileRegistrationRequest(); geneRequest.setPath(resource.getFile().getAbsolutePath()); geneRequest.setReferenceId(humanReferenceId); GeneFile geneFile = gffManager.registerGeneFile(geneRequest); referenceGenomeManager.updateReferenceGeneFileId(humanReferenceId, geneFile.getId()); resource = context.getResource("classpath:templates/Dream.set3.VarDict.SV.vcf"); FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest(); request.setReferenceId(humanReferenceId); request.setPath(resource.getFile().getAbsolutePath()); VcfFile vcfFile = vcfManager.registerVcfFile(request); Assert.assertNotNull(vcfFile); Assert.assertNotNull(vcfFile.getId()); project.setItems(Arrays.asList(new ProjectItem(geneFile), new ProjectItem(vcfFile))); projectManager.create(project); IndexSearchResult<VcfIndexEntry> entries = featureIndexManager.filterVariations(new VcfFilterForm(), project.getId()); Assert.assertFalse(entries.getEntries().isEmpty()); long varGenesCount = entries.getEntries().stream().filter(e -> StringUtils.isNotBlank(e.getGene())).count(); Assert.assertTrue(varGenesCount > 0); VcfFilterForm chr21Form = new VcfFilterForm(); chr21Form.setChromosomeIds(singletonList(chr1.getId())); IndexSearchResult<VcfIndexEntry> chr21Entries = featureIndexManager.filterVariations(chr21Form, project.getId()); Assert.assertFalse(chr21Entries.getEntries().isEmpty()); Assert.assertTrue(chr21Entries.getEntries().stream() .allMatch(e -> e.getChromosome().getId().equals(chr1.getId()))); VcfFilterForm chr22Form = new VcfFilterForm(); chr22Form.setChromosomeIds(singletonList(chr2.getId())); IndexSearchResult<VcfIndexEntry> chr22Entries = featureIndexManager.filterVariations(chr22Form, project.getId()); Assert.assertFalse(chr22Entries.getEntries().isEmpty()); Assert.assertTrue(chr22Entries.getEntries().stream() .allMatch(e -> e.getChromosome().getId().equals(chr2.getId()))); VcfFilterForm chr2122Form = new VcfFilterForm(); chr2122Form.setChromosomeIds(Arrays.asList(chr1.getId(), chr2.getId())); IndexSearchResult<VcfIndexEntry> chr2122Entries = featureIndexManager.filterVariations(chr2122Form, project.getId()); Assert.assertFalse(chr2122Entries.getEntries().isEmpty()); Assert.assertTrue(chr2122Entries.getEntries().stream() .anyMatch(e -> e.getChromosome().getId().equals(chr1.getId()))); Assert.assertTrue(chr2122Entries.getEntries().stream() .anyMatch(e -> e.getChromosome().getId().equals(chr2.getId()))); Assert.assertEquals(chr21Entries.getEntries().size() + chr22Entries.getEntries().size(), chr2122Entries .getEntries().size()); }
public IndexSearchResult<VcfIndexEntry> filterVariations(VcfFilterForm filterForm, long projectId) throws IOException { Project project = projectManager.load(projectId); List<VcfFile> files = project.getItems().stream() .filter(i -> i.getBioDataItem().getFormat() == BiologicalDataItemFormat.VCF) .map(i -> (VcfFile) i.getBioDataItem()) .collect(Collectors.toList()); return getVcfSearchResult(filterForm, files); }
FeatureIndexManager { public IndexSearchResult<VcfIndexEntry> filterVariations(VcfFilterForm filterForm, long projectId) throws IOException { Project project = projectManager.load(projectId); List<VcfFile> files = project.getItems().stream() .filter(i -> i.getBioDataItem().getFormat() == BiologicalDataItemFormat.VCF) .map(i -> (VcfFile) i.getBioDataItem()) .collect(Collectors.toList()); return getVcfSearchResult(filterForm, files); } }
FeatureIndexManager { public IndexSearchResult<VcfIndexEntry> filterVariations(VcfFilterForm filterForm, long projectId) throws IOException { Project project = projectManager.load(projectId); List<VcfFile> files = project.getItems().stream() .filter(i -> i.getBioDataItem().getFormat() == BiologicalDataItemFormat.VCF) .map(i -> (VcfFile) i.getBioDataItem()) .collect(Collectors.toList()); return getVcfSearchResult(filterForm, files); }  }
FeatureIndexManager { public IndexSearchResult<VcfIndexEntry> filterVariations(VcfFilterForm filterForm, long projectId) throws IOException { Project project = projectManager.load(projectId); List<VcfFile> files = project.getItems().stream() .filter(i -> i.getBioDataItem().getFormat() == BiologicalDataItemFormat.VCF) .map(i -> (VcfFile) i.getBioDataItem()) .collect(Collectors.toList()); return getVcfSearchResult(filterForm, files); }  void deleteFromIndexByFileId(final long projectId, List<Pair<FeatureType, Long>> fileIds); Set<String> searchGenesInVcfFilesInProject(long projectId, String gene, List<Long> vcfFileIds); Set<String> searchGenesInVcfFiles(String gene, List<Long> vcfFileIds); List<Chromosome> filterChromosomes(VcfFilterForm filterForm, long projectId); List<Chromosome> filterChromosomes(VcfFilterForm filterForm); IndexSearchResult<VcfIndexEntry> filterVariations(VcfFilterForm filterForm, long projectId); int getTotalPagesCount(VcfFilterForm filterForm); int getTotalPagesCount(VcfFilterForm filterForm, long projectId); List<Group> groupVariations(VcfFilterForm filterForm, long projectId, String groupByField); List<Group> groupVariations(VcfFilterForm filterForm, String groupByField); IndexSearchResult<VcfIndexEntry> filterVariations(VcfFilterForm filterForm); IndexSearchResult searchFeaturesInProject(String featureId, long projectId); IndexSearchResult searchFeaturesByReference(String featureId, long referenceId); VcfFilterInfo loadVcfFilterInfoForProject(long projectId); void buildIndexForFile(FeatureFile featureFile); Set<String> fetchGeneIds(int start, int end, List<GeneFile> geneFiles, Chromosome chromosome); void writeLuceneIndexForFile(final FeatureFile featureFile,
            final List<? extends FeatureIndexEntry> entries,
            VcfFilterInfo vcfFilterInfo); void makeIndexForBedReader(BedFile bedFile, AbstractFeatureReader<NggbBedFeature, LineIterator> reader,
                                      Map<String, Chromosome> chromosomeMap); void makeIndexForVcfReader(VcfFile vcfFile, FeatureReader<VariantContext> reader, List<GeneFile> geneFiles,
                                       Map<String, Chromosome> chromosomeMap, VcfFilterInfo info); void processGeneFile(GeneFile geneFile, final Map<String, Chromosome> chromosomeMap,
            boolean full); void addGeneFeatureToIndex(List<FeatureIndexEntry> allEntries, GeneFeature feature,
                                     Map<String, Chromosome> chromosomeMap); }
FeatureIndexManager { public IndexSearchResult<VcfIndexEntry> filterVariations(VcfFilterForm filterForm, long projectId) throws IOException { Project project = projectManager.load(projectId); List<VcfFile> files = project.getItems().stream() .filter(i -> i.getBioDataItem().getFormat() == BiologicalDataItemFormat.VCF) .map(i -> (VcfFile) i.getBioDataItem()) .collect(Collectors.toList()); return getVcfSearchResult(filterForm, files); }  void deleteFromIndexByFileId(final long projectId, List<Pair<FeatureType, Long>> fileIds); Set<String> searchGenesInVcfFilesInProject(long projectId, String gene, List<Long> vcfFileIds); Set<String> searchGenesInVcfFiles(String gene, List<Long> vcfFileIds); List<Chromosome> filterChromosomes(VcfFilterForm filterForm, long projectId); List<Chromosome> filterChromosomes(VcfFilterForm filterForm); IndexSearchResult<VcfIndexEntry> filterVariations(VcfFilterForm filterForm, long projectId); int getTotalPagesCount(VcfFilterForm filterForm); int getTotalPagesCount(VcfFilterForm filterForm, long projectId); List<Group> groupVariations(VcfFilterForm filterForm, long projectId, String groupByField); List<Group> groupVariations(VcfFilterForm filterForm, String groupByField); IndexSearchResult<VcfIndexEntry> filterVariations(VcfFilterForm filterForm); IndexSearchResult searchFeaturesInProject(String featureId, long projectId); IndexSearchResult searchFeaturesByReference(String featureId, long referenceId); VcfFilterInfo loadVcfFilterInfoForProject(long projectId); void buildIndexForFile(FeatureFile featureFile); Set<String> fetchGeneIds(int start, int end, List<GeneFile> geneFiles, Chromosome chromosome); void writeLuceneIndexForFile(final FeatureFile featureFile,
            final List<? extends FeatureIndexEntry> entries,
            VcfFilterInfo vcfFilterInfo); void makeIndexForBedReader(BedFile bedFile, AbstractFeatureReader<NggbBedFeature, LineIterator> reader,
                                      Map<String, Chromosome> chromosomeMap); void makeIndexForVcfReader(VcfFile vcfFile, FeatureReader<VariantContext> reader, List<GeneFile> geneFiles,
                                       Map<String, Chromosome> chromosomeMap, VcfFilterInfo info); void processGeneFile(GeneFile geneFile, final Map<String, Chromosome> chromosomeMap,
            boolean full); void addGeneFeatureToIndex(List<FeatureIndexEntry> allEntries, GeneFeature feature,
                                     Map<String, Chromosome> chromosomeMap);  }