public int checkExportedVCF(Path originalVcf, Path exportedVcf, Region region) throws IOException { return checkExportedVCF(originalVcf, null, exportedVcf, region, null); }
@BeforeClass public static void beforeClass() throws IOException { inputUri = new URI[VCF_TEST_FILE_NAMES.length]; etlResult = new StoragePipelineResult[VCF_TEST_FILE_NAMES.length]; for (int i = 0; i < VCF_TEST_FILE_NAMES.length; i++) { etlResult[i] = null; inputUri[i] = getResourceUri(VCF_TEST_FILE_NAMES[i]); } }
public Map<String, Variant> readVCF(Path vcfPath, Region region) throws IOException { return readVCF(vcfPath, null, region); }
@Test public void testVcfHtsExportSingleFile() throws Exception { Query query = new Query() .append(VariantQueryParam.STUDY.key(), STUDY_NAME) .append(VariantQueryParam.FILE.key(), 1); Path outputVcf = getTmpRootDir().resolve("hts_sf_" + EXPORTED_FILE_NAME); QueryOptions options = new QueryOptions(QueryOptions.SORT, true); int failedVariants = export(outputVcf, query, options); assertEquals(0, failedVariants); // compare VCF_TEST_FILE_NAME and EXPORTED_FILE_NAME checkExportedVCF(Paths.get(getResourceUri("1000g_batches/1-500.filtered.10k.chr22.phase3_shapeit2_mvncall_integrated_v5.20130502.genotypes.vcf" + ".gz")), outputVcf, new Region("22")); }
@Override @Before public void before() throws Exception { if (studyConfiguration == null) { clearDB(DB_NAME); studyConfiguration = newStudyConfiguration(); } for (int i = 0; i < VCF_TEST_FILE_NAMES.length; i++) { if (etlResult[i] == null) { etlResult[i] = runDefaultETL(inputUri[i], getVariantStorageEngine(), studyConfiguration, new ObjectMap(VariantStorageEngine.Options.ANNOTATE.key(), false) .append(VariantStorageEngine.Options.CALCULATE_STATS.key(), false)); } } dbAdaptor = getVariantStorageEngine().getDBAdaptor(); }
public Map<String, Variant> readVCF(Path vcfPath, Integer lim, Region region) throws IOException { if (lim == null) { lim = Integer.MAX_VALUE; } if (region == null) { region = new Region(); } VariantReader variantVcfReader = new VariantVcfHtsjdkReader(vcfPath, getMetadata(vcfPath), VARIANT_NORMALIZER); variantVcfReader.open(); variantVcfReader.pre(); Map<String, Variant> variantMap; variantMap = readVCF(vcfPath, lim, region, variantVcfReader); variantVcfReader.post(); variantVcfReader.close(); return variantMap; }
Map<String, Variant> originalVariants; if (originalVcfReader == null) { originalVariants = readVCF(originalVcf, lim, region); } else { originalVariants = readVCF(originalVcf, lim, region, originalVcfReader); Map<String, Variant> exportedVariants = readVCF(exportedVcf, region); assertEquals(message, originalVariant.getStart(), exportedVariant.getStart()); assertEquals(message, originalVariant.getEnd(), exportedVariant.getEnd()); assertWithConflicts(originalVariant, () -> assertEquals("At variant " + originalVariant, originalVariant.getIds(), exportedVariant.getIds())); assertEquals(message, originalVariant.getStudies().size(), exportedVariant.getStudies().size()); assertEquals(message, originalVariant.getSampleNames(STUDY_NAME), exportedVariant.getSampleNames(STUDY_NAME)); StudyEntry exportedStudyEntry = exportedVariant.getStudy(STUDY_NAME); for (String sampleName : originalStudyEntry.getSamplesName()) { assertWithConflicts(exportedVariant, () -> assertEquals("For sample '" + sampleName + "', id " + studyConfiguration.getSampleIds().get(sampleName) + ", in " + originalVariant,
@Test public void testVcfHtsExportMultiFile() throws Exception { Query query = new Query(); query.append(VariantQueryParam.STUDY.key(), STUDY_NAME); // .append(VariantDBAdaptor.VariantQueryParams.REGION.key(), region); Path outputVcf = getTmpRootDir().resolve("hts_mf_" + EXPORTED_FILE_NAME); int failedVariants = export(outputVcf, query, new QueryOptions(QueryOptions.SORT, true)); assertEquals(0, failedVariants); // compare VCF_TEST_FILE_NAME and EXPORTED_FILE_NAME Path originalVcf = Paths.get(getResourceUri("filtered.10k.chr22.phase3_shapeit2_mvncall_integrated_v5.20130502.genotypes.vcf.gz")); VariantReader variantReader = new VariantVcfHtsjdkReader( originalVcf, getMetadata(originalVcf), VARIANT_NORMALIZER); variantReader.open(); variantReader.pre(); Region region = new Region("22", 16000000); int batchSize = 2000; while (checkExportedVCF(originalVcf, variantReader, outputVcf, region, batchSize) != batchSize) { region = new Region("22", region.getEnd()); } variantReader.post(); variantReader.close(); }