• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SAMUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中htsjdk.samtools.SAMUtils的典型用法代码示例。如果您正苦于以下问题:Java SAMUtils类的具体用法?Java SAMUtils怎么用?Java SAMUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SAMUtils类属于htsjdk.samtools包,在下文中一共展示了SAMUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setBaseQualities

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
/**
 * Setters and Accessors for base insertion and base deletion quality scores
 */
public void setBaseQualities( final byte[] quals, final EventType errorModel ) {
    switch( errorModel ) {
        case BASE_SUBSTITUTION:
            setBaseQualities(quals);
            break;
        case BASE_INSERTION:
            setAttribute( GATKSAMRecord.BQSR_BASE_INSERTION_QUALITIES, quals == null ? null : SAMUtils.phredToFastq(quals) );
            break;
        case BASE_DELETION:
            setAttribute( GATKSAMRecord.BQSR_BASE_DELETION_QUALITIES, quals == null ? null : SAMUtils.phredToFastq(quals) );
            break;
        default:
            throw new ReviewedGATKException("Unrecognized Base Recalibration type: " + errorModel );
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:19,代码来源:GATKSAMRecord.java


示例2: initializeCachedData

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
private void initializeCachedData() {
    for ( int i = 0; i < 256; i++ )
        for ( int j = 0; j < 256; j++ )
            for ( int q = 0; q <= SAMUtils.MAX_PHRED_SCORE; q++ ) {
                EPSILONS[i][j][q] = 1.0;
            }

    for ( char b1 : "ACGTacgt".toCharArray() ) {
        for ( char b2 : "ACGTacgt".toCharArray() ) {
            for ( int q = 0; q <= SAMUtils.MAX_PHRED_SCORE; q++ ) {
                double qual = qual2prob[q < minBaseQual ? minBaseQual : q];
                double e = Character.toLowerCase(b1) == Character.toLowerCase(b2) ? 1 - qual : qual * EM;
                EPSILONS[(byte)b1][(byte)b2][q] = e;
            }
        }
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:18,代码来源:BAQ.java


示例3: qualToUse

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
/**
 * Helper function that returns the phred-scaled base quality score we should use for calculating
 * likelihoods for a pileup element.  May return 0 to indicate that the observation is bad, and may
 * cap the quality score by the mapping quality of the read itself.
 *
 * @param p                           Pileup element
 * @param ignoreBadBases              Should we ignore bad bases?
 * @param capBaseQualsAtMappingQual   Should we cap the base qualities at the mapping quality of the read?
 * @param minBaseQual                 Minimum allowed base quality
 * @return the actual base quality to use
 */
private static byte qualToUse(PileupElement p, boolean ignoreBadBases, boolean capBaseQualsAtMappingQual, int minBaseQual) {
    if ( ignoreBadBases && !BaseUtils.isRegularBase( p.getBase() ) )
        return 0;

    byte qual = p.getQual();

    if ( qual > SAMUtils.MAX_PHRED_SCORE )
        throw new UserException.MisencodedBAM(p.getRead(), "we encountered an extremely high quality score (" + (int)qual + ")");
    if ( capBaseQualsAtMappingQual )
        qual = (byte) Math.min( 0xff & qual, p.getMappingQual());
    if ( (int)qual < minBaseQual )
        qual = (byte)0;

    return qual;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:27,代码来源:DiploidSNPGenotypeLikelihoods.java


示例4: initializeCachedData

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
private void initializeCachedData() {
	for (int i = 0; i < 256; i++)
		for (int j = 0; j < 256; j++)
			for (int q = 0; q <= SAMUtils.MAX_PHRED_SCORE; q++) {
				EPSILONS[i][j][q] = 1.0;
			}

	for (char b1 : "ACGTacgt".toCharArray()) {
		for (char b2 : "ACGTacgt".toCharArray()) {
			for (int q = 0; q <= SAMUtils.MAX_PHRED_SCORE; q++) {
				double qual = qual2prob[q < minBaseQual ? minBaseQual : q];
				double e = Character.toLowerCase(b1) == Character
						.toLowerCase(b2) ? 1 - qual : qual * EM;
				EPSILONS[(byte) b1][(byte) b2][q] = e;
			}
		}
	}
}
 
开发者ID:seppinho,项目名称:mutation-server,代码行数:19,代码来源:BaqAlt.java


示例5: apply

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
@Override
public GATKRead apply(final GATKRead read) {
    // get the qualities
    final byte[] quals = read.getBaseQualities();
    try {
        // transform them in place
        for (int i = 0; i < quals.length; ++i) {
            if (quals[i] < MIN_SOLEXA_BEFORE_CONVERSION) {
                // throw an exception if they are missencoded
                throwException();
            }
            // convert to Solexa
            quals[i] = SOLEXA_QUALITY_CONVERTER
                    .solexaCharToPhredBinary((byte) SAMUtils.phredToFastq(quals[i]));
        }
    } catch (IndexOutOfBoundsException e) {
        // if there is an index exception, that means that the qualities are not correctly encoded
        throwException();
    }
    // set the base qualities
    read.setBaseQualities(quals);
    return read;
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:24,代码来源:SolexaToSangerReadTransformer.java


示例6: doWork

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
@Override
protected int doWork() {
    final File output =
            OUTPUT == null
                    ? new File(INPUT.getParentFile(), getOutputFileName(INPUT))
                    : OUTPUT;

    IOUtil.assertFileIsWritable(output);
    final String hashText = SAMUtils.calculateReadGroupRecordChecksum(INPUT, REFERENCE_SEQUENCE);

    try {
        final FileWriter outputWriter = new FileWriter(output);
        outputWriter.write(hashText);
        outputWriter.close();
    } catch (final IOException ioe) {
        throw new PicardException(
                "Could not write the computed hash (" + hashText + ") to the output file: " + ioe.getMessage(), ioe);
    }
    return 0;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:21,代码来源:CalculateReadGroupChecksum.java


示例7: MultiHitAlignedReadIterator

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
/**
 *
 * @param querynameOrderIterator
 * @param primaryAlignmentSelectionStrategy Algorithm for selecting primary alignment when it is not clear from
 *                                          the input what should be primary.
 */
MultiHitAlignedReadIterator(final CloseableIterator<SAMRecord> querynameOrderIterator,
                            final PrimaryAlignmentSelectionStrategy primaryAlignmentSelectionStrategy) {
    this.primaryAlignmentSelectionStrategy = primaryAlignmentSelectionStrategy;
    peekIterator = new PeekableIterator<SAMRecord>(new FilteringSamIterator(querynameOrderIterator,
            new SamRecordFilter() {
                // Filter unmapped reads.
                public boolean filterOut(final SAMRecord record) {
                    return record.getReadUnmappedFlag() || SAMUtils.cigarMapsNoBasesToRef(record.getCigar());
                }
                public boolean filterOut(final SAMRecord first, final SAMRecord second) {
                    return ((first.getReadUnmappedFlag() || SAMUtils.cigarMapsNoBasesToRef(first.getCigar()))
                            && (second.getReadUnmappedFlag() || SAMUtils.cigarMapsNoBasesToRef(second.getCigar())));
                }
            }));


    advance();
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:25,代码来源:MultiHitAlignedReadIterator.java


示例8: testUsingOriginalQualities

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
@Test
public void testUsingOriginalQualities() throws Exception {
    final MeanQualityByCycleSpark.HistogramGenerator hg = new MeanQualityByCycleSpark.HistogramGenerator(true);
    Assert.assertEquals(hg.useOriginalQualities, true);

    GATKRead read1 = ArtificialReadUtils.createArtificialRead("aa".getBytes(), new byte[]{50, 50}, "2M");
    hg.addRead(read1);
    assertEqualsLongArray(hg.firstReadCountsByCycle, new long[0]);
    assertEqualsDoubleArray(hg.firstReadTotalsByCycle, new double[0], 1e-05);
    assertEqualsLongArray(hg.secondReadCountsByCycle, new long[0]);
    assertEqualsDoubleArray(hg.secondReadTotalsByCycle, new double[0], 1e-05);

    GATKRead read2 = ArtificialReadUtils.createArtificialRead("aa".getBytes(), new byte[]{50, 50}, "2M");
    read2.setAttribute(SAMTag.OQ.name(), SAMUtils.phredToFastq(new byte[]{30, 40}));
    hg.addRead(read2);

    assertEqualsLongArray(hg.firstReadCountsByCycle, new long[]{0, 1, 1});
    assertEqualsDoubleArray(hg.firstReadTotalsByCycle, new double[]{0, 30, 40}, 1e-05);
    assertEqualsLongArray(hg.secondReadCountsByCycle, new long[]{0, 0, 0});
    assertEqualsDoubleArray(hg.secondReadTotalsByCycle, new double[]{0, 0, 0}, 1e-05);
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:22,代码来源:MeanQualityHistogramGeneratorUnitTest.java


示例9: reset

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
void reset(EvidenceRecord evidenceRecord) {
	this.evidenceRecord = evidenceRecord;

	negative = "-".equals(evidenceRecord.Strand);

	baseBuf.clear();
	scoreBuf.clear();
	if (evidenceRecord.Strand.equals("+")) {
		baseBuf.put(evidenceRecord.Sequence.getBytes());
		scoreBuf.put(SAMUtils.fastqToPhred(evidenceRecord.Scores));
	} else {
		byte[] bytes = evidenceRecord.Sequence.getBytes();
		SequenceUtil.reverseComplement(bytes);
		baseBuf.put(bytes);
		bytes = SAMUtils.fastqToPhred(evidenceRecord.Scores);
		SequenceUtil.reverseQualities(bytes);
		scoreBuf.put(bytes);
	}
	baseBuf.flip();
	scoreBuf.flip();

	firstHalf.clear();
	secondHalf.clear();
}
 
开发者ID:enasequence,项目名称:cramtools,代码行数:25,代码来源:Read.java


示例10: firstSAMRecord

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
SAMRecord firstSAMRecord(SAMFileHeader header) {
	SAMRecord r = new SAMRecord(header);
	r.setReadName(evidenceRecord.getReadName());
	r.setReferenceName(evidenceRecord.Chromosome);
	r.setAlignmentStart(Integer.valueOf(evidenceRecord.OffsetInReference) + 1);
	r.setMappingQuality(Integer.valueOf(evidenceRecord.ScoreAllele0));
	r.setReadPairedFlag(true);
	r.setReadUnmappedFlag(false);
	r.setReadNegativeStrandFlag(negative);
	r.setFirstOfPairFlag(evidenceRecord.side == 0);
	r.setSecondOfPairFlag(!r.getFirstOfPairFlag());

	r.setCigar(new Cigar(Utils.toCigarOperatorList(firstHalf.samCigarElements)));

	r.setReadBases(Utils.toByteArray(firstHalf.readBasesBuf));
	r.setBaseQualities(Utils.toByteArray(firstHalf.readScoresBuf));

	r.setAttribute("GC", Utils.toString(firstHalf.gcList));
	r.setAttribute("GS", Utils.toString(firstHalf.gsBuf));
	r.setAttribute("GQ", SAMUtils.phredToFastq(Utils.toByteArray(firstHalf.gqBuf)));

	return r;
}
 
开发者ID:enasequence,项目名称:cramtools,代码行数:24,代码来源:Read.java


示例11: secondSAMRecord

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
SAMRecord secondSAMRecord(SAMFileHeader header) {
	SAMRecord r = new SAMRecord(header);
	r.setReadName(evidenceRecord.getReadName());
	r.setReferenceName(evidenceRecord.Chromosome);
	r.setAlignmentStart(Integer.valueOf(evidenceRecord.MateOffsetInReference) + 1);
	r.setMappingQuality(Integer.valueOf(evidenceRecord.ScoreAllele0));
	r.setReadPairedFlag(true);
	r.setReadUnmappedFlag(false);
	r.setReadNegativeStrandFlag(negative);
	r.setFirstOfPairFlag(evidenceRecord.side == 1);
	r.setSecondOfPairFlag(!r.getFirstOfPairFlag());

	r.setCigar(new Cigar(Utils.toCigarOperatorList(secondHalf.samCigarElements)));

	r.setReadBases(Utils.toByteArray(secondHalf.readBasesBuf));
	r.setBaseQualities(Utils.toByteArray(secondHalf.readScoresBuf));

	r.setAttribute("GC", Utils.toString(secondHalf.gcList));
	r.setAttribute("GS", Utils.toString(secondHalf.gsBuf));
	r.setAttribute("GQ", SAMUtils.phredToFastq(Utils.toByteArray(secondHalf.gqBuf)));

	return r;
}
 
开发者ID:enasequence,项目名称:cramtools,代码行数:24,代码来源:Read.java


示例12: analyseSamRecord

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
private void analyseSamRecord(final SAMRecord rec) {
if(rec.getReadUnmappedFlag()) return;
if(rec.getReadFailsVendorQualityCheckFlag()) return;
if(rec.isSecondaryOrSupplementary()) return;
if(rec.getDuplicateReadFlag()) return;

final List<SAMRecord> others= SAMUtils.getOtherCanonicalAlignments(rec);
if(others.isEmpty()) return;
String sample=this.defaultSampleName;
final SAMReadGroupRecord g=rec.getReadGroup();
if(g!=null) {
	final String sa = g.getSample();
	if(sa!=null) sample=sa;
	}

IntervalTreeMap<Set<Arc>> database = this.sample2database.get(sample);
if(database==null) {
	database=new IntervalTreeMap<Set<Arc>>();
	this.sample2database.put(sample, database);
	}

for(final SAMRecord other:others)
	{
	analyseSamPair(database,rec,other);
	}
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:27,代码来源:SamScanSplitReads.java


示例13: fillCache

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
private void fillCache() {
    // cache Q(j,k) = log10(j/2N*(1-ek) + (2N-j)/2N*ek) for j = 0:2N

    logMismatchProbabilityArray = new double[1+numChromosomes][1+SAMUtils.MAX_PHRED_SCORE];
    for (int i=0; i <= numChromosomes; i++) {
        for (int j=0; j <= SAMUtils.MAX_PHRED_SCORE; j++) {
            double phi = (double)i/numChromosomes;
            logMismatchProbabilityArray[i][j] = Math.log10(phi * (1.0-qualVec[j]) + qualVec[j]/3.0 * (1.0-phi));
        }
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:12,代码来源:GeneralPloidyGenotypeLikelihoods.java


示例14: writeDebugLikelihoods

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
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);
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:11,代码来源:PairHMMLikelihoodCalculationEngine.java


示例15: writeDebugLikelihoods

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
private void writeDebugLikelihoods(final GATKRead processedRead, final Haplotype haplotype, final double log10l){
    // Note: the precision of log10l in the debug output is only ~6 digits (ie., not all digits are necessarily printed)
    likelihoodsStream.printf("%s %s %s %s %s %s %f%n",
            haplotype.getBaseString(),
            new String(processedRead.getBases()),
            SAMUtils.phredToFastq(processedRead.getBaseQualities()),
            SAMUtils.phredToFastq(ReadUtils.getBaseInsertionQualities(processedRead)),
            SAMUtils.phredToFastq(ReadUtils.getBaseDeletionQualities(processedRead)),
            SAMUtils.phredToFastq(constantGCP),
            log10l);
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:12,代码来源:PairHMMLikelihoodCalculationEngine.java


示例16: testConvertQualities

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
@Test(dataProvider = "solexaQuals")
public void testConvertQualities(final String solexaQualityString,
        final String expectedSolexaQuals) throws Exception {
    final GATKRead read = ArtificialReadUtils.createArtificialUnmappedRead(header,
            Utils.dupBytes((byte) 'A', solexaQualityString.length()),
            SAMUtils.fastqToPhred(solexaQualityString)
    );
    Assert.assertEquals(ReadUtils.getBaseQualityString(transformer.apply(read)),
            expectedSolexaQuals);
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:11,代码来源:SolexaToSangerReadTransformerUnitTest.java


示例17: testBadQualities

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
@Test(dataProvider = "badQuals", expectedExceptions = UserException.BadInput.class)
public void testBadQualities(final String badQual) {
    final GATKRead read = ArtificialReadUtils.createArtificialUnmappedRead(
            header, new byte[] {'A'}, SAMUtils.fastqToPhred(badQual));
    transformer.apply(read);
    log(ReadUtils.getBaseQualityString(read));
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:8,代码来源:SolexaToSangerReadTransformerUnitTest.java


示例18: testCorrectQuals

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
@Test(dataProvider = "standardQuals")
public void testCorrectQuals(final String qualities) throws Exception {
    final GATKRead read = ArtificialReadUtils.createArtificialUnmappedRead(header,
            Utils.dupBytes((byte) 'A', qualities.length()),
            SAMUtils.fastqToPhred(qualities)
    );
    final CheckQualityReadTransformer transformer =
            new CheckQualityReadTransformer();
    final GATKRead copy = read.deepCopy();
    Assert.assertEquals(transformer.apply(read), copy);
    transformer.currentReadCounter.set(1001);
    Assert.assertEquals(transformer.apply(read), copy);
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:14,代码来源:CheckQualityReadTransformerUnitTest.java


示例19: testBadQualitiesNoThrown

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
@Test(dataProvider = "badQuals")
public void testBadQualitiesNoThrown(final String badQual) throws Exception {
    final GATKRead read = ArtificialReadUtils.createArtificialUnmappedRead(
            header, new byte[] {'A'}, SAMUtils.fastqToPhred(badQual));
    final CheckQualityReadTransformer transformer =
            new CheckQualityReadTransformer();
    transformer.apply(read);
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:9,代码来源:CheckQualityReadTransformerUnitTest.java


示例20: testBadQualitiesCheck

import htsjdk.samtools.SAMUtils; //导入依赖的package包/类
@Test(dataProvider = "badQuals", expectedExceptions = UserException.MisencodedQualityScoresRead.class)
public void testBadQualitiesCheck(final String badQual) throws Exception {
    final GATKRead read = ArtificialReadUtils.createArtificialUnmappedRead(
            header, new byte[] {'A'}, SAMUtils.fastqToPhred(badQual));
    final CheckQualityReadTransformer transformer =
            new CheckQualityReadTransformer();
    transformer.currentReadCounter.set(1001);
    transformer.apply(read);
    log(String.valueOf(read.getBaseQuality(0)));
}
 
开发者ID:magicDGS,项目名称:ReadTools,代码行数:11,代码来源:CheckQualityReadTransformerUnitTest.java



注:本文中的htsjdk.samtools.SAMUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MapEntry类代码示例发布时间:2022-05-22
下一篇:
Java URLPermission类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap