@Test @Transactional(propagation = Propagation.REQUIRES_NEW) public void testSortByMultipleFields() throws IOException { IndexSearchResult<VcfIndexEntry> referentList = featureIndexManager.filterVariations(new VcfFilterForm(), testProject.getId()); List<VcfIndexEntry> pagedEntries = new ArrayList<>(); VcfFilterForm filterForm = new VcfFilterForm(); filterForm.setPageSize(10); filterForm.setOrderBy(Arrays.asList(new VcfFilterForm.OrderBy(IndexSortField.START_INDEX.name(), false), new VcfFilterForm.OrderBy(IndexSortField.VARIATION_TYPE.name(), false))); for (int i = 1; i < (referentList.getEntries().size() / 10) + 2; i++) { filterForm.setPage(i); IndexSearchResult<VcfIndexEntry> pageRes = featureIndexManager.filterVariations(filterForm, testProject.getId()); List<VcfIndexEntry> page = pageRes.getEntries(); Assert.assertFalse(page.isEmpty()); if (i < (referentList.getEntries().size() / 10) + 1) { Assert.assertEquals(page.size(), 10); } else { Assert.assertEquals(page.size(), 4); } List<VcfIndexEntry> duplicates = page.stream().filter(pagedEntries::contains).collect(Collectors.toList()); Assert.assertTrue(duplicates.isEmpty()); Assert.assertFalse(page.stream().anyMatch(p -> pagedEntries.stream().anyMatch( e -> e.getStartIndex() > p.getStartIndex()))); Assert.assertFalse(page.stream().anyMatch( p -> pagedEntries.stream().anyMatch(e -> e.getVariationType().name().compareTo( p.getVariationType().name()) > 0))); pagedEntries.addAll(page); } }
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);  }