@Override protected Double getElementForRead(final GATKSAMRecord read, final int refLoc) { return (double)Math.abs(read.getInferredInsertSize()); } }
/** * is this base inside the adaptor of the read? * * There are two cases to treat here: * * 1) Read is in the negative strand => Adaptor boundary is on the left tail * 2) Read is in the positive strand => Adaptor boundary is on the right tail * * Note: We return false to all reads that are UNMAPPED or have an weird big insert size (probably due to mismapping or bigger event) * * @param read the read to test * @param basePos base position in REFERENCE coordinates (not read coordinates) * @return whether or not the base is in the adaptor */ public static boolean isBaseInsideAdaptor(final GATKSAMRecord read, long basePos) { final int adaptorBoundary = read.getAdaptorBoundary(); if (adaptorBoundary == CANNOT_COMPUTE_ADAPTOR_BOUNDARY || read.getInferredInsertSize() > DEFAULT_ADAPTOR_SIZE) return false; return read.getReadNegativeStrandFlag() ? basePos <= adaptorBoundary : basePos >= adaptorBoundary; }
private static String insertLengthOutput(final ReadBackedPileup pileup) { Integer[] insertSizes=new Integer[pileup.depthOfCoverage()]; int i=0; for ( PileupElement p : pileup ) { insertSizes[i]=p.getRead().getInferredInsertSize(); ++i; } return Utils.join(",",insertSizes); }
@Override public Integer map(ReferenceContext referenceContext, GATKSAMRecord read, RefMetaDataTracker RefMetaDataTracker) { final String rgID = read.getReadGroup().getId(); final PerReadGroupInfo info = readGroupInfo.get(rgID); if ( info.needsMoreData() ) { info.readLength.add(read.getReadLength()); info.nReadsSeen++; if ( read.getReadPairedFlag() ) { info.nReadsPaired++; if ( read.getInferredInsertSize() != 0) { info.insertSize.add(Math.abs(read.getInferredInsertSize())); } } } return null; }
@Test public void testSecondaryAlignmentsDoNotInterfere() { final List<GATKSAMRecord> properReads = ArtificialSAMUtils.createPair(header, "foo", 1, 10, 30, true, false); final GATKSAMRecord read1 = properReads.get(0); read1.setAlignmentStart(8); // move the read read1.setFlags(99); // first in proper pair, mate negative strand final GATKSAMRecord read2Primary = properReads.get(1); read2Primary.setFlags(147); // second in pair, mate unmapped, not primary alignment Assert.assertEquals(read1.getInferredInsertSize(), 21); final GATKSAMRecord read2NonPrimary = new GATKSAMRecord(read2Primary); read2NonPrimary.setFlags(393); // second in proper pair, on reverse strand final ConstrainedMateFixingManager manager = new ConstrainedMateFixingManager(null, genomeLocParser, 1000, 1000, 1000); manager.addRead(read1, true, false); manager.addRead(read2NonPrimary, false, false); manager.addRead(read2Primary, false, false); Assert.assertEquals(manager.getNReadsInQueue(), 3); for ( final SAMRecord read : manager.getReadsInQueueForTesting() ) { if ( read.getFirstOfPairFlag() ) { Assert.assertEquals(read.getFlags(), 99); Assert.assertEquals(read.getInferredInsertSize(), 23); } else if ( read.getNotPrimaryAlignmentFlag() ) { Assert.assertEquals(read.getFlags(), 393); Assert.assertEquals(read.getInferredInsertSize(), -21); } else { Assert.assertEquals(read.getFlags(), 147); Assert.assertEquals(read.getInferredInsertSize(), -23); } } }
/** * Creates a hard-clipped view on a existing read record. * @param read the underlying unclipped read. * @param start inclusive first position in {@code read} included in the clipped view. * @param end inclusive last position in {@code read} included in the clipped view. */ public ClippedGATKSAMRecord(final GATKSAMRecord read, int start, int end) { super(read.getHeader()); this.setReferenceIndex(read.getReferenceIndex()); this.setAlignmentStart(read.getAlignmentStart() + start); this.setMappingQuality(100); // setting read indexing bin below this.setFlags(read.getFlags()); this.setMateReferenceIndex(read.getMateReferenceIndex()); this.setMateAlignmentStart(read.getMateAlignmentStart()); this.setInferredInsertSize(read.getInferredInsertSize()); this.setReadBases(Arrays.copyOfRange(read.getReadBases(), start, end)); this.setBaseQualities(Arrays.copyOfRange(read.getBaseQualities(),start,end)); this.setReadName(read.getReadName()); insertionQuals = Arrays.copyOfRange(read.getBaseInsertionQualities(),start,end); deletionQuals = Arrays.copyOfRange(read.getBaseDeletionQualities(),start,end); // Set these to null in order to mark them as being candidates for lazy initialization. // If this is not done, they will have non-null defaults. super.setReadName(null); super.setCigarString(null); super.setReadBases(null); super.setBaseQualities(null); // Do this after the above because setCigarString will clear it. GATKBin.setReadIndexingBin(this, -1); }
emptyRead.setMateReferenceIndex(read.getMateReferenceIndex()); emptyRead.setMateAlignmentStart(read.getMateAlignmentStart()); emptyRead.setInferredInsertSize(read.getInferredInsertSize());