本文整理了Java中org.broadinstitute.gatk.utils.Utils.dupBytes()
方法的一些代码示例,展示了Utils.dupBytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.dupBytes()
方法的具体详情如下:
包路径:org.broadinstitute.gatk.utils.Utils
类名称:Utils
方法名:dupBytes
暂无
代码示例来源:origin: broadgsa/gatk-protected
PairHMMTestData(String ref, String nextRef, String read, final byte qual) {
this.ref = ref;
this.nextRef = nextRef;
this.read = read;
this.baseQuals = this.insQuals = this.delQuals = Utils.dupBytes(qual, read.length());
this.gcp = Utils.dupBytes((byte)10, read.length());
this.log10l = -1;
this.newRead = true;
}
代码示例来源:origin: broadgsa/gatk-protected
private double testHaplotypeIndexingCalc(final PairHMM hmm, final String hap, final String nextHap, final String read, final int hapStart, final boolean recache) {
final byte[] readBases = read.getBytes();
// if not peaking ahead to capture info for a future cache run, the next haplotype will be null, and this should be passed to HMM
final byte[] nextHapBases = nextHap == null ? null : nextHap.getBytes();
final byte[] baseQuals = Utils.dupBytes((byte)30, readBases.length);
final byte[] insQuals = Utils.dupBytes((byte)45, readBases.length);
final byte[] delQuals = Utils.dupBytes((byte)40, readBases.length);
final byte[] gcp = Utils.dupBytes((byte)10, readBases.length);
double d = hmm.computeReadLikelihoodGivenHaplotypeLog10(hap.getBytes(), readBases, baseQuals, insQuals, delQuals, gcp, recache, nextHapBases);
Assert.assertTrue(MathUtils.goodLog10Probability(d), "Likelihoods = " + d + " was bad for read " + read + " and ref " + hap + " with hapStart " + hapStart);
return d;
}
代码示例来源:origin: broadgsa/gatk-protected
@Test(enabled = true, expectedExceptions = IllegalStateException.class, dataProvider = "UninitializedHMMs")
public void testNoInitializeCall(final PairHMM hmm) {
byte[] readBases = "A".getBytes();
byte[] refBases = "AT".getBytes();
byte[] baseQuals = Utils.dupBytes((byte)30, readBases.length);
// didn't call initialize => should exception out
double d = hmm.computeReadLikelihoodGivenHaplotypeLog10( refBases, readBases,
baseQuals, baseQuals, baseQuals, baseQuals, true, null);
}
代码示例来源:origin: broadgsa/gatk-protected
@Test(dataProvider = "PoorlyModelledReadData")
public void testPoorlyModelledRead(final int readLen, final double maxErrorRatePerBase, final boolean expected, final List<Double> log10likelihoods) {
final byte[] bases = Utils.dupBytes((byte)'A', readLen);
final byte[] quals = Utils.dupBytes((byte) 40, readLen);
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(bases, quals, readLen + "M");
final PerReadAlleleLikelihoodMap map = new PerReadAlleleLikelihoodMap();
final boolean actual = map.readIsPoorlyModelled(read, log10likelihoods, maxErrorRatePerBase);
Assert.assertEquals(actual, expected);
}
代码示例来源:origin: broadgsa/gatk-protected
@Test(enabled = true, expectedExceptions = IllegalArgumentException.class, dataProvider = "JustHMMProvider")
public void testHapTooLong(final PairHMM hmm) {
byte[] readBases = "AAA".getBytes();
byte[] refBases = "AAAT".getBytes();
byte[] baseQuals = Utils.dupBytes((byte)30, readBases.length);
hmm.initialize(3, 3);
double d = hmm.computeReadLikelihoodGivenHaplotypeLog10( refBases, readBases,
baseQuals, baseQuals, baseQuals, baseQuals, true, null);
}
代码示例来源:origin: broadgsa/gatk-protected
@Test(enabled = true, expectedExceptions = IllegalArgumentException.class, dataProvider = "JustHMMProvider")
public void testReadTooLong(final PairHMM hmm) {
byte[] readBases = "AAA".getBytes();
byte[] refBases = "AAAT".getBytes();
byte[] baseQuals = Utils.dupBytes((byte)30, readBases.length);
hmm.initialize(2, 3);
double d = hmm.computeReadLikelihoodGivenHaplotypeLog10( refBases, readBases,
baseQuals, baseQuals, baseQuals, baseQuals, true, null);
}
}
代码示例来源:origin: broadgsa/gatk
@Test(enabled = !DEBUG, dataProvider = "MismatchCountDataProvider")
public void testMismatchCountData(final GATKSAMRecord read, final int refIndex, final int startOnRead, final int basesToRead, final boolean isMismatch) {
final byte[] reference = Utils.dupBytes((byte)'A', 100);
final int actual = AlignmentUtils.getMismatchCount(read, reference, refIndex, startOnRead, basesToRead).numMismatches;
Assert.assertEquals(actual, isMismatch ? 1 : 0, "Wrong number of mismatches detected for read " + read.getSAMString());
}
代码示例来源:origin: broadgsa/gatk-protected
@Test(dataProvider = "CalcNIndelInformativeReadsData")
public void testCalcNIndelInformativeReads(final String readBases, final String ref, final int maxIndelSize, final List<Integer> expected ) {
final byte qual = (byte)30;
final byte[] quals = Utils.dupBytes(qual, readBases.length());
for ( int i = 0; i < readBases.getBytes().length; i++ ) {
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(readBases.getBytes(), quals, readBases.length() + "M");
final GenomeLoc loc = new UnvalidatingGenomeLoc("20", 0, i, i);
final ReadBackedPileup pileup = new ReadBackedPileupImpl(loc, Collections.singletonList(read), i);
final int actual = model.calcNIndelInformativeReads(pileup, i, ref.getBytes(), maxIndelSize);
Assert.assertEquals(actual, (int)expected.get(i), "failed at position " + i);
}
}
代码示例来源:origin: broadgsa/gatk-protected
@Test(enabled = !DEBUG, dataProvider = "JustHMMProvider")
void testMaxLengthsBiggerThanProvidedRead(final PairHMM hmm) {
final byte[] readBases = "CTATCTTAGTAAGCCCCCATACCTGCAAATTTCAGGATGTCTCCTCCAAAAATCAACA".getBytes();
final byte[] refBases = "CTATCTTAGTAAGCCCCCATACCTGCAAATTTCAGGATGTCTCCTCCAAAAATCAAAACTTCTGAGAAAAAAAAAAAAAATTAAATCAAACCCTGATTCCTTAAAGGTAGTAAAAAAACATCATTCTTTCTTAGTGGAATAGAAACTAGGTCAAAAGAACAGTGATTC".getBytes();
final byte[] quals = new byte[]{35,34,31,32,35,34,32,31,36,30,31,32,36,34,33,32,32,32,33,32,30,35,33,35,36,36,33,33,33,32,32,32,37,33,36,35,33,32,34,31,36,35,35,35,35,33,34,31,31,30,28,27,26,29,26,25,29,29};
final byte[] insQual = new byte[]{46,46,46,46,46,47,45,46,45,48,47,44,45,48,46,43,43,42,48,48,45,47,47,48,48,47,48,45,38,47,45,39,47,48,47,47,48,46,49,48,49,48,46,47,48,44,44,43,39,32,34,36,46,48,46,44,45,45};
final byte[] delQual = new byte[]{44,44,44,43,45,44,43,42,45,46,45,43,44,47,45,40,40,40,45,46,43,45,45,44,46,46,46,43,35,44,43,36,44,45,46,46,44,44,47,43,47,45,45,45,46,45,45,46,44,35,35,35,45,47,45,44,44,43};
final byte[] gcp = Utils.dupBytes((byte) 10, delQual.length);
hmm.initialize(readBases.length + 100, refBases.length + 100);
for ( int nExtraMaxSize = 0; nExtraMaxSize < 100; nExtraMaxSize++ ) {
// running HMM with no haplotype caching. Should therefore pass null in place of nextRef bases
hmm.computeReadLikelihoodGivenHaplotypeLog10( refBases, readBases, quals, insQual, delQual, gcp, true, null);
}
}
代码示例来源:origin: broadgsa/gatk-protected
public void addSequence(final byte[] bases, final boolean isRef) {
if ( isRef ) {
refHaplotype = new Haplotype(bases, true);
} else {
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(bases, Utils.dupBytes((byte)30,bases.length), bases.length + "M");
reads.add(read);
}
}
代码示例来源:origin: broadgsa/gatk
@Test(dataProvider = "MaxMinIndelSize")
public void maxIndelSizeTest(final int size, final int otherSize, final int max, final int min, final String op) {
final byte[] largerAllele = Utils.dupBytes((byte) 'A', size+1);
final byte[] smallerAllele = Utils.dupBytes((byte) 'A', 1);
final List<Allele> alleles = new ArrayList<Allele>(2);
final Allele ref = Allele.create(op.equals("I") ? smallerAllele : largerAllele, true);
final Allele alt = Allele.create(op.equals("D") ? smallerAllele : largerAllele, false);
alleles.add(ref);
alleles.add(alt);
final VariantContext vc = new VariantContextBuilder("test", "1", 10, 10 + ref.length() - 1, alleles).make();
boolean hasIndelTooLargeOrSmall = SelectVariants.containsIndelLargerOrSmallerThan(vc, max, min);
Assert.assertEquals(hasIndelTooLargeOrSmall, size > max || size < min);
}
代码示例来源:origin: broadgsa/gatk-protected
public GATKSAMRecord makeRead(final int start, final int length) {
final byte[] quals = Utils.dupBytes((byte)30, length);
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "read " + readCounter++, 0, start + getStart(), ref.substring(start, start + length).getBytes(), quals, length + "M");
read.setReadGroup(rg);
return read;
}
}
代码示例来源:origin: broadgsa/gatk
@Test(enabled = !DEBUG, dataProvider = "ReadToAlignmentByteArrayDataProvider")
public void testReadToAlignmentByteArrayData(final Cigar cigar, final int expectedLength, final char middleOp, final int startOfIndelBases, final int lengthOfDeletion) {
final byte[] read = Utils.dupBytes((byte)'A', cigar.getReadLength());
final byte[] alignment = AlignmentUtils.readToAlignmentByteArray(cigar, read);
Assert.assertEquals(alignment.length, expectedLength, "Wrong alignment length detected for cigar " + cigar.toString());
for ( int i = 0; i < alignment.length; i++ ) {
final byte expectedBase;
if ( middleOp == 'D' && i >= startOfIndelBases && i < startOfIndelBases + lengthOfDeletion )
expectedBase = PileupElement.DELETION_BASE;
else if ( middleOp == 'I' && i == startOfIndelBases - 1 )
expectedBase = PileupElement.A_FOLLOWED_BY_INSERTION_BASE;
else
expectedBase = (byte)'A';
Assert.assertEquals(alignment[i], expectedBase, "Wrong base detected at position " + i);
}
}
代码示例来源:origin: broadgsa/gatk
@Test (enabled = true)
public void testReadWithNsRefAfterDeletion() throws FileNotFoundException {
final ReferenceSequenceFile seq = new CachingIndexedFastaSequenceFile(new File(b37KGReference));
final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(seq.getSequenceDictionary());
final int readLength = 76;
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 8975, readLength);
read.setReadBases(Utils.dupBytes((byte) 'A', readLength));
read.setBaseQualities(Utils.dupBytes((byte)30, readLength));
read.setCigarString("3M414N1D73M");
final int result = ReadUtils.getReadCoordinateForReferenceCoordinateUpToEndOfRead(read, 9393, ReadUtils.ClippingTail.LEFT_TAIL);
Assert.assertEquals(result, 3);
}
代码示例来源:origin: broadgsa/gatk
@Test (enabled = true)
public void testReadWithNsRefIndexInDeletion() throws FileNotFoundException {
final ReferenceSequenceFile seq = new CachingIndexedFastaSequenceFile(new File(b37KGReference));
final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(seq.getSequenceDictionary());
final int readLength = 76;
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 8975, readLength);
read.setReadBases(Utils.dupBytes((byte) 'A', readLength));
read.setBaseQualities(Utils.dupBytes((byte)30, readLength));
read.setCigarString("3M414N1D73M");
final int result = ReadUtils.getReadCoordinateForReferenceCoordinateUpToEndOfRead(read, 9392, ReadUtils.ClippingTail.LEFT_TAIL);
Assert.assertEquals(result, 2);
}
代码示例来源:origin: broadgsa/gatk
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;
}
代码示例来源:origin: broadgsa/gatk
@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);
}
}
代码示例来源: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
public GATKSAMRecord makeRead() {
GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "read", 0, locus, readLength);
read.setReadBases(Utils.dupBytes((byte) 'A', readLength));
final byte[] quals = new byte[readLength];
for ( int i = 0; i < readLength; i++ )
quals[i] = (byte)(i % QualityUtils.MAX_SAM_QUAL_SCORE);
read.setBaseQualities(quals);
read.setCigarString(cigarString);
return read;
}
}
代码示例来源:origin: broadgsa/gatk
@Override protected void setUp() {
header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 1000);
genomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
for ( int j = 0; j < nReads; j++ ) {
GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "read", 0, locus, readLength);
read.setReadBases(Utils.dupBytes((byte) 'A', readLength));
final byte[] quals = new byte[readLength];
for ( int i = 0; i < readLength; i++ )
quals[i] = (byte)(i % QualityUtils.MAX_SAM_QUAL_SCORE);
read.setBaseQualities(quals);
read.setCigarString(cigar);
reads.add(read);
}
}
内容来源于网络,如有侵权,请联系作者删除!