@Override public int getInferredInsertSize() { return record.getInferredInsertSize(); }
@Override public int getInsertSize(SAMRecord alignment) { return alignment.getInferredInsertSize(); }
@Override public AlignmentFilters<SAMRecord> addInsertSizeFilter(int maxInsertSize) { filters.add(samRecord -> samRecord.getInferredInsertSize() <= maxInsertSize); return this; }
public boolean filterOut(SAMRecord record) { return (record.getReadPairedFlag() && (record.getInferredInsertSize() > maxInsertSize || record.getInferredInsertSize() < -1*maxInsertSize)); } }
@Override public boolean filterOut(final SAMRecord rec) { if (!rec.getReadPairedFlag()) return true; final int ins = Math.abs(rec.getInferredInsertSize()); return ins < minInsertSize || ins > maxInsertSize; }
private static Integer stratifyInsertLength(final SAMRecord sam) { return Math.min( sam.getReadLength() * 10, Math.abs(sam.getInferredInsertSize())); }
private static Integer stratifyInsertLength(final SAMRecord sam) { return Math.min( sam.getReadLength() * 10, Math.abs(sam.getInferredInsertSize())); }
@Override public boolean filterOut(final SAMRecord rec) { if (!rec.getReadPairedFlag()) return true; final int ins = Math.abs(rec.getInferredInsertSize()); return ins < minInsertSize || ins > maxInsertSize; }
@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); }
@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); }
@Override public int getInferredInsertSize() { if (!initializedFields.contains(LazyField.INFERRED_INSERT_SIZE)) { setInferredInsertSize(getInferredInsertSizeImpl()); } return super.getInferredInsertSize(); }
@Override public int getInferredInsertSize() { if (!initializedFields.contains(LazyField.INFERRED_INSERT_SIZE)) { setInferredInsertSize(getInferredInsertSizeImpl()); } return super.getInferredInsertSize(); }
/** * Checks whether the given read is part of a chimeric pair. * Note that this method returns false if the read is unpaired or if either end of the pair is unmapped. * * @param rec the read * @param maxInsertSize max insert size to be considered non-chimeric * @param expectedOrientations set of orientations that are not chimeric; must not ne null * @return true if this record is part of a chimeric read pair, false otherwise */ public static boolean isChimeric(final SAMRecord rec, final int maxInsertSize, final Set<PairOrientation> expectedOrientations) { return isMappedPair(rec) && // the read pair needs to be mapped and... (Math.abs(rec.getInferredInsertSize()) > maxInsertSize || // either far apart on the same contig !rec.getReferenceIndex().equals(rec.getMateReferenceIndex()) || // or on different contigs !matchesExpectedOrientations(rec, expectedOrientations)); // or in unexpected orientations }
public static boolean iSizeTooBigToMove(SAMRecord read, int maxInsertSizeForMovingReadPairs) { return ( read.getReadPairedFlag() && ! read.getMateUnmappedFlag() && !read.getReferenceName().equals(read.getMateReferenceName()) ) // maps to different chromosomes || Math.abs(read.getInferredInsertSize()) > maxInsertSizeForMovingReadPairs; // we won't try to move such a read }
public int compare(final SAMRecord samRecord1, final SAMRecord samRecord2) { int cmp = fileOrderCompare(samRecord1, samRecord2); // Note: secondary sort order does not match SAMRecordCoordinateComparator if (cmp != 0) return cmp; cmp = samRecord1.getReadName().compareTo(samRecord2.getReadName()); if (cmp != 0) return cmp; cmp = compareInts(samRecord1.getFlags(), samRecord2.getFlags()); if (cmp != 0) return cmp; cmp = compareInts(samRecord1.getMappingQuality(), samRecord2.getMappingQuality()); if (cmp != 0) return cmp; cmp = compareInts(samRecord1.getInferredInsertSize(), samRecord2.getInferredInsertSize()); return cmp; }
@Override public void acceptRecord(final SAMRecord record, final ReferenceSequence refSeq) { if (!record.getReadPairedFlag() || record.getReadUnmappedFlag() || record.getMateUnmappedFlag() || record.getFirstOfPairFlag() || record.isSecondaryOrSupplementary() || (record.getDuplicateReadFlag() && !this.includeDuplicates) || record.getInferredInsertSize() == 0) { return; } super.acceptRecord(record, refSeq); }
@Override public void acceptRecord(final SAMRecord record, final ReferenceSequence refSeq) { if (!record.getReadPairedFlag() || record.getReadUnmappedFlag() || record.getMateUnmappedFlag() || record.getFirstOfPairFlag() || record.isSecondaryOrSupplementary() || (record.getDuplicateReadFlag() && !this.includeDuplicates) || record.getInferredInsertSize() == 0) { return; } super.acceptRecord(record, refSeq); }
/** * Sets mate pair information appropriately on a supplemental SAMRecord (e.g. from a split alignment) * using the primary alignment of the read's mate. * @param supplemental a supplemental alignment for the mate pair of the primary supplied * @param matePrimary the primary alignment of the the mate pair of the supplemental */ public static void setMateInformationOnSupplementalAlignment( final SAMRecord supplemental, final SAMRecord matePrimary) { supplemental.setMateReferenceIndex(matePrimary.getReferenceIndex()); supplemental.setMateAlignmentStart(matePrimary.getAlignmentStart()); supplemental.setMateNegativeStrandFlag(matePrimary.getReadNegativeStrandFlag()); supplemental.setMateUnmappedFlag(matePrimary.getReadUnmappedFlag()); supplemental.setInferredInsertSize(-matePrimary.getInferredInsertSize()); }
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 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) {