Java Code Examples for htsjdk.samtools.SAMRecord#isSecondaryAlignment()

The following examples show how to use htsjdk.samtools.SAMRecord#isSecondaryAlignment() . 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: SamSequence.java    From rtg-tools with BSD 2-Clause "Simplified" License 6 votes vote down vote up
static byte getFlags(SAMRecord record) {
  byte flags = 0;
  if (record.getReadPairedFlag()) {
    flags ^= READ_PAIRED_FLAG;
    if (record.getFirstOfPairFlag()) {
      flags ^= FIRST_OF_PAIR_FLAG;
    }
  }
  if (record.getReadNegativeStrandFlag()) {
    flags ^= READ_STRAND_FLAG;
  }
  if (record.isSecondaryAlignment()) {
    flags ^= NOT_PRIMARY_ALIGNMENT_FLAG;
  }
  return flags;
}
 
Example 2
Source File: OverlappingReadsErrorCalculator.java    From picard with MIT License 6 votes vote down vote up
private boolean areReadsMates(final SAMRecord read1, final SAMRecord read2) {
    // must have same name
    return (read1.getReadName().equals(read2.getReadName()) &&
            // must be paired
            read1.getReadPairedFlag() &&
            // one must be first while the other is not
            read1.getFirstOfPairFlag() != read2.getFirstOfPairFlag() &&
            // one must be second while the other is not
            read1.getSecondOfPairFlag() != read2.getSecondOfPairFlag() &&
            // read1 must be mapped
            !read1.getReadUnmappedFlag() &&
            // read2 must be mapped
            !read2.getReadUnmappedFlag() &&
            // read1 must be non-secondary
            !read1.isSecondaryAlignment() &&
            // read2 must be non-secondary
            !read2.isSecondaryAlignment() &&
            // read1 mate position must agree with read2's position
            read1.getMateAlignmentStart() == read2.getAlignmentStart() &&
            // read1 mate reference must agree with read2's reference
            read1.getMateReferenceIndex().equals(read2.getReferenceIndex())
    );
}
 
Example 3
Source File: BamSlicer.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
private boolean passesFilters(@NotNull final SAMRecord record)
{
    if(record.getMappingQuality() < mMinMappingQuality || record.getReadUnmappedFlag())
        return false;

    if(mDropSupplementaries && (record.getSupplementaryAlignmentFlag() || record.isSecondaryAlignment()))
        return false;

    if(mDropDuplicates && record.getDuplicateReadFlag())
        return false;

    return true;
}
 
Example 4
Source File: BamFragmentAllocator.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
private void processSamRecord(@NotNull final SAMRecord record)
{
    // to avoid double-processing of reads overlapping 2 (or more) gene collections, only process them if they start in this
    // gene collection or its preceding non-genic region
    if(!positionWithin(record.getStart(), mValidReadStartRegion[SE_START], mValidReadStartRegion[SE_END]))
        return;

    if(record.isSecondaryAlignment())
        return;

    if(mDuplicateTracker.checkDuplicates(record))
    {
        if(mConfig.DropDuplicates)
        {
            if(record.getFirstOfPairFlag())
                mCurrentGenes.addCount(DUPLICATE, 1);

            return;
        }

        // optimised processing for enriched genes
        if(checkDuplicateEnrichedReads(record))
        {
            ++mTotalBamReadCount;
            ++mGeneReadCount;
            return;
        }
    }

    ++mTotalBamReadCount;
    ++mGeneReadCount;

    processRead(ReadRecord.from(record));
}
 
Example 5
Source File: DuplicateSamFilter.java    From rtg-tools with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean acceptRecord(SAMRecord rec) {
  if (rec == null || rec.getReadName() == null) {
    return false;
  }
  if (!rec.isSecondaryAlignment()) {
    return true;
  }
  final long hash = internalHash(rec.getReadName(), !rec.getReadPairedFlag() || rec.getFirstOfPairFlag());
  if (mReadNameSet.contains(hash)) {
    return false;
  }
  mReadNameSet.add(hash);
  return true;
}