当前位置: 首页>>代码示例>>Java>>正文


Java StringUtil.stringToBytes方法代码示例

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


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

示例1: createSamRecord

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
private SAMRecord createSamRecord(final SAMFileHeader header, final String baseName, final FastqRecord frec, final boolean paired) {
    final SAMRecord srec = new SAMRecord(header);
    srec.setReadName(baseName);
    srec.setReadString(frec.getReadString());
    srec.setReadUnmappedFlag(true);
    srec.setAttribute(ReservedTagConstants.READ_GROUP_ID, READ_GROUP_NAME);
    final byte[] quals = StringUtil.stringToBytes(frec.getBaseQualityString());
    convertQuality(quals, QUALITY_FORMAT);
    for (final byte qual : quals) {
        final int uQual = qual & 0xff;
        if (uQual < MIN_Q || uQual > MAX_Q) {
            throw new PicardException("Base quality " + uQual + " is not in the range " + MIN_Q + ".." +
            MAX_Q + " for read " + frec.getReadHeader());
        }
    }
    srec.setBaseQualities(quals);

    if (paired) {
        srec.setReadPairedFlag(true);
        srec.setMateUnmappedFlag(true);
    }
    return srec ;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:24,代码来源:FastqToSam.java

示例2: createAlternateConsensus

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
private Consensus createAlternateConsensus(final int indexOnRef, final byte[] reference, final byte[] indelStr, final VariantContext indel) {
    if (indexOnRef < 0 || indexOnRef >= reference.length)
        return null;

    // create the new consensus
    StringBuilder sb = new StringBuilder();
    Cigar cigar = new Cigar();
    int refIdx;

    for (refIdx = 0; refIdx < indexOnRef; refIdx++)
        sb.append((char) reference[refIdx]);
    if (indexOnRef > 0)
        cigar.add(new CigarElement(indexOnRef, CigarOperator.M));

    if (indel.isSimpleDeletion()) {
        refIdx += indelStr.length;
        cigar.add(new CigarElement(indelStr.length, CigarOperator.D));
    } else if (indel.isSimpleInsertion()) {
        for (byte b : indelStr)
            sb.append((char) b);
        cigar.add(new CigarElement(indelStr.length, CigarOperator.I));
    } else {
        throw new IllegalStateException("Creating an alternate consensus from a complex indel is not allows");
    }

    if (reference.length - refIdx > 0)
        cigar.add(new CigarElement(reference.length - refIdx, CigarOperator.M));
    for (; refIdx < reference.length; refIdx++)
        sb.append((char) reference[refIdx]);
    byte[] altConsensus = StringUtil.stringToBytes(sb.toString()); // alternative consensus sequence we just built from the current read

    return new Consensus(altConsensus, cigar, 0);
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:34,代码来源:IndelRealigner.java

示例3: addAlternateConsensus

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
public void addAlternateConsensus(int start, final byte[] reference,
		final VariantContext knowIndel, final byte[] indelStr) {
	if (start < 0 || start >= reference.length
			|| knowIndel.isComplexIndel())
		return;

	StringBuilder sb = new StringBuilder();
	ArrayList<CigarElement> elements = new ArrayList<CigarElement>();
	int refIdx;

	for (refIdx = 0; refIdx < start; refIdx++)
		sb.append((char) reference[refIdx]);
	if (start > 0)
		elements.add(new CigarElement(start, CigarOperator.M));

	if (knowIndel.isSimpleDeletion()) {
		refIdx += indelStr.length;
		elements.add(new CigarElement(indelStr.length, CigarOperator.D));
	} else if (knowIndel.isSimpleInsertion()) {
		for (byte b : indelStr)
			sb.append((char) b);
		elements.add(new CigarElement(indelStr.length, CigarOperator.I));
	}

	if (reference.length - refIdx > 0)
		elements.add(new CigarElement(reference.length - refIdx,
				CigarOperator.M));
	for (; refIdx < reference.length; refIdx++)
		sb.append((char) reference[refIdx]);
	byte[] altConsensus = StringUtil.stringToBytes(sb.toString());

	consensus.add(new AlternateConsensus(altConsensus, new Cigar(elements),
			0));
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:35,代码来源:AlternateConsensusBin.java

示例4: isValidDna

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
/**
 * Returns true if the input string is a valid DNA string,
 * which we take to mean only containing the characters ACTGactg.
 *
 * @param inString the input string sequence to test
 * @return a boolean indicating whether the input is a DNA sequence
 */
public static boolean isValidDna(String inString) {
  final byte[] in = StringUtil.stringToBytes(inString);
  for (int i = 0; i < in.length; i++) {
    if (!SequenceUtil.isValidBase(in[i])) {
      return false;
    }
  }
  return true;
}
 
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:17,代码来源:GenomeWarpUtils.java

示例5: CustomAdapterPair

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
CustomAdapterPair(final String fivePrime, final String threePrime) {
    this.threePrime = threePrime;
    this.threePrimeBytes = StringUtil.stringToBytes(threePrime);

    this.fivePrime = fivePrime;
    this.fivePrimeReadOrder = SequenceUtil.reverseComplement(fivePrime);
    this.fivePrimeBytes = StringUtil.stringToBytes(fivePrime);
    this.fivePrimeReadOrderBytes = StringUtil.stringToBytes(fivePrimeReadOrder);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:10,代码来源:CustomAdapterPair.java

示例6: substringAndRemoveTrailingNs

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
/**
 * Truncate to the given length, and in addition truncate any trailing Ns.
 */
private String substringAndRemoveTrailingNs(final String s, int length) {
    length = Math.min(length, s.length());
    final byte[] bytes = StringUtil.stringToBytes(s);
    while (length > 0 && SequenceUtil.isNoCall(bytes[length - 1])) {
        length--;
    }
    return s.substring(0, length);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:12,代码来源:AdapterMarker.java

示例7: TruncatedAdapterPair

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
private TruncatedAdapterPair(final String name, final String threePrimeReadOrder, final String fivePrimeReadOrder) {
    this.name = name;
    this.threePrime = threePrimeReadOrder;
    this.threePrimeBytes = StringUtil.stringToBytes(threePrimeReadOrder);
    this.fivePrimeReadOrder = fivePrimeReadOrder;
    this.fivePrimeReadOrderBytes = StringUtil.stringToBytes(fivePrimeReadOrder);
    this.fivePrime = SequenceUtil.reverseComplement(fivePrimeReadOrder);
    this.fivePrimeBytes = StringUtil.stringToBytes(this.fivePrime);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:10,代码来源:AdapterMarker.java

示例8: IlluminaAdapterPair

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
private IlluminaAdapterPair(final String fivePrime, final String threePrime) {
    this.threePrime = threePrime;
    this.threePrimeBytes = StringUtil.stringToBytes(threePrime);

    this.fivePrime = fivePrime;
    this.fivePrimeReadOrder = SequenceUtil.reverseComplement(fivePrime);
    this.fivePrimeBytes = StringUtil.stringToBytes(fivePrime);
    this.fivePrimeReadOrderBytes = StringUtil.stringToBytes(fivePrimeReadOrder);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:10,代码来源:IlluminaUtil.java

示例9: testBasicClip

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
@Test(dataProvider="clipTestData")
public void testBasicClip(final String testName, final String read, final String clip, final int minMatch, final double errRate, final int expected) {
    final byte[] r = (read == null) ? null : StringUtil.stringToBytes(read);
    final byte[] c = (clip == null) ? null : StringUtil.stringToBytes(clip);

    final int result = ClippingUtility.findIndexOfClipSequence(r, c, minMatch, errRate);
    Assert.assertEquals(result, expected, testName);

}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:10,代码来源:ClippingUtilityTest.java

示例10: getBases

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
@Override
public byte[] getBases() {
    final String basesString = genomicsRead.getAlignedSequence();
    if ( getLength() == 0) {
        return new byte[0];
    }

    return StringUtil.stringToBytes(basesString);
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:10,代码来源:GoogleGenomicsReadToGATKReadAdapter.java

示例11: get3PrimeAdapterBytes

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
@Override
public byte[] get3PrimeAdapterBytes() {
    return StringUtil.stringToBytes(threePrimeAdapter);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:5,代码来源:ClippingUtilityTest.java

示例12: makePhredBinaryFromSolexaQualityAscii_1_3

import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
/**
 * Convert from Solexa-scaled ASCII qualities to Phred-scaled binary.  The only difference is Solexa qualities have
 * 64 added to the phred binary to make them printable.
 *
 * @param solexaQualities Printable ASCII qualities.
 * @param offset Character at which to start conversion.
 * @param length Number of characters to convert.
 * @return binary Phred-scaled qualities.
 */
public static byte[] makePhredBinaryFromSolexaQualityAscii_1_3(final String solexaQualities, final int offset, final int length) {
    final byte[] quals = StringUtil.stringToBytes(solexaQualities, offset, length);
    SolexaQualityConverter.getSingleton().convertSolexa_1_3_QualityCharsToPhredBinary(quals);
    return quals;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:15,代码来源:IlluminaUtil.java


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