protected ObjectArrayList<? extends GenotypeCount> getAllCounts(BaseInformationRecords.BaseInformationOrBuilder record, boolean isTumor) { return getAllCounts(record, isTumor, true); }
protected float[] getBuffer() { if (buffer == null) { buffer = new float[numberOfFeatures()]; } else { Arrays.fill(buffer, 0f); } return buffer; }
protected ObjectArrayList<? extends GenotypeCount> getAllCounts(BaseInformationRecords.BaseInformationOrBuilder record, boolean isTumor, boolean sort) { ObjectArrayList<? extends GenotypeCount> cached = getCachedResult(isTumor, sort); if (cached != null && record.equals(recordCached[isTumor ? 1 : 0][sort ? 1 : 0])) { return cached; } else { assert oneSampleHasTumor(record.getSamplesList()) : "at least one sample must have hasTumor=true."; for (int i = 0; i < record.getSamplesCount(); i++) { if (isTumor != record.getSamples(i).getIsTumor()) continue; // a subclass is expected to override getGenotypeCountFactory to provide its own type for Genotype counts: cached = getAllCounts(record, getGenotypeCountFactory(), isTumor, sort); putInCache(record, cached, isTumor, sort); return cached; } throw new InternalError("At least one sample matching isTumor, and one matching not isTumor must be found."); } }
protected ObjectArrayList<? extends GenotypeCount> getAllCounts(BaseInformationRecords.BaseInformationOrBuilder record, GenotypeCountFactory factory, boolean isTumor, boolean sort) { int sampleIndex = isTumor ? 1 : 0; ObjectArrayList<GenotypeCount> list = new ObjectArrayList<>(); int genotypeIndex = 0; for (int i = 0; i < record.getSamples(0).getCountsCount(); i++) { int germCount = record.getSamples(0).getCounts(i).getGenotypeCountForwardStrand() + record.getSamples(0).getCounts(i).getGenotypeCountReverseStrand(); BaseInformationRecords.CountInfo genoInfo = record.getSamples(sampleIndex).getCounts(i); int forwCount = genoInfo.getGenotypeCountForwardStrand(); int revCount = genoInfo.getGenotypeCountReverseStrand(); GenotypeCount count = factory.create(); count.set(forwCount, revCount, genoInfo.getToSequence(), i, germCount); initializeCount(record.getSamples(sampleIndex).getCounts(i), count); list.add(count); } // DO not increment genotypeIndex. It must remain constant for all N bases int genotypeIndexFor_Ns = N_GENOTYPE_INDEX; // pad with zero until we have 10 elements: while (list.size() < MAX_GENOTYPES) { final GenotypeCount genotypeCount = getGenotypeCountFactory().create(); genotypeCount.set(0, 0, "N", genotypeIndexFor_Ns, 0); list.add(genotypeCount); } //sort in decreasing order of counts: if (sort) { Collections.sort(list); } // trim the list at 5 elements because we will consider only the 5 genotypes with largest total counts: list.trim(MAX_GENOTYPES); return list; }
/** * Default implementation assumes a 1-d tensor. * * @return */ @Override public MappedDimensions dimensions() { return new MappedDimensions(numberOfFeatures()); }
protected ObjectArrayList<? extends GenotypeCount> getAllCounts(BaseInformationRecords.BaseInformationOrBuilder record, GenotypeCountFactory factory, boolean isTumor) { return getAllCounts(record, factory, isTumor, true); }