org.broadinstitute.gatk.utils.sam.GATKSAMRecord.getBaseQualities()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中org.broadinstitute.gatk.utils.sam.GATKSAMRecord.getBaseQualities()方法的一些代码示例,展示了GATKSAMRecord.getBaseQualities()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GATKSAMRecord.getBaseQualities()方法的具体详情如下:
包路径:org.broadinstitute.gatk.utils.sam.GATKSAMRecord
类名称:GATKSAMRecord
方法名:getBaseQualities

GATKSAMRecord.getBaseQualities介绍

暂无

代码示例

代码示例来源:origin: broadgsa/gatk-protected

private boolean isLowQualityBase( final GATKSAMRecord read, final int offset ) {
  return read.getBaseQualities()[offset] < minimumQToUse;
}

代码示例来源:origin: broadgsa/gatk-protected

/**
 * Get the element for the given read at the given reference position
 *
 * @param read     the read
 * @param refLoc   the reference position
 * @return a Double representing the element to be used in the rank sum test, or null if it should not be used
 */
@Override
protected Double getElementForRead(final GATKSAMRecord read, final int refLoc) {
  return (double) read.getBaseQualities()[ReadUtils.getReadCoordinateForReferenceCoordinateUpToEndOfRead(read, refLoc, ReadUtils.ClippingTail.RIGHT_TAIL)];
}

代码示例来源:origin: broadgsa/gatk

/**
 * Given a read, outputs the base qualities in a string format
 *
 * @param read the read
 * @return a string representation of the base qualities
 */
public static String convertReadQualToString(GATKSAMRecord read) {
  return convertReadQualToString(read.getBaseQualities());
}

代码示例来源:origin: broadgsa/gatk

/**
 * Get the base quality score of the base at this aligned position on the genome
 * @return a phred-scaled quality score as a byte
 */
public byte getQual() {
  return isDeletion() ? DELETION_QUAL : read.getBaseQualities()[offset];
}

代码示例来源:origin: broadgsa/gatk

protected static void checkForMisencodedQuals(final GATKSAMRecord read) {
    // sample reads randomly for checking
    if ( ++currentReadCounter >= samplingFrequency ) {
      currentReadCounter = 0;

      final byte[] quals = read.getBaseQualities();
      for ( final byte qual : quals ) {
        if ( qual > QualityUtils.MAX_REASONABLE_Q_SCORE )
          throw new UserException.MisencodedBAM(read, "we encountered an extremely high quality score of " + (int)qual);
      }
    }
  }
}

代码示例来源:origin: broadgsa/gatk-protected

@Override
protected Double getElementForRead(final GATKSAMRecord read, final int refLoc) {
  return (double)read.getBaseQualities()[ReadUtils.getReadCoordinateForReferenceCoordinateUpToEndOfRead(read, refLoc, ReadUtils.ClippingTail.RIGHT_TAIL)];
}

代码示例来源:origin: broadgsa/gatk

/**
 * Default utility to query the base insertion quality of a read. If the read doesn't have one, it creates an array of default qualities (currently Q45)
 * and assigns it to the read.
 *
 * @return the base insertion quality array
 */
public byte[] getBaseInsertionQualities() {
  byte [] quals = getExistingBaseInsertionQualities();
  if( quals == null ) {
    quals = new byte[getBaseQualities().length];
    Arrays.fill(quals, DEFAULT_INSERTION_DELETION_QUAL); // Some day in the future when base insertion and base deletion quals exist the samtools API will
                    // be updated and the original quals will be pulled here, but for now we assume the original quality is a flat Q45
  }
  return quals;
}

代码示例来源:origin: broadgsa/gatk-protected

protected Double getBaseQualityForRead(final GATKSAMRecord read, final int refLoc) {
  return (double)read.getBaseQualities()[ReadUtils.getReadCoordinateForReferenceCoordinateUpToEndOfRead(read, refLoc, ReadUtils.ClippingTail.RIGHT_TAIL)];
}

代码示例来源:origin: broadgsa/gatk

/**
 * Default utility to query the base deletion quality of a read. If the read doesn't have one, it creates an array of default qualities (currently Q45)
 * and assigns it to the read.
 *
 * @return the base deletion quality array
 */
public byte[] getBaseDeletionQualities() {
  byte[] quals = getExistingBaseDeletionQualities();
  if( quals == null ) {
    quals = new byte[getBaseQualities().length];
    Arrays.fill(quals, DEFAULT_INSERTION_DELETION_QUAL);  // Some day in the future when base insertion and base deletion quals exist the samtools API will
                    // be updated and the original quals will be pulled here, but for now we assume the original quality is a flat Q45
  }
  return quals;
}

代码示例来源:origin: broadgsa/gatk

protected static GATKSAMRecord fixMisencodedQuals(final GATKSAMRecord read) {
  final byte[] quals = read.getBaseQualities();
  for ( int i = 0; i < quals.length; i++ ) {
    quals[i] -= encodingFixValue;
    if ( quals[i] < 0 )
      throw new UserException.BadInput("while fixing mis-encoded base qualities we encountered a read that was correctly encoded; we cannot handle such a mixture of reads so unfortunately the BAM must be fixed with some other tool");
  }
  read.setBaseQualities(quals);
  return read;
}

代码示例来源:origin: broadgsa/gatk

public void addAlignment(GATKSAMRecord read) {
  output.println("@" + read.getReadName());
  if (read.getReadNegativeStrandFlag()) {
    output.println(ReadUtils.getBasesReverseComplement(read));
    output.println("+");
    output.println(ReadUtils.convertReadQualToString(invertQuals(read.getBaseQualities())));
  } else {
    output.println(ReadUtils.convertReadBasesToString(read));
    output.println("+");
    output.println(ReadUtils.convertReadQualToString(read));
  }
}

代码示例来源:origin: broadgsa/gatk

private GATKSAMRecord modifyBaseQualities(final GATKSAMRecord read, final int startOffset, final int length) throws Exception {
  final GATKSAMRecord readWithLowQuals = (GATKSAMRecord)read.clone();
  final byte[] withLowQuals = Arrays.copyOf(read.getBaseQualities(), read.getBaseQualities().length);
  for ( int i = startOffset; i < startOffset + length; i++ )
    withLowQuals[i] = (byte)(read.getBaseQualities()[i] + (i % 2 == 0 ? -1 : 0));
  readWithLowQuals.setBaseQualities(withLowQuals);
  return readWithLowQuals;
}

代码示例来源:origin: broadgsa/gatk

@Override
public void recordValues(final GATKSAMRecord read, final ReadCovariates values) {
  final byte[] baseQualities = read.getBaseQualities();
  final byte[] baseInsertionQualities = read.getBaseInsertionQualities();
  final byte[] baseDeletionQualities = read.getBaseDeletionQualities();
  for (int i = 0; i < baseQualities.length; i++) {
    values.addCovariate((int)baseQualities[i], (int)baseInsertionQualities[i], (int)baseDeletionQualities[i], i);
  }
}

代码示例来源:origin: broadgsa/gatk

public byte[] getBaseQualities( final EventType errorModel ) {
  switch( errorModel ) {
    case BASE_SUBSTITUTION:
      return getBaseQualities();
    case BASE_INSERTION:
      return getBaseInsertionQualities();
    case BASE_DELETION:
      return getBaseDeletionQualities();
    default:
      throw new ReviewedGATKException("Unrecognized Base Recalibration type: " + errorModel );
  }
}

代码示例来源:origin: broadgsa/gatk-protected

private void performBatchAdditions(final List<GATKSAMRecord> reads, final List<Haplotype> haplotypes, Map<GATKSAMRecord,byte[]> gcp) {
  for(final GATKSAMRecord read : reads){
    final byte[] readBases = read.getReadBases();
    final byte[] readQuals = read.getBaseQualities();
    final byte[] readInsQuals = read.getBaseInsertionQualities();
    final byte[] readDelQuals = read.getBaseDeletionQualities();
    final byte[] overallGCP = gcp.get(read);
    batchAdd(haplotypes, readBases, readQuals, readInsQuals, readDelQuals, overallGCP);
  }
}

代码示例来源:origin: broadgsa/gatk

@Test(enabled = !DEBUG, dataProvider = "AdjustFragmentsTest")
  public void testAdjustingTwoReads(final GATKSAMRecord read1, final GATKSAMRecord read2, final int overlapSize) {
    FragmentUtils.adjustQualsOfOverlappingPairedFragments(read1, read2);

    for ( int i = 0; i < read1.getReadLength() - overlapSize; i++ )
      Assert.assertEquals(read1.getBaseQualities()[i], highQuality);
    for ( int i = read1.getReadLength() - overlapSize; i < read1.getReadLength(); i++ )
      Assert.assertEquals(read1.getBaseQualities()[i], overlappingQuality);

    for ( int i = 0; i < overlapSize; i++ )
      Assert.assertEquals(read2.getBaseQualities()[i], overlappingQuality);
    for ( int i = overlapSize; i < read2.getReadLength(); i++ )
      Assert.assertEquals(read2.getBaseQualities()[i], highQuality);
  }
}

代码示例来源:origin: broadgsa/gatk

@Test(enabled = true)
public void testFixBadQuals() {
  final GATKSAMRecord read = createRead(false);
  final GATKSAMRecord fixedRead = MisencodedBaseQualityReadTransformer.fixMisencodedQuals(read);
  for ( int i = 0; i < fixedQuals.length; i++ )
    Assert.assertEquals(fixedQuals[i], fixedRead.getBaseQualities()[i]);
}

代码示例来源:origin: broadgsa/gatk

private void assertNoLowQualBases(GATKSAMRecord read, byte low_qual) {
  if (!read.isEmpty()) {
    byte[] quals = read.getBaseQualities();
    for (int i = 0; i < quals.length; i++)
      Assert.assertFalse(quals[i] <= low_qual, String.format("Found low qual (%d) base after hard clipping. Position: %d -- %s", low_qual, i, read.getCigarString()));
  }
}

代码示例来源:origin: broadgsa/gatk-protected

private void writeDebugLikelihoods(final GATKSAMRecord processedRead, final Haplotype haplotype, final double log10l){
  likelihoodsStream.printf("%s %s %s %s %s %s %f%n",
        haplotype.getBaseString(),
        new String(processedRead.getReadBases() ),
        SAMUtils.phredToFastq(processedRead.getBaseQualities()),
        SAMUtils.phredToFastq(processedRead.getBaseInsertionQualities() ),
        SAMUtils.phredToFastq(processedRead.getBaseDeletionQualities() ),
        SAMUtils.phredToFastq(constantGCP),
        log10l);
}

代码示例来源:origin: broadgsa/gatk-protected

/**
 * Loads the read that is going to be evaluated in following calls to {@link #calculateLocalLikelihoods}.
 *
 * @param read the target read.
 * @throws NullPointerException if {@code read} is null.
 */
@Override
public void loadRead(final GATKSAMRecord read) {
  loadRead(read.getReadBases(),read.getBaseQualities(),read.getBaseInsertionQualities(),read.getBaseDeletionQualities(),read.getMappingQuality());
}

相关文章

微信公众号

最新文章

更多

GATKSAMRecord类方法