public static List<String> filter(List<String> gts, List<String> loadedGts) { return filter(gts, loadedGts, Arrays.asList("0/0", "./.")); }
private boolean isValidGenotype(Set<String> genotypesSet, List<GenotypeClass> genotypeClasses, String gt) { return genotypesSet.contains(gt) || !genotypeClasses.isEmpty() && genotypeClasses.stream().anyMatch(gc -> gc.test(gt)); }
public static List<String> filter(List<String> gts, List<String> loadedGts, List<String> defaultGts) { Set<String> filteredGts = new HashSet<>(gts.size()); for (String gt : gts) { GenotypeClass genotypeClass = GenotypeClass.from(gt); if (genotypeClass == null) { filteredGts.add(gt); } else { filteredGts.addAll(genotypeClass.filter(loadedGts)); filteredGts.addAll(genotypeClass.filter(defaultGts)); } } return new ArrayList<>(filteredGts); }
@Test public void testGetSamplesInAllVariantsGenotypeClass() throws Exception { Collection<String> samplesInAllVariants = filter.getSamplesInAllVariants(Arrays.asList("1:100:A:C", "1:102:A:C"), STUDY, SAMPLES, Arrays.asList(GenotypeClass.HET.toString(), GenotypeClass.HOM_ALT.toString())); assertEquals(Arrays.asList(S3), new ArrayList<>(samplesInAllVariants)); }
private List<GenotypeClass> getGenotypeClasses(Set<String> genotypesSet) { List<GenotypeClass> genotypeClasses = new ArrayList<>(); Iterator<String> iterator = genotypesSet.iterator(); while (iterator.hasNext()) { String genotype = iterator.next(); GenotypeClass genotypeClass = GenotypeClass.from(genotype); if (genotypeClass != null) { genotypeClasses.add(genotypeClass); iterator.remove(); } } return genotypeClasses; } }
@Test public void testGetSamplesInAllVariantsGenotypeClassMix() throws Exception { Collection<String> samplesInAllVariants = filter.getSamplesInAllVariants(Arrays.asList("1:100:A:C", "1:102:A:C"), STUDY, SAMPLES, Arrays.asList(GenotypeClass.HET.toString(), "1/1")); assertEquals(Arrays.asList(S3), new ArrayList<>(samplesInAllVariants)); }
public List<String> filter(String... gts) { return filter(Arrays.asList(gts)); }
@Test public void testMultiSampleFile() throws Exception { StudyConfiguration studyConfiguration = VariantStorageBaseTest.newStudyConfiguration(); VariantHadoopDBAdaptor dbAdaptor = getVariantStorageEngine().getDBAdaptor(); loadFile("s1_s2.genome.vcf", studyConfiguration, new ObjectMap(HadoopVariantStorageEngine.VARIANT_TABLE_LOAD_REFERENCE, true)); checkArchiveTableTimeStamp(dbAdaptor); printVariants(studyConfiguration, dbAdaptor, newOutputUri()); int numHomRef = 0; for (Variant variant : dbAdaptor) { StudyEntry study = variant.getStudies().get(0); for (String s : study.getSamplesName()) { String gt = study.getSampleData(s, "GT"); assertNotEquals(GenotypeClass.UNKNOWN_GENOTYPE, gt); if (GenotypeClass.HOM_REF.test(gt)) { numHomRef++; assertTrue(StringUtils.isNumeric(study.getSampleData(s, "DP"))); } } } assertNotEquals(0, numHomRef); }
@Test public void testGetSamplesInAnyVariantsGenotypeClass() throws Exception { Map<String, Set<Variant>> samples = filter.getSamplesInAnyVariants(new Query(), Arrays.asList(GenotypeClass.HOM_ALT.toString())); System.out.println("samplesInAllVariants = " + samples); assertEquals(new HashSet<>(Arrays.asList(S1, S3)), samples.keySet()); } }
public VariantDBIterator iterator(List<Region> regions, String study, String sample, List<String> gts) { Integer studyId = getStudyId(study); List<String> filteredGts = GenotypeClass.filter(gts, getAllLoadedGenotypes(study)); if (!gts.isEmpty() && filteredGts.isEmpty()) { // If empty, should find none. Add non-existing genotype // TODO: Fast empty result filteredGts = Collections.singletonList("x/x"); } return internalIterator(regions, studyId, sample, filteredGts); }
List<String> gts = GenotypeClass.filter(entry.getValue(), allGts); if (!entry.getValue().isEmpty() && gts.isEmpty()) {
@Test public void testGenotypes() throws Exception { List<String> gts = Arrays.asList("0/0", "0", "0/1", "1/1", "./.", ".", "1/2", "0/2", "2/2", "2/3", "./0", "0/.", "./1", "1/."); assertEquals(Arrays.asList("0/0", "0"), GenotypeClass.HOM_REF.filter(gts)); assertEquals(Arrays.asList("1/1", "2/2"), GenotypeClass.HOM_ALT.filter(gts)); assertEquals(Arrays.asList("0/1", "1/2", "0/2", "2/3"), GenotypeClass.HET.filter(gts)); assertEquals(Arrays.asList("0/1", "0/2"), GenotypeClass.HET_REF.filter(gts)); assertEquals(Arrays.asList("1/2", "2/3"), GenotypeClass.HET_ALT.filter(gts)); assertEquals(Arrays.asList("./.", "."), GenotypeClass.MISS.filter(gts)); } }
int sampleId = studyConfigurationManager.getSampleId(entry.getKey(), defaultStudyConfiguration); List<String> genotypes = GenotypeClass.filter(entry.getValue(), loadedGenotypes);
List<String> genotypes = GenotypeClass.filter(entry.getValue(), loadedGenotypes, defaultGenotypes);
for (Map.Entry<Object, List<String>> entry : map.entrySet()) { List<String> genotypes = GenotypeClass.filter(entry.getValue(), loadedGenotypes);