@Override public int size() { // optimization -- we know the number of samples in the unparsed data, so use it here to // avoid parsing just to know the size of the context return loaded ? super.size() : nUnparsedGenotypes; }
/** * @return the number of samples in the context */ public int getNSamples() { return genotypes.size(); }
/** * @return the number of samples in the context */ public int getNSamples() { return genotypes.size(); }
@Override public int size() { // optimization -- we know the number of samples in the unparsed data, so use it here to // avoid parsing just to know the size of the context return loaded ? super.size() : nUnparsedGenotypes; }
/** * @return the number of samples in the context */ public int getNSamples() { return genotypes.size(); }
@Override public int size() { // optimization -- we know the number of samples in the unparsed data, so use it here to // avoid parsing just to know the size of the context return loaded ? super.size() : nUnparsedGenotypes; }
/** * @param ith the sample index * * @return the ith genotype in this context or null if there aren't that many genotypes */ public Genotype getGenotype(int ith) { return genotypes.size() > ith ? genotypes.get(ith) : null; }
/** * @param ith the sample index * * @return the ith genotype in this context or null if there aren't that many genotypes */ public Genotype getGenotype(int ith) { return genotypes.size() > ith ? genotypes.get(ith) : null; }
@Ensures({"sampleNamesInOrder != null"}) protected void ensureSampleOrdering() { if ( sampleNamesInOrder == null ) { sampleNamesInOrder = new ArrayList<String>(size()); for ( int i = 0; i < size(); i++ ) { sampleNamesInOrder.add(getGenotypes().get(i).getSampleName()); } Collections.sort(sampleNamesInOrder); } }
protected Map<String, Object> makeCoeffAnnotation(final VariantContext vc) { final GenotypesContext genotypes = (founderIds == null || founderIds.isEmpty()) ? vc.getGenotypes() : vc.getGenotypes(founderIds); if (genotypes == null || genotypes.size() < MIN_SAMPLES || !vc.isVariant()) return null; final double F = calculateIC(vc, genotypes); if (heterozygosityUtils.getSampleCount() < MIN_SAMPLES) return null; return Collections.singletonMap(getKeyNames().get(0), (Object)String.format("%.4f", F)); }
public static GenotypesContext stripPLsAndAD(final GenotypesContext genotypes) { final GenotypesContext newGs = GenotypesContext.create(genotypes.size()); for ( final Genotype g : genotypes ) { newGs.add(removePLsAndAD(g)); } return newGs; }
public void run(final VariantContext vc) { if ( samples == null ) samples = new HashSet<>(new ArrayList<>(vc.getSampleNames()).subList(0, nSamplesToTake)); vc.getGenotypes(samples).size(); } };
@Test(enabled = true, dataProvider = "GenotypesContextProvider") public void testSet(GenotypesContextProvider cfg) { Genotype set = GenotypeBuilder.create("replace", Arrays.asList(Aref, Aref)); int n = cfg.makeContext().size(); for ( int i = 0; i < n; i++ ) { GenotypesContext gc = cfg.makeContext(); Genotype setted = gc.set(i, set); Assert.assertNotNull(setted); ArrayList<Genotype> l = new ArrayList<Genotype>(cfg.initialSamples); l.set(i, set); testGenotypesContextContainsExpectedSamples(gc, l); } }
@Requires("originalGenotypes != null && alleleMapper != null") protected static GenotypesContext updateGenotypesWithMappedAlleles(final GenotypesContext originalGenotypes, final AlleleMapper alleleMapper) { final GenotypesContext updatedGenotypes = GenotypesContext.create(originalGenotypes.size()); for ( final Genotype genotype : originalGenotypes ) { final List<Allele> updatedAlleles = alleleMapper.remap(genotype.getAlleles()); updatedGenotypes.add(new GenotypeBuilder(genotype).alleles(updatedAlleles).make()); } return updatedGenotypes; }