public boolean hasGenotype(String sample) { return getGenotypes().containsSample(sample); }
Assert.assertEquals(gc.get(i), expectedSamples.get(i)); Assert.assertFalse(gc.containsSample(MISSING.getSampleName())); Assert.assertTrue(gc.containsSample(name)); Assert.assertFalse(gc.containsSample(MISSING.getSampleName()));
public boolean hasGenotype(String sample) { return getGenotypes().containsSample(sample); }
public boolean hasGenotype(String sample) { return getGenotypes().containsSample(sample); }
private static Genotype getGenotypeFromArray(RefMetaDataTracker tracker, RodBinding<VariantContext> genotypes, boolean verifiedSampleName, boolean verifySample, String sampleName) { // get the truthForSample and the hapmap information for this site; if either are null we can't move forward Collection<VariantContext> truths = tracker.getValues(genotypes); if (truths == null || truths.isEmpty()) return null; VariantContext truthForSample = truths.iterator().next(); // verify that the sample name exists in the input genotype file if (!verifiedSampleName && verifySample) { if (!truthForSample.getSampleNames().contains(sampleName)) throw new UserException.BadInput("The sample name was set to " + sampleName + " but this sample isn't in your genotypes file. Please Verify your sample name"); verifiedSampleName = true; } GenotypesContext gt = truthForSample.getGenotypes(); // if we are supposed to verify the sample name, AND the sample doesn't exist in the genotypes -- skip this site if (verifySample && !gt.containsSample(sampleName)) return null; // if the sample doesn't exist in genotypes AND there is more than one sample in the genotypes file -- skip this site if (!gt.containsSample(sampleName) && gt.size() != 1) return null; // if there is more than one sample in the genotypes file, get it by name. Otherwise just get the sole sample genotype return gt.size() != 1 ? gt.get(sampleName) : gt.get(0); }
private static void mergeGenotypes(GenotypesContext mergedGenotypes, VariantContext oneVC, AlleleMapper alleleMapping, boolean uniquifySamples) { //TODO: should we add a check for cases when the genotypeMergeOption is REQUIRE_UNIQUE for ( final Genotype g : oneVC.getGenotypes() ) { final String name = mergedSampleName(oneVC.getSource(), g.getSampleName(), uniquifySamples); if ( ! mergedGenotypes.containsSample(name) ) { // only add if the name is new Genotype newG = g; if ( uniquifySamples || alleleMapping.needsRemapping() ) { final List<Allele> alleles = alleleMapping.needsRemapping() ? alleleMapping.remap(g.getAlleles()) : g.getAlleles(); newG = new GenotypeBuilder(g).name(name).alleles(alleles).make(); } mergedGenotypes.add(newG); } } }