示例#1
0
  /**
   * Construct a set of SAM bitwise flags from a GATKRead
   *
   * @param read read from which to construct the flags
   * @return SAM-compliant set of bitwise flags reflecting the properties in the given read
   */
  public static int getSAMFlagsForRead(final GATKRead read) {
    int samFlags = 0;

    if (read.isPaired()) {
      samFlags |= SAM_READ_PAIRED_FLAG;
    }
    if (read.isProperlyPaired()) {
      samFlags |= SAM_PROPER_PAIR_FLAG;
    }
    if (read.isUnmapped()) {
      samFlags |= SAM_READ_UNMAPPED_FLAG;
    }
    if (read.isPaired() && read.mateIsUnmapped()) {
      samFlags |= SAM_MATE_UNMAPPED_FLAG;
    }
    if (!read.isUnmapped() && read.isReverseStrand()) {
      samFlags |= SAM_READ_STRAND_FLAG;
    }
    if (read.isPaired() && !read.mateIsUnmapped() && read.mateIsReverseStrand()) {
      samFlags |= SAM_MATE_STRAND_FLAG;
    }
    if (read.isFirstOfPair()) {
      samFlags |= SAM_FIRST_OF_PAIR_FLAG;
    }
    if (read.isSecondOfPair()) {
      samFlags |= SAM_SECOND_OF_PAIR_FLAG;
    }
    if (read.isSecondaryAlignment()) {
      samFlags |= SAM_NOT_PRIMARY_ALIGNMENT_FLAG;
    }
    if (read.failsVendorQualityCheck()) {
      samFlags |= SAM_READ_FAILS_VENDOR_QUALITY_CHECK_FLAG;
    }
    if (read.isDuplicate()) {
      samFlags |= SAM_DUPLICATE_READ_FLAG;
    }
    if (read.isSupplementaryAlignment()) {
      samFlags |= SAM_SUPPLEMENTARY_ALIGNMENT_FLAG;
    }

    return samFlags;
  }