/** * an alias of {@link #getAlignmentStart() * @return 1-based inclusive leftmost position of the clipped sequence, or 0 if there is no position. */ @Override public int getStart() { return getAlignmentStart(); }
/** * an alias of {@link #getAlignmentStart() * @return 1-based inclusive leftmost position of the clipped sequence, or 0 if there is no position. */ @Override public int getStart() { return getAlignmentStart(); }
private void processStackChangeWithinContig( SAMRecord read ) { currentContigNumStacks++; updateReadsPerStack(currentStackNumReads); currentStackNumReads = 1; updateDistanceBetweenStacks(read.getAlignmentStart() - lastRead.getAlignmentStart()); }
private void setCurrentPosition( final T read ) { currentContigIndex = read.getReferenceIndex(); currentAlignmentStart = read.getAlignmentStart(); positionEstablished = true; }
protected SamSequenceFragment(TextRead tr, TextRead mate) { if(tr.getSamRecord().getAlignmentStart() <= mate.getSamRecord().getAlignmentStart()){ this.leftRead= tr; this.rightRead= mate; } else { this.leftRead= mate; this.rightRead= tr; } this.isSingleton= false; }
public UnsupportedCigarOperatorException(final CigarOperator co, final SAMRecord read, final String message) { super(String.format( "Unsupported CIGAR operator %s in read %s at %s:%d. %s", co, read.getReadName(), read.getReferenceName(), read.getAlignmentStart(), message)); } }
public boolean hasNext() { if (chr == null && currentRecord != null) { return true; } if (currentRecord == null || (chr != null && !chr.equals(currentRecord.getReferenceName()))) { return false; } else { return contained ? currentRecord.getAlignmentEnd() <= end : currentRecord.getAlignmentStart() <= end; } }
@Override public int getAlignmentStart() { if (!initializedFields.contains(LazyField.ALIGNMENT_START)) { setAlignmentStart(getAlignmentStartImpl()); } return super.getAlignmentStart(); }
public int compare(SAMRecord lhs, SAMRecord rhs) { if(!lhs.getReferenceIndex().equals(rhs.getReferenceIndex())) return lhs.getReferenceIndex() - rhs.getReferenceIndex(); // Note: no integer overflow here because alignment starts are >= 0. return lhs.getAlignmentStart() - rhs.getAlignmentStart(); } }
/** * Returns blocks of the read sequence that have been aligned directly to the * reference sequence. Note that clipped portions of the read and inserted and * deleted bases (vs. the reference) are not represented in the alignment blocks. */ public List<AlignmentBlock> getAlignmentBlocks() { if (this.mAlignmentBlocks == null) { this.mAlignmentBlocks = SAMUtils.getAlignmentBlocks(getCigar(), getAlignmentStart(), "read cigar"); } return this.mAlignmentBlocks; }
private boolean readIsPastCurrentPosition( final T read ) { return ! positionEstablished || read.getReferenceIndex() > currentContigIndex || read.getAlignmentStart() > currentAlignmentStart || (read.getReadUnmappedFlag() && ! unmappedReadsReached); }
/** * Returns blocks of the read sequence that have been aligned directly to the * reference sequence. Note that clipped portions of the read and inserted and * deleted bases (vs. the reference) are not represented in the alignment blocks. */ public List<AlignmentBlock> getAlignmentBlocks() { if (this.mAlignmentBlocks == null) { this.mAlignmentBlocks = SAMUtils.getAlignmentBlocks(getCigar(), getAlignmentStart(), "read cigar"); } return this.mAlignmentBlocks; }
/** * @return the alignment start (1-based, inclusive) adjusted for clipped bases. For example if the read * has an alignment start of 100 but the first 4 bases were clipped (hard or soft clipped) * then this method will return 96. * * Invalid to call on an unmapped read. */ public int getUnclippedStart() { return SAMUtils.getUnclippedStart(getAlignmentStart(), getCigar()); }
/** * Check for invalid end of alignments. * @param read The read to validate. * @return true if read end is valid, false otherwise. */ private static boolean checkInvalidAlignmentEnd(final SAMRecord read ) { // Alignment aligns to negative number of bases in the reference. if( !read.getReadUnmappedFlag() && read.getAlignmentEnd() != -1 && (read.getAlignmentEnd()-read.getAlignmentStart()+1)<0 ) return false; return true; }
@Test public void testBasicOverlappedReadClipping() { final SAMRecordSetBuilder set = new SAMRecordSetBuilder(); set.setReadLength(110); final List<SAMRecord> recs = set.addPair("q1", 0, 100, 90, false, false, "110M", "110M", false, true, 30); final SAMRecord r1 = recs.get(0); final SAMRecord r2 = recs.get(1); AbstractAlignmentMerger.clipForOverlappingReads(r1, r2); Assert.assertEquals(r1.getAlignmentStart(), 100); Assert.assertEquals(r1.getCigarString(), "100M10S"); Assert.assertEquals(r2.getAlignmentStart(), 100); Assert.assertEquals(r2.getCigarString(), "10S100M"); }
@Test public void tesOverlappedReadClippingWithNonOverlappedReads() { final SAMRecordSetBuilder set = new SAMRecordSetBuilder(); set.setReadLength(110); final List<SAMRecord> recs = set.addPair("q1", 0, 100, 200, false, false, "110M", "110M", false, true, 30); final SAMRecord r1 = recs.get(0); final SAMRecord r2 = recs.get(1); AbstractAlignmentMerger.clipForOverlappingReads(r1, r2); Assert.assertEquals(r1.getAlignmentStart(), 100); Assert.assertEquals(r1.getCigarString(), "110M"); Assert.assertEquals(r2.getAlignmentStart(), 200); Assert.assertEquals(r2.getCigarString(), "110M"); }
@Test public void testOverlappedReadClippingWithExistingSoftClipping() { final SAMRecordSetBuilder set = new SAMRecordSetBuilder(); set.setReadLength(120); final List<SAMRecord> recs = set.addPair("q1", 0, 100, 95, false, false, "110M10S", "15S105M", false, true, 30); final SAMRecord r1 = recs.get(0); final SAMRecord r2 = recs.get(1); AbstractAlignmentMerger.clipForOverlappingReads(r1, r2); Assert.assertEquals(r1.getAlignmentStart(), 100); Assert.assertEquals(r1.getCigarString(), "100M20S"); Assert.assertEquals(r2.getAlignmentStart(), 100); Assert.assertEquals(r2.getCigarString(), "20S100M"); }
private void assertGoodRead(final SAMRecord read, final ArtificialBAMBuilder bamBuilder) { Assert.assertEquals(read.getReadLength(), bamBuilder.getReadLength()); Assert.assertEquals(read.getReadBases().length, bamBuilder.getReadLength()); Assert.assertEquals(read.getBaseQualities().length, bamBuilder.getReadLength()); Assert.assertTrue(read.getAlignmentStart() >= bamBuilder.getAlignmentStart()); Assert.assertNotNull(read.getReadGroup()); } }
/** * Strip mapping information from a SAMRecord, but preserve it in the 'O' tags if it isn't already set. */ public static void makeReadUnmappedWithOriginalTags(final SAMRecord rec) { if (!hasOriginalMappingInformation(rec)) { rec.setAttribute(SAMTag.OP.name(), rec.getAlignmentStart()); rec.setAttribute(SAMTag.OC.name(), rec.getCigarString()); rec.setAttribute(SAMTag.OF.name(), rec.getFlags()); rec.setAttribute(SAMTag.OR.name(), rec.getReferenceName()); } makeReadUnmapped(rec); }
/** * Strip mapping information from a SAMRecord, but preserve it in the 'O' tags if it isn't already set. */ public static void makeReadUnmappedWithOriginalTags(final SAMRecord rec) { if (!hasOriginalMappingInformation(rec)) { rec.setAttribute(SAMTag.OP.name(), rec.getAlignmentStart()); rec.setAttribute(SAMTag.OC.name(), rec.getCigarString()); rec.setAttribute(SAMTag.OF.name(), rec.getFlags()); rec.setAttribute(SAMTag.OR.name(), rec.getReferenceName()); } makeReadUnmapped(rec); }