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

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

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

GATKSAMRecord.getReadLength介绍

暂无

代码示例

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

/**
 * Are we on the right edge?  I.e., is the current state off the right of the alignment?
 * @return true if off the right edge, false if otherwise
 */
public boolean isRightEdge() {
  return readOffset == read.getReadLength();
}

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

private int findMaxReadLength(final GATKSAMRecord ... reads) {
  int max = 0;
  for (final GATKSAMRecord read : reads) {
    final int readLength = read.getReadLength();
    if (max < readLength)
      max = readLength;
  }
  return max;
}

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

protected int findMaxReadLength(final List<GATKSAMRecord> reads) {
  int listMaxReadLength = 0;
  for(GATKSAMRecord read : reads){
    final int readLength = read.getReadLength();
    if( readLength > listMaxReadLength ) { listMaxReadLength = readLength; }
  }
  return listMaxReadLength;
}

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

/**
 * Create a BAQ style array that indicates no alignment uncertainty
 * @param read the read for which we want a BAQ array
 * @return a BAQ-style non-null byte[] counting NO_BAQ_UNCERTAINTY values
 * // TODO -- could be optimized avoiding this function entirely by using this inline if the calculation code above
 */
protected  static byte[] flatBAQArray(final GATKSAMRecord read) {
  final byte[] baq = new byte[read.getReadLength()];
  Arrays.fill(baq, NO_BAQ_UNCERTAINTY);
  return baq;
}

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

private Map<GATKSAMRecord, byte[]> buildGapContinuationPenalties(final List<GATKSAMRecord> processedReads, final byte gcp) {
  final Map<GATKSAMRecord,byte[]> result = new HashMap<>(processedReads.size());
  for (final GATKSAMRecord read : processedReads) {
    final byte[] readGcpArray = new byte[read.getReadLength()];
    Arrays.fill(readGcpArray,gcp);
    result.put(read,readGcpArray);
  }
  return result;
}

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

private boolean readIsPoorlyModelled(final int sampleIndex, final int readIndex, final GATKSAMRecord read, final double maxErrorRatePerBase) {
  final double maxErrorsForRead = Math.min(2.0, Math.ceil(read.getReadLength() * maxErrorRatePerBase));
  final double log10QualPerBase = -4.0;
  final double log10MaxLikelihoodForTrueAllele = maxErrorsForRead * log10QualPerBase;
  final int alleleCount = alleles.alleleCount();
  final double[][] sampleValues = valuesBySampleIndex[sampleIndex];
  for (int a = 0; a < alleleCount; a++)
    if (sampleValues[a][readIndex] >= log10MaxLikelihoodForTrueAllele)
      return false;
  return true;
}

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

/**
 * @see #getMismatchCount(GATKSAMRecord, byte[], int, int, int) with startOnRead == 0 and nReadBases == read.getReadLength()
 */
public static MismatchCount getMismatchCount(GATKSAMRecord r, byte[] refSeq, int refIndex) {
  return getMismatchCount(r, refSeq, refIndex, 0, r.getReadLength());
}

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

@Override
public Integer map(final ReferenceContext referenceContext,final GATKSAMRecord samRecord,final RefMetaDataTracker RefMetaDataTracker) {
  final int length = Math.abs(samRecord.getReadLength());
  final SAMReadGroupRecord rg = samRecord.getReadGroup();
  increment(table,length, rg);
  return null;
}

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

/**
 * Whether the read is anchored perfectly, there are no non-aligned bases.
 *
 * @return {@code true} iff so.
 */
public boolean isPerfectAnchoring() {
  return hasValidAnchors() && leftAnchorIndex == 0 && rightAnchorIndex == read.getReadLength() - graphMap.kmerSize &&
      !leftAnchorVertex.hasAmbiguousSequence();
}

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

/**
 *
 * @param read  a read containing the variant
 * @return  number of non-hard clipped, aligned bases (excluding low quality bases at either end)
 */
//TODO: this is bizarre -- this code counts hard clips, but then subtracts them from the read length, which already doesn't count hard clips
public static int getNumAlignedBases(final GATKSAMRecord read) {
  return read.getReadLength() - getNumClippedBasesAtStart(read) - getNumClippedBasesAtEnd(read);
}

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

private Set<GATKSAMRecord> filterNonPassingReads( final ActiveRegion activeRegion ) {
  final Set<GATKSAMRecord> readsToRemove = new LinkedHashSet<>();
  for( final GATKSAMRecord rec : activeRegion.getReads() ) {
    if( rec.getReadLength() < READ_LENGTH_FILTER_THRESHOLD || rec.getMappingQuality() < READ_QUALITY_FILTER_THRESHOLD || (!isBadMateFilterDisabled && BadMateFilter.hasBadMate(rec)) || (keepRG != null && !rec.getReadGroup().getId().equals(keepRG)) ) {
      readsToRemove.add(rec);
    }
  }
  activeRegion.removeAll( readsToRemove );
  return readsToRemove;
}

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

/**
 * Should we clip a downstream portion of a read because it spans off the end of a haplotype?
 *
 * @param read               the read in question
 * @param refWindowStop      the end of the reference window
 * @return true if the read needs to be clipped, false otherwise
 */
protected static boolean mustClipDownstream(final GATKSAMRecord read, final int refWindowStop) {
  return ( !read.isEmpty() && read.getSoftStart() < refWindowStop && read.getSoftStart() + read.getReadLength() - 1 > refWindowStop );
}

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

@Test(dataProvider = "ClippedReadLengthData", enabled = !DEBUG)
public void testHardClipReadLengthIsRight(final int originalReadLength, final int nToClip) {
  GATKSAMRecord read = ReadClipperTestUtils.makeReadFromCigar(originalReadLength + "M", 0);
  read.getReadLength(); // provoke the caching of the read length
  final int expectedReadLength = originalReadLength - nToClip;
  GATKSAMRecord clipped = ReadClipper.hardClipByReadCoordinates(read, 0, nToClip - 1);
  Assert.assertEquals(clipped.getReadLength(), expectedReadLength,
      String.format("Clipped read length %d with cigar %s not equal to the expected read length %d after clipping %d bases from the left from a %d bp read with cigar %s",
          clipped.getReadLength(), clipped.getCigar(), expectedReadLength, nToClip, read.getReadLength(), read.getCigar()));
}

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

@Override
public void recordValues(final GATKSAMRecord read, final ReadCovariates values) {
  final String readGroupId = readGroupValueFromRG(read.getReadGroup());
  final int key = keyForReadGroup(readGroupId);
  final int l = read.getReadLength();
  for (int i = 0; i < l; i++)
    values.addCovariate(key, key, key, i);
}

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

/**
 * A unit test that creates an artificial read for testing some code that uses reads
 */
@Test()
public void testWithARead() {
  final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(seq.getSequenceDictionary());
  final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 1, 10);
  Assert.assertEquals(read.getReadLength(), 10);
  // TODO -- add some tests here using read
}

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

private GATKSAMRecord makeRead(final String baseString) {
  final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 1, 10);
  final byte[] bases = baseString.getBytes();
  read.setReadBases(bases.clone());
  read.setBaseQualities(Utils.dupBytes((byte)30, read.getReadLength()));
  return read;
}

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

@Test(enabled = true)
  public void testMaxCyclePasses() {
    int readLength = RAC.MAXIMUM_CYCLE_VALUE;
    GATKSAMRecord read = ReadUtils.createRandomRead(readLength);
    read.setReadPairedFlag(true);
    read.setReadGroup(new GATKSAMReadGroupRecord("MY.ID"));
    read.getReadGroup().setPlatform("illumina");

    ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1);
    covariate.recordValues(read, readCovariates);
  }
}

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

@Test(enabled = true, expectedExceptions={UserException.class})
public void testMoreThanMaxCycleFails() {
  int readLength = RAC.MAXIMUM_CYCLE_VALUE + 1;
  GATKSAMRecord read = ReadUtils.createRandomRead(readLength);
  read.setReadPairedFlag(true);
  read.setReadGroup(new GATKSAMReadGroupRecord("MY.ID"));
  read.getReadGroup().setPlatform("illumina");
  ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1);
  covariate.recordValues(read, readCovariates);
}

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

private static void runTest(final GATKSAMReadGroupRecord rg, final String expected, final ReadGroupCovariate covariate) {
  GATKSAMRecord read = ReadUtils.createRandomRead(10);
  read.setReadGroup(rg);
  ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1);
  covariate.recordValues(read, readCovariates);
  verifyCovariateArray(readCovariates.getMismatchesKeySet(), expected, covariate);
}

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

@Test(enabled = true)
public void testSimpleContexts() {
  GATKSAMRecord read = ReadUtils.createRandomRead(1000);
  GATKSAMRecord clippedRead = ReadClipper.clipLowQualEnds(read, RAC.LOW_QUAL_TAIL, ClippingRepresentation.WRITE_NS);
  ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1);
  covariate.recordValues(read, readCovariates);
  verifyCovariateArray(readCovariates.getMismatchesKeySet(), RAC.MISMATCHES_CONTEXT_SIZE, clippedRead, covariate);
  verifyCovariateArray(readCovariates.getInsertionsKeySet(), RAC.INDELS_CONTEXT_SIZE, clippedRead, covariate);
  verifyCovariateArray(readCovariates.getDeletionsKeySet(),  RAC.INDELS_CONTEXT_SIZE,  clippedRead, covariate);
}

相关文章

微信公众号

最新文章

更多

GATKSAMRecord类方法