// NB: this test should return different results than MarkDuplicatesWithMateCigar
 @Test
 public void testTwoMappedPairsWithSoftClippingFirstOfPairOnly() {
   final AbstractMarkDuplicatesCommandLineProgramTester tester = getTester();
   // NB: no duplicates
   // 5'1: 2, 5'2:46+73M=118
   // 5'1: 2, 5'2:51+68M=118
   tester.addMappedPair(
       0, 12, 46, false, false, "6S42M28S", "3S73M", true, 50); // only add the first one
   // NB: this next record should not be a duplicate in MarkDuplicates
   tester.addMappedPair(
       0, 12, 51, false, false, "6S42M28S", "8S68M", true, 50); // only add the first one
   tester.runTest();
 }
 @Test
 public void testWithBarcodeDuplicate() {
   final AbstractMarkDuplicatesCommandLineProgramTester tester = getTester();
   tester.addMatePair(
       "RUNID:1:1:15993:13361",
       2,
       41212324,
       41212310,
       false,
       false,
       false,
       false,
       "33S35M",
       "19S49M",
       true,
       true,
       false,
       false,
       false,
       DEFAULT_BASE_QUALITY);
   tester.addMatePair(
       "RUNID:2:2:15993:13362",
       2,
       41212324,
       41212310,
       false,
       false,
       true,
       true,
       "33S35M",
       "19S49M",
       true,
       true,
       false,
       false,
       false,
       DEFAULT_BASE_QUALITY);
   final String barcodeTag = "BC";
   for (final SAMRecord record : new IterableAdapter<SAMRecord>(tester.getRecordIterator())) {
     record.setAttribute(barcodeTag, "Barcode1");
   }
   tester.addArg("BARCODE_TAG=" + barcodeTag);
   tester.runTest();
 }
  @Test
  public void testWithIndividualReadBarcodes() {
    final AbstractMarkDuplicatesCommandLineProgramTester tester = getTester();
    final String readNameOne = "RUNID:1:1:15993:13361";
    final String readNameTwo = "RUNID:2:2:15993:13362";
    final String readNameThree = "RUNID:3:3:15993:13362";

    // first two reads have the same barcode (all three), third read has a different barcode for the
    // second end
    tester.addMatePair(
        readNameOne,
        2,
        41212324,
        41212310,
        false,
        false,
        false,
        false,
        "33S35M",
        "19S49M",
        true,
        true,
        false,
        false,
        false,
        DEFAULT_BASE_QUALITY);
    tester.addMatePair(
        readNameTwo,
        2,
        41212324,
        41212310,
        false,
        false,
        true,
        true,
        "33S35M",
        "19S49M",
        true,
        true,
        false,
        false,
        false,
        DEFAULT_BASE_QUALITY); // same barcode as the first
    tester.addMatePair(
        readNameThree,
        2,
        41212324,
        41212310,
        false,
        false,
        false,
        false,
        "33S35M",
        "19S49M",
        true,
        true,
        false,
        false,
        false,
        DEFAULT_BASE_QUALITY);

    final String barcodeTag = "BC";
    final String readOneBarcodeTag =
        "BX"; // want the same tag as the second end, since this is allowed
    final String readTwoBarcodeTag = "BX";
    for (final SAMRecord record : new IterableAdapter<SAMRecord>(tester.getRecordIterator())) {
      record.setAttribute(barcodeTag, "Barcode1"); // same barcode
      if (record.getFirstOfPairFlag()) { // always the same value for the first end
        record.setAttribute(readOneBarcodeTag, "readOne1");
      } else { // second end
        if (record.getReadName().equals(readNameOne) || record.getReadName().equals(readNameTwo)) {
          record.setAttribute(readTwoBarcodeTag, "readTwo1");
        } else if (record.getReadName().equals(readNameThree)) {
          record.setAttribute(readTwoBarcodeTag, "readTwo2");
        }
      }
    }
    tester.addArg("BARCODE_TAG=" + barcodeTag);
    tester.addArg("READ_ONE_BARCODE_TAG=" + readOneBarcodeTag);
    tester.addArg("READ_TWO_BARCODE_TAG=" + readTwoBarcodeTag);

    tester.runTest();
  }
  @Test
  public void testWithBarcodeComplex() {
    final AbstractMarkDuplicatesCommandLineProgramTester tester = getTester();
    final String readNameOne = "RUNID:1:1:15993:13361";
    final String readNameTwo = "RUNID:2:2:15993:13362";
    final String readNameThree = "RUNID:3:3:15993:13362";

    // first two reads have the same barcode, third read has a different barcode
    tester.addMatePair(
        readNameOne,
        2,
        41212324,
        41212310,
        false,
        false,
        false,
        false,
        "33S35M",
        "19S49M",
        true,
        true,
        false,
        false,
        false,
        DEFAULT_BASE_QUALITY);
    tester.addMatePair(
        readNameTwo,
        2,
        41212324,
        41212310,
        false,
        false,
        true,
        true,
        "33S35M",
        "19S49M",
        true,
        true,
        false,
        false,
        false,
        DEFAULT_BASE_QUALITY); // same barcode as the first
    tester.addMatePair(
        readNameThree,
        2,
        41212324,
        41212310,
        false,
        false,
        false,
        false,
        "33S35M",
        "19S49M",
        true,
        true,
        false,
        false,
        false,
        DEFAULT_BASE_QUALITY);

    final String barcodeTag = "BC";
    for (final SAMRecord record : new IterableAdapter<SAMRecord>(tester.getRecordIterator())) {
      if (record.getReadName().equals(readNameOne) || record.getReadName().equals(readNameTwo)) {
        record.setAttribute(barcodeTag, "Barcode1");
      } else if (record.getReadName().equals(readNameThree)) {
        record.setAttribute(barcodeTag, "Barcode2");
      }
    }
    tester.addArg("BARCODE_TAG=" + barcodeTag);
    tester.runTest();
  }