private void outputMissingInterval(final IntervalStratification stats) { final GenomeLoc interval = stats.getInterval(); final boolean missing[] = new boolean[interval.size()]; Arrays.fill(missing, true); for (AbstractStratification sample : stats.getElements()) { if (hasMissingStatuses(sample)) { int pos = 0; for (AbstractStratification locus : sample.getElements()) { if (locus.callableStatuses().isEmpty()) { missing[pos] = false; } pos++; } } } int start = -1; boolean insideMissing = false; for (int i = 0; i < missing.length; i++) { if (missing[i] && !insideMissing) { start = interval.getStart() + i; insideMissing = true; } else if (!missing[i] && insideMissing) { final int stop = interval.getStart() + i - 1; outputMissingInterval(interval.getContig(), start, stop); insideMissing = false; } } if (insideMissing) { outputMissingInterval(interval.getContig(), start, interval.getStop()); } }
/** * Takes the interval, finds it in the stash, prints it to the VCF * * @param stats The statistics of the interval * @param refAllele the reference allele */ private void outputStatsToVCF(final IntervalStratification stats, final Allele refAllele) { GenomeLoc interval = stats.getInterval(); final List<Allele> alleles = new ArrayList<>(); final Map<String, Object> attributes = new HashMap<>(); final ArrayList<Genotype> genotypes = new ArrayList<>(); for (String sample : samples) { final GenotypeBuilder gb = new GenotypeBuilder(sample); SampleStratification sampleStat = stats.getSampleStatistics(sample); gb.attribute( GATKVCFConstants.AVG_INTERVAL_DP_BY_SAMPLE_KEY, sampleStat.averageCoverage(interval.size())); gb.attribute(GATKVCFConstants.LOW_COVERAGE_LOCI, sampleStat.getNLowCoveredLoci()); gb.attribute(GATKVCFConstants.ZERO_COVERAGE_LOCI, sampleStat.getNUncoveredLoci()); gb.filters(statusToStrings(stats.getSampleStatistics(sample).callableStatuses(), false)); genotypes.add(gb.make()); } alleles.add(refAllele); alleles.add(SYMBOLIC_ALLELE); VariantContextBuilder vcb = new VariantContextBuilder( "DiagnoseTargets", interval.getContig(), interval.getStart(), interval.getStop(), alleles); vcb = vcb.log10PError(VariantContext.NO_LOG10_PERROR); vcb.filters(new LinkedHashSet<>(statusToStrings(stats.callableStatuses(), true))); attributes.put(VCFConstants.END_KEY, interval.getStop()); attributes.put(GATKVCFConstants.AVG_INTERVAL_DP_KEY, stats.averageCoverage(interval.size())); attributes.put(GATKVCFConstants.INTERVAL_GC_CONTENT_KEY, stats.gcContent()); vcb = vcb.attributes(attributes); vcb = vcb.genotypes(genotypes); vcfWriter.add(vcb.make()); }
public Event(GenomeLoc loc, int furthestStopPos, EVENT_TYPE type) { this.loc = loc; this.furthestStopPos = furthestStopPos; this.type = type; if (type == EVENT_TYPE.INDEL_EVENT || type == EVENT_TYPE.BOTH) { eventStartPos = loc.getStart(); eventStopPos = loc.getStop(); } else { eventStartPos = -1; eventStopPos = -1; } if (type == EVENT_TYPE.POINT_EVENT || type == EVENT_TYPE.BOTH) { pointEvents.add(loc.getStart()); } }
public void onTraversalDone(EventPair sum) { if (sum.left != null && sum.left.isReportableEvent()) sum.intervals.add(sum.left.getLoc()); if (sum.right != null && sum.right.isReportableEvent()) sum.intervals.add(sum.right.getLoc()); if (FilenameUtils.getExtension(out.getName()).equals("interval_list")) { final SAMFileHeader masterSequenceDictionaryHeader = new SAMFileHeader(); masterSequenceDictionaryHeader.setSequenceDictionary( getToolkit().getMasterSequenceDictionary()); final IntervalList intervalList = new IntervalList(masterSequenceDictionaryHeader); for (GenomeLoc loc : sum.intervals) { intervalList.add(new Interval(loc.getContig(), loc.getStart(), loc.getStop())); } intervalList.write(out); } else { try (BufferedWriter bufferedWriter = IOUtil.openFileForBufferedWriting(out)) { for (GenomeLoc loc : sum.intervals) { bufferedWriter.write(loc.toString()); bufferedWriter.newLine(); } } catch (final IOException e) { throw new GATKException("Error writing out intervals to file: " + out.getAbsolutePath(), e); } } }
public String toString() { return String.format( "%s\t%d\t%d\t%s", loc.getContig(), loc.getStart() - 1, loc.getStop(), state); }
/** * Updating the location of this CalledBaseState by the new stop location * * @param newStop */ public void update(GenomeLoc newStop) { loc = genomeLocParser.createGenomeLoc(loc.getContig(), loc.getStart(), newStop.getStop()); }