@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void testLoadExtendedInfo() throws IOException, InterruptedException { VcfFile vcfFile = testSave("classpath:templates/extended_info.vcf"); VcfFile file = vcfFileManager.load(vcfFile.getId()); Assert.assertNotNull(file); VcfFilterInfo filterInfo = vcfManager.getFiltersInfo(Collections.singleton(vcfFile.getId())); Assert.assertEquals(NUMBER_OF_FILTERS, filterInfo.getAvailableFilters().size()); Assert.assertEquals(NUMBER_OF_TRIVIAL_INFO, filterInfo.getInfoItems().size() - 1); Assert.assertEquals(NUMBER_OF_TRIVIAL_INFO, filterInfo.getInfoItemMap().size() - 1); }
public VcfFilterInfo getFiltersInfo(Collection<Long> vcfFileIds) throws IOException { VcfFilterInfo filterInfo = new VcfFilterInfo(); Map<String, InfoItem> infoItems = new HashMap<>(); Set<String> availableFilters = new HashSet<>(); for (Long fileId : vcfFileIds) { VcfFile vcfFile = vcfFileManager.load(fileId); Assert.notNull(vcfFile, getMessage(ERROR_VCF_ID_INVALID, fileId)); try (FeatureReader<VariantContext> reader = AbstractEnhancedFeatureReader.getFeatureReader(vcfFile.getPath(), new VCFCodec(), false, indexCache)) { VCFHeader header = (VCFHeader) reader.getHeader(); Collection<VCFInfoHeaderLine> headerLines = header.getInfoHeaderLines(); infoItems.putAll(headerLines.stream() .filter(l -> !isExtendedInfoLine(l.getDescription())) .map(InfoItem::new) .collect(Collectors.toMap(InfoItem::getName, i -> i))); availableFilters.addAll(header.getFilterLines().stream().map(VCFSimpleHeaderLine::getID) .collect(Collectors.toList())); } } List<String> filtersWhiteList = getFilterWhiteList(); if (!filtersWhiteList.isEmpty()) { infoItems = scourFilterList(infoItems, filtersWhiteList); } infoItems.put(FeatureIndexDao.FeatureIndexFields.IS_EXON.getFieldName(), new InfoItem(FeatureIndexDao .FeatureIndexFields.IS_EXON.getFieldName(), VCFHeaderLineType.Flag, "Defines if a variation is " + "located in exon region")); filterInfo.setInfoItemMap(infoItems); filterInfo.setAvailableFilters(availableFilters); return filterInfo; }
VcfManager { public VcfFilterInfo getFiltersInfo(Collection<Long> vcfFileIds) throws IOException { VcfFilterInfo filterInfo = new VcfFilterInfo(); Map<String, InfoItem> infoItems = new HashMap<>(); Set<String> availableFilters = new HashSet<>(); for (Long fileId : vcfFileIds) { VcfFile vcfFile = vcfFileManager.load(fileId); Assert.notNull(vcfFile, getMessage(ERROR_VCF_ID_INVALID, fileId)); try (FeatureReader<VariantContext> reader = AbstractEnhancedFeatureReader.getFeatureReader(vcfFile.getPath(), new VCFCodec(), false, indexCache)) { VCFHeader header = (VCFHeader) reader.getHeader(); Collection<VCFInfoHeaderLine> headerLines = header.getInfoHeaderLines(); infoItems.putAll(headerLines.stream() .filter(l -> !isExtendedInfoLine(l.getDescription())) .map(InfoItem::new) .collect(Collectors.toMap(InfoItem::getName, i -> i))); availableFilters.addAll(header.getFilterLines().stream().map(VCFSimpleHeaderLine::getID) .collect(Collectors.toList())); } } List<String> filtersWhiteList = getFilterWhiteList(); if (!filtersWhiteList.isEmpty()) { infoItems = scourFilterList(infoItems, filtersWhiteList); } infoItems.put(FeatureIndexDao.FeatureIndexFields.IS_EXON.getFieldName(), new InfoItem(FeatureIndexDao .FeatureIndexFields.IS_EXON.getFieldName(), VCFHeaderLineType.Flag, "Defines if a variation is " + "located in exon region")); filterInfo.setInfoItemMap(infoItems); filterInfo.setAvailableFilters(availableFilters); return filterInfo; } }
VcfManager { public VcfFilterInfo getFiltersInfo(Collection<Long> vcfFileIds) throws IOException { VcfFilterInfo filterInfo = new VcfFilterInfo(); Map<String, InfoItem> infoItems = new HashMap<>(); Set<String> availableFilters = new HashSet<>(); for (Long fileId : vcfFileIds) { VcfFile vcfFile = vcfFileManager.load(fileId); Assert.notNull(vcfFile, getMessage(ERROR_VCF_ID_INVALID, fileId)); try (FeatureReader<VariantContext> reader = AbstractEnhancedFeatureReader.getFeatureReader(vcfFile.getPath(), new VCFCodec(), false, indexCache)) { VCFHeader header = (VCFHeader) reader.getHeader(); Collection<VCFInfoHeaderLine> headerLines = header.getInfoHeaderLines(); infoItems.putAll(headerLines.stream() .filter(l -> !isExtendedInfoLine(l.getDescription())) .map(InfoItem::new) .collect(Collectors.toMap(InfoItem::getName, i -> i))); availableFilters.addAll(header.getFilterLines().stream().map(VCFSimpleHeaderLine::getID) .collect(Collectors.toList())); } } List<String> filtersWhiteList = getFilterWhiteList(); if (!filtersWhiteList.isEmpty()) { infoItems = scourFilterList(infoItems, filtersWhiteList); } infoItems.put(FeatureIndexDao.FeatureIndexFields.IS_EXON.getFieldName(), new InfoItem(FeatureIndexDao .FeatureIndexFields.IS_EXON.getFieldName(), VCFHeaderLineType.Flag, "Defines if a variation is " + "located in exon region")); filterInfo.setInfoItemMap(infoItems); filterInfo.setAvailableFilters(availableFilters); return filterInfo; }  }
VcfManager { public VcfFilterInfo getFiltersInfo(Collection<Long> vcfFileIds) throws IOException { VcfFilterInfo filterInfo = new VcfFilterInfo(); Map<String, InfoItem> infoItems = new HashMap<>(); Set<String> availableFilters = new HashSet<>(); for (Long fileId : vcfFileIds) { VcfFile vcfFile = vcfFileManager.load(fileId); Assert.notNull(vcfFile, getMessage(ERROR_VCF_ID_INVALID, fileId)); try (FeatureReader<VariantContext> reader = AbstractEnhancedFeatureReader.getFeatureReader(vcfFile.getPath(), new VCFCodec(), false, indexCache)) { VCFHeader header = (VCFHeader) reader.getHeader(); Collection<VCFInfoHeaderLine> headerLines = header.getInfoHeaderLines(); infoItems.putAll(headerLines.stream() .filter(l -> !isExtendedInfoLine(l.getDescription())) .map(InfoItem::new) .collect(Collectors.toMap(InfoItem::getName, i -> i))); availableFilters.addAll(header.getFilterLines().stream().map(VCFSimpleHeaderLine::getID) .collect(Collectors.toList())); } } List<String> filtersWhiteList = getFilterWhiteList(); if (!filtersWhiteList.isEmpty()) { infoItems = scourFilterList(infoItems, filtersWhiteList); } infoItems.put(FeatureIndexDao.FeatureIndexFields.IS_EXON.getFieldName(), new InfoItem(FeatureIndexDao .FeatureIndexFields.IS_EXON.getFieldName(), VCFHeaderLineType.Flag, "Defines if a variation is " + "located in exon region")); filterInfo.setInfoItemMap(infoItems); filterInfo.setAvailableFilters(availableFilters); return filterInfo; }  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 VcfFilterInfo getFiltersInfo(Collection<Long> vcfFileIds) throws IOException { VcfFilterInfo filterInfo = new VcfFilterInfo(); Map<String, InfoItem> infoItems = new HashMap<>(); Set<String> availableFilters = new HashSet<>(); for (Long fileId : vcfFileIds) { VcfFile vcfFile = vcfFileManager.load(fileId); Assert.notNull(vcfFile, getMessage(ERROR_VCF_ID_INVALID, fileId)); try (FeatureReader<VariantContext> reader = AbstractEnhancedFeatureReader.getFeatureReader(vcfFile.getPath(), new VCFCodec(), false, indexCache)) { VCFHeader header = (VCFHeader) reader.getHeader(); Collection<VCFInfoHeaderLine> headerLines = header.getInfoHeaderLines(); infoItems.putAll(headerLines.stream() .filter(l -> !isExtendedInfoLine(l.getDescription())) .map(InfoItem::new) .collect(Collectors.toMap(InfoItem::getName, i -> i))); availableFilters.addAll(header.getFilterLines().stream().map(VCFSimpleHeaderLine::getID) .collect(Collectors.toList())); } } List<String> filtersWhiteList = getFilterWhiteList(); if (!filtersWhiteList.isEmpty()) { infoItems = scourFilterList(infoItems, filtersWhiteList); } infoItems.put(FeatureIndexDao.FeatureIndexFields.IS_EXON.getFieldName(), new InfoItem(FeatureIndexDao .FeatureIndexFields.IS_EXON.getFieldName(), VCFHeaderLineType.Flag, "Defines if a variation is " + "located in exon region")); filterInfo.setInfoItemMap(infoItems); filterInfo.setAvailableFilters(availableFilters); return filterInfo; }  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; }