Пример #1
0
 @Test
 public void realignAtContigBorderTest() {
   final int contigEnd = header.getSequence(0).getSequenceLength();
   final GATKSAMRecord read =
       ArtificialSAMUtils.createArtificialRead(header, "goodRead", 0, contigEnd - 1, 2);
   read.setCigarString("2M");
   Assert.assertEquals(IndelRealigner.realignmentProducesBadAlignment(read, contigEnd), false);
   read.setCigarString("1M1D1M");
   Assert.assertEquals(IndelRealigner.realignmentProducesBadAlignment(read, contigEnd), true);
 }
Пример #2
0
  /**
   * Creates an empty GATKSAMRecord with the read's header, read group and mate information, but
   * empty (not-null) fields: - Cigar String - Read Bases - Base Qualities
   *
   * <p>Use this method if you want to create a new empty GATKSAMRecord based on another
   * GATKSAMRecord
   *
   * @param read a read to copy the header from
   * @return a read with no bases but safe for the GATK
   */
  public static GATKSAMRecord emptyRead(GATKSAMRecord read) {
    final GATKSAMRecord emptyRead = new GATKSAMRecord(read.getHeader());
    emptyRead.setReferenceIndex(read.getReferenceIndex());
    emptyRead.setAlignmentStart(0);
    emptyRead.setMappingQuality(0);
    // setting read indexing bin last
    emptyRead.setFlags(read.getFlags());
    emptyRead.setMateReferenceIndex(read.getMateReferenceIndex());
    emptyRead.setMateAlignmentStart(read.getMateAlignmentStart());
    emptyRead.setInferredInsertSize(read.getInferredInsertSize());

    emptyRead.setCigarString("");
    emptyRead.setReadBases(new byte[0]);
    emptyRead.setBaseQualities(new byte[0]);

    SAMReadGroupRecord samRG = read.getReadGroup();
    emptyRead.clearAttributes();
    if (samRG != null) {
      GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(samRG);
      emptyRead.setReadGroup(rg);
    }

    GATKBin.setReadIndexingBin(emptyRead, 0);

    return emptyRead;
  }
    private List<PileupElement> makeReads(final int n, final int mapq, final String op) {
      final int readLength = 3;

      final List<PileupElement> elts = new LinkedList<PileupElement>();
      for (int i = 0; i < n; i++) {
        GATKSAMRecord read =
            ArtificialSAMUtils.createArtificialRead(header, "read", 0, 1, readLength);
        read.setReadBases(Utils.dupBytes((byte) 'A', readLength));
        read.setBaseQualities(Utils.dupBytes((byte) 30, readLength));
        read.setCigarString("1M1" + op + "1M");
        read.setMappingQuality(mapq);
        final int baseOffset = op.equals("M") ? 1 : 0;
        final CigarElement cigarElement = read.getCigar().getCigarElement(1);
        elts.add(new PileupElement(read, baseOffset, cigarElement, 1, 0));
      }

      return elts;
    }
  @Test
  public void testRBPMappingQuals() {

    // create a read with high MQ
    final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "read", 0, 1, 10);
    read.setReadBases(Utils.dupBytes((byte) 'A', 10));
    read.setBaseQualities(Utils.dupBytes((byte) 30, 10));
    read.setCigarString("10M");
    read.setMappingQuality(200); // set a MQ higher than max signed byte

    // now create the RBP
    final List<PileupElement> elts = new LinkedList<>();
    elts.add(new PileupElement(read, 0, read.getCigar().getCigarElement(0), 0, 0));
    final Map<String, ReadBackedPileupImpl> pileupsBySample = new HashMap<>();
    pileupsBySample.put("foo", new ReadBackedPileupImpl(loc, elts));
    final ReadBackedPileup pileup = new ReadBackedPileupImpl(loc, pileupsBySample);

    Assert.assertEquals(pileup.getMappingQuals()[0], 200);
  }