@Override public int getMateAlignmentStart() { if (!initializedFields.contains(LazyField.MATE_ALIGNMENT_START)) { setMateAlignmentStart(getMateAlignmentStartImpl()); } return super.getMateAlignmentStart(); }
@Override public int getMateAlignmentStart() { if (!initializedFields.contains(LazyField.MATE_ALIGNMENT_START)) { setMateAlignmentStart(getMateAlignmentStartImpl()); } return super.getMateAlignmentStart(); }
/** * @param rec the SAM record * Returns blocks of the mate sequence that have been aligned directly to the * reference sequence. Note that clipped portions of the mate and inserted and * deleted bases (vs. the reference) are not represented in the alignment blocks. */ public static List<AlignmentBlock> getMateAlignmentBlocks(final SAMRecord rec) { return getAlignmentBlocks(getMateCigar(rec), rec.getMateAlignmentStart(), "mate cigar"); }
/** * @param rec the SAM record * Returns blocks of the mate sequence that have been aligned directly to the * reference sequence. Note that clipped portions of the mate and inserted and * deleted bases (vs. the reference) are not represented in the alignment blocks. */ public static List<AlignmentBlock> getMateAlignmentBlocks(final SAMRecord rec) { return getAlignmentBlocks(getMateCigar(rec), rec.getMateAlignmentStart(), "mate cigar"); }
/** * @param rec the SAM record * Returns blocks of the mate sequence that have been aligned directly to the * reference sequence. Note that clipped portions of the mate and inserted and * deleted bases (vs. the reference) are not represented in the alignment blocks. */ public static List<AlignmentBlock> getMateAlignmentBlocks(final SAMRecord rec) { return getAlignmentBlocks(getMateCigar(rec), rec.getMateAlignmentStart(), "mate cigar"); }
/** * @param rec the SAM record * Returns blocks of the mate sequence that have been aligned directly to the * reference sequence. Note that clipped portions of the mate and inserted and * deleted bases (vs. the reference) are not represented in the alignment blocks. */ public static List<AlignmentBlock> getMateAlignmentBlocks(final SAMRecord rec) { return getAlignmentBlocks(getMateCigar(rec), rec.getMateAlignmentStart(), "mate cigar"); }
private void addRead(SAMRecord read) { if (read.getReadUnmappedFlag()) return; // TODO: process CIGAR instead of just taking the whole alignment length as support for the reference currentReferenceRead.add(read.getAlignmentEnd()); if (isLowerMappedOfNonOverlappingConcordantPair(read)) { currentStartReferencePairs.add(read.getAlignmentEnd()); currentEndReferencePairs.add(read.getMateAlignmentStart()); } } /**
private static int getFragmentSize(SAMRecord samRecord, int defaultFragmentSize, ReadPairConcordanceCalculator rpcc) { int fragmentSize = Math.max(defaultFragmentSize, samRecord.getReadLength()); if (rpcc.isConcordant(samRecord) && samRecord.getMateAlignmentStart() != 0) { fragmentSize = SAMRecordUtil.estimateFragmentSize(samRecord, PairOrientation.FR); } return fragmentSize; } }
private static boolean isReadsOverlap(SAMRecord record, int start, int position, int mateAlignmentStart){ if (position >= mateAlignmentStart) { return start >= mateAlignmentStart && start <= (mateAlignmentStart + record.getCigar().getReferenceLength() - 1); } else { return start >= mateAlignmentStart && record.getMateAlignmentStart() <= record.getAlignmentEnd(); } }
private boolean isLowerMappedOfNonOverlappingConcordantPair(SAMRecord read) { return !read.getReadUnmappedFlag() && read.getReadPairedFlag() && !read.getMateUnmappedFlag() && read.getAlignmentEnd() < read.getMateAlignmentStart() && read.getReferenceIndex().equals(read.getMateReferenceIndex()) && (read.getAlignmentStart() < read.getMateAlignmentStart() || (read.getAlignmentStart() == read.getMateAlignmentStart() && read.getFirstOfPairFlag())) && pairing.isConcordant(read); } private String trackedBufferName_currentReferenceRead = "coverage.currentReferenceRead";
/** * This method uses the MateCigar value as determined from the attribute MC. It must be non-null. * @param rec the SAM record * @return 1-based inclusive rightmost position of the clipped mate sequence, or 0 read if unmapped. */ public static int getMateAlignmentEnd(final SAMRecord rec) { if (rec.getMateUnmappedFlag()) { throw new RuntimeException("getMateAlignmentEnd called on an unmapped mate."); } final Cigar mateCigar = SAMUtils.getMateCigar(rec); if (mateCigar == null) { throw new SAMException("Mate CIGAR (Tag MC) not found."); } return CoordMath.getEnd(rec.getMateAlignmentStart(), mateCigar.getReferenceLength()); }
private void assertMate(final SAMRecord rec, final SAMRecord mate) { Assert.assertNotNull(mate); Assert.assertEquals(mate.getReadName(), rec.getReadName()); Assert.assertEquals(mate.getReferenceIndex(), rec.getMateReferenceIndex()); if (SAMUtils.getMateCigarString(rec) != null) { Assert.assertEquals(mate.getCigarString(), SAMUtils.getMateCigarString(rec)); } Assert.assertEquals(mate.getAlignmentStart(), rec.getMateAlignmentStart()); Assert.assertFalse(mate.getFirstOfPairFlag() == rec.getFirstOfPairFlag()); }
protected Range<Long> getMateRange(SAMRecord r) { if (!r.getReadPairedFlag() || r.getMateUnmappedFlag()) { return null; } Object mc = r.getAttribute(SAMTag.MC.name()); Cigar mateCigar = null; if (mc instanceof String) { mateCigar = TextCigarCodec.decode((String)mc); } long start = lgc.getLinearCoordinate(r.getMateReferenceIndex(), r.getMateAlignmentStart()); return rangeOf(start, mateCigar); }
public MateKey getMateKey(SAMRecord read) { // If mate is mapped, use read flag. // If mate is not mapped, use opposite of this read's RC flag boolean isMateRevOrientation = read.getMateUnmappedFlag() ? !read.getReadNegativeStrandFlag() : read.getMateNegativeStrandFlag(); int matePos = read.getMateUnmappedFlag() ? -1 : read.getMateAlignmentStart(); int mateNum = read.getFirstOfPairFlag() ? 2 : 1; return new MateKey(read.getReadName(), matePos, read.getMateUnmappedFlag(), isMateRevOrientation, mateNum, read.getAlignmentStart()); }
public PairEndInfo(final SAMRecord record, final long recordNumber) { this.recordNumber = recordNumber; this.readAlignmentStart = record.getAlignmentStart(); this.readNegStrandFlag = record.getReadNegativeStrandFlag(); this.readReferenceIndex = record.getReferenceIndex(); this.readUnmappedFlag = record.getReadUnmappedFlag(); this.readCigarString = record.getCigarString(); this.mateAlignmentStart = record.getMateAlignmentStart(); this.mateNegStrandFlag = record.getMateNegativeStrandFlag(); this.mateReferenceIndex = record.getMateReferenceIndex(); this.mateUnmappedFlag = record.getMateUnmappedFlag(); final Object mcs = record.getAttribute(SAMTag.MC.name()); this.mateCigarString = (mcs != null) ? (String) mcs : null; this.firstOfPairFlag = record.getFirstOfPairFlag(); }
public PairEndInfo(final SAMRecord record, final long recordNumber) { this.recordNumber = recordNumber; this.readAlignmentStart = record.getAlignmentStart(); this.readNegStrandFlag = record.getReadNegativeStrandFlag(); this.readReferenceIndex = record.getReferenceIndex(); this.readUnmappedFlag = record.getReadUnmappedFlag(); this.readCigarString = record.getCigarString(); this.mateAlignmentStart = record.getMateAlignmentStart(); this.mateNegStrandFlag = record.getMateNegativeStrandFlag(); this.mateReferenceIndex = record.getMateReferenceIndex(); this.mateUnmappedFlag = record.getMateUnmappedFlag(); final Object mcs = record.getAttribute(SAMTag.MC.name()); this.mateCigarString = (mcs != null) ? (String) mcs : null; this.firstOfPairFlag = record.getFirstOfPairFlag(); }
private void compare(SAMRecord r1, SAMRecord r2) { assertThat(r1.getReadName(), equalTo(r2.getReadName())); assertThat(r1.getFlags(), equalTo(r2.getFlags())); assertThat(r1.getReferenceIndex(), equalTo(r2.getReferenceIndex())); assertThat(r1.getAlignmentStart(), equalTo(r2.getAlignmentStart())); assertThat(r1.getMappingQuality(), equalTo(r2.getMappingQuality())); assertThat(r1.getCigarString(), equalTo(r2.getCigarString())); assertThat(r1.getMateReferenceIndex(), equalTo(r2.getMateReferenceIndex())); assertThat(r1.getMateAlignmentStart(), equalTo(r2.getMateAlignmentStart())); assertThat(r1.getInferredInsertSize(), equalTo(r2.getInferredInsertSize())); assertArrayEquals(r1.getReadBases(), r2.getReadBases()); assertArrayEquals(r1.getBaseQualities(), r2.getBaseQualities()); }
public static boolean isDovetailing(SAMRecord record, PairOrientation expectedOrientation, int margin) { if (record.getReadUnmappedFlag()) return false; if (!record.getReadPairedFlag()) return false; if (record.getMateUnmappedFlag()) return false; Cigar cigar2 = null; String mc = record.getStringAttribute(SAMTag.MC.name()); if (mc != null) { cigar2 = TextCigarCodec.decode(mc); } return isDovetailing(record.getReferenceIndex(), record.getAlignmentStart(), record.getReadNegativeStrandFlag(), record.getCigar(), record.getMateReferenceIndex(), record.getMateAlignmentStart(), record.getMateNegativeStrandFlag(), cigar2, expectedOrientation, margin); }
public static Alignment buildAlignment(SAMRecord record, Map<String, Object> attributes, String referenceSequence) { List<Alignment.AlignmentDifference> differences; differences = AlignmentUtils.getDifferencesFromCigar(record, referenceSequence, Integer.MAX_VALUE); Alignment alignment = new Alignment(record.getReadName(), record.getReferenceName(), record.getAlignmentStart(), record.getAlignmentEnd(), record.getUnclippedStart(), record.getUnclippedEnd(), record.getReadLength(), record.getMappingQuality(), record.getBaseQualityString(),//.replace("\\", "\\\\").replace("\"", "\\\""), record.getMateReferenceName(), record.getMateAlignmentStart(), record.getInferredInsertSize(), record.getFlags(), differences, attributes); return alignment; } public static Alignment buildAlignment(SAMRecord record, String referenceSequence) {
private int translate(SAMRecord record, BAMRecordView view) { view.setReadName(record.getReadName()); view.setFlags(record.getFlags()); view.setRefID(record.getReferenceIndex()); view.setAlignmentStart(record.getAlignmentStart()); view.setMappingScore(record.getMappingQuality()); view.setCigar(record.getCigar()); view.setMateRefID(record.getMateReferenceIndex()); view.setMateAlStart(record.getMateAlignmentStart()); view.setInsertSize(record.getInferredInsertSize()); view.setBases(record.getReadBases()); view.setQualityScores(record.getBaseQualities()); view.setTagData(new byte[0], 0, 0); return view.finish(); }