Java Code Examples for htsjdk.samtools.SamPairUtil#PairOrientation
The following examples show how to use
htsjdk.samtools.SamPairUtil#PairOrientation .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MergeBamAlignmentTest.java From picard with MIT License | 6 votes |
private void doMergeAlignment(final File unmappedBam, final List<File> alignedBams, final List<File> read1AlignedBams, final List<File> read2AlignedBams, final Integer read1Trim, final Integer read2Trim, final boolean alignReadsOnly, final boolean clipAdapters, final boolean isBisulfiteSequence, final int maxInsOrDels, final String progRecordId, final String progGroupVersion, final String progGroupCommandLine, final String progGroupName, final boolean pairedRun, final File refSeq, final File output, final SamPairUtil.PairOrientation expectedOrientation, final MergeBamAlignment.PrimaryAlignmentStrategy primaryAlignmentStrategy, final String attributesToRetain, final Boolean includeSecondary, final Boolean unmapContaminantReads, final SAMFileHeader.SortOrder sortOrder) { doMergeAlignment(unmappedBam, alignedBams, read1AlignedBams, read2AlignedBams, read1Trim, read2Trim, alignReadsOnly, clipAdapters, isBisulfiteSequence, maxInsOrDels, progRecordId, progGroupVersion, progGroupCommandLine, progGroupName, pairedRun, refSeq, output, expectedOrientation, primaryAlignmentStrategy, attributesToRetain, includeSecondary, unmapContaminantReads, sortOrder, null); }
Example 2
Source File: InsertSizeMetricsCollector.java From picard with MIT License | 5 votes |
@Override protected InsertSizeCollectorArgs makeArg(SAMRecord samRecord, ReferenceSequence refSeq) { final int insertSize = Math.abs(samRecord.getInferredInsertSize()); final SamPairUtil.PairOrientation orientation = SamPairUtil.getPairOrientation(samRecord); return new InsertSizeCollectorArgs(insertSize, orientation); }
Example 3
Source File: InsertSizeMetricsCollector.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected InsertSizeMetricsCollectorArgs makeArg(SAMRecord samRecord, ReferenceSequence refSeq) { // inferred insert size is negative if the mate maps to lower position than the read, so use abs final int insertSize = Math.abs(samRecord.getInferredInsertSize()); final SamPairUtil.PairOrientation orientation = SamPairUtil.getPairOrientation(samRecord); return new InsertSizeMetricsCollectorArgs(insertSize, orientation); }
Example 4
Source File: InsertSizeMetricsCollector.java From picard with MIT License | 4 votes |
public void addMetricsToFile(final MetricsFile<InsertSizeMetrics,Integer> file) { // get the number of inserts, and the maximum and minimum keys across, across all orientations for (final Histogram<Integer> h : this.histograms.values()) { totalInserts += h.getCount(); } if (0 == totalInserts) return; // nothing to store for(final Map.Entry<SamPairUtil.PairOrientation, Histogram<Integer>> entry : histograms.entrySet()) { final SamPairUtil.PairOrientation pairOrientation = entry.getKey(); final Histogram<Integer> histogram = entry.getValue(); final double total = histogram.getCount(); // Only include a category if it has a sufficient percentage of the data in it if( total >= totalInserts * minimumPct ) { final InsertSizeMetrics metrics = new InsertSizeMetrics(); metrics.SAMPLE = this.sample; metrics.LIBRARY = this.library; metrics.READ_GROUP = this.readGroup; metrics.PAIR_ORIENTATION = pairOrientation; if (!histogram.isEmpty()) { metrics.READ_PAIRS = (long) total; metrics.MAX_INSERT_SIZE = (int) histogram.getMax(); metrics.MIN_INSERT_SIZE = (int) histogram.getMin(); metrics.MEDIAN_INSERT_SIZE = histogram.getMedian(); metrics.MODE_INSERT_SIZE = histogram.getMode(); metrics.MEDIAN_ABSOLUTE_DEVIATION = histogram.getMedianAbsoluteDeviation(); final double median = histogram.getMedian(); double covered = 0; double low = median; double high = median; while (low >= histogram.getMin()-1 || high <= histogram.getMax()+1) { final Histogram.Bin<Integer> lowBin = histogram.get((int) low); if (lowBin != null) covered += lowBin.getValue(); if (low != high) { final Histogram.Bin<Integer> highBin = histogram.get((int) high); if (highBin != null) covered += highBin.getValue(); } final double percentCovered = covered / total; final int distance = (int) (high - low) + 1; if (percentCovered >= 0.1 && metrics.WIDTH_OF_10_PERCENT == 0) metrics.WIDTH_OF_10_PERCENT = distance; if (percentCovered >= 0.2 && metrics.WIDTH_OF_20_PERCENT == 0) metrics.WIDTH_OF_20_PERCENT = distance; if (percentCovered >= 0.3 && metrics.WIDTH_OF_30_PERCENT == 0) metrics.WIDTH_OF_30_PERCENT = distance; if (percentCovered >= 0.4 && metrics.WIDTH_OF_40_PERCENT == 0) metrics.WIDTH_OF_40_PERCENT = distance; if (percentCovered >= 0.5 && metrics.WIDTH_OF_50_PERCENT == 0) metrics.WIDTH_OF_50_PERCENT = distance; if (percentCovered >= 0.6 && metrics.WIDTH_OF_60_PERCENT == 0) metrics.WIDTH_OF_60_PERCENT = distance; if (percentCovered >= 0.7 && metrics.WIDTH_OF_70_PERCENT == 0) metrics.WIDTH_OF_70_PERCENT = distance; if (percentCovered >= 0.8 && metrics.WIDTH_OF_80_PERCENT == 0) metrics.WIDTH_OF_80_PERCENT = distance; if (percentCovered >= 0.9 && metrics.WIDTH_OF_90_PERCENT == 0) metrics.WIDTH_OF_90_PERCENT = distance; if (percentCovered >= 0.95 && metrics.WIDTH_OF_95_PERCENT == 0) metrics.WIDTH_OF_95_PERCENT = distance; if (percentCovered >= 0.99 && metrics.WIDTH_OF_99_PERCENT == 0) metrics.WIDTH_OF_99_PERCENT = distance; --low; ++high; } } // Trim the Histogram down to get rid of outliers that would make the chart useless. final Histogram<Integer> trimmedHistogram = histogram; // alias it trimmedHistogram.trimByWidth(getWidthToTrimTo(metrics)); if (!trimmedHistogram.isEmpty()) { metrics.MEAN_INSERT_SIZE = trimmedHistogram.getMean(); metrics.STANDARD_DEVIATION = trimmedHistogram.getStandardDeviation(); } file.addHistogram(trimmedHistogram); file.addMetric(metrics); } } }
Example 5
Source File: InsertSizeMetricsCollector.java From picard with MIT License | 4 votes |
public SamPairUtil.PairOrientation getPairOrientation() { return po; }
Example 6
Source File: InsertSizeMetricsCollector.java From picard with MIT License | 4 votes |
public InsertSizeCollectorArgs(final int insertSize, final SamPairUtil.PairOrientation po) { this.insertSize = insertSize; this.po = po; }
Example 7
Source File: InsertSizeMetricsCollectorArgs.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
public SamPairUtil.PairOrientation getPairOrientation() { return po; }
Example 8
Source File: InsertSizeMetricsCollectorArgs.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
public InsertSizeMetricsCollectorArgs(final int insertSize, final SamPairUtil.PairOrientation po) { this.insertSize = insertSize; this.po = po; }