本文整理汇总了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 ;
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例11: get3PrimeAdapterBytes
import htsjdk.samtools.util.StringUtil; //导入方法依赖的package包/类
@Override
public byte[] get3PrimeAdapterBytes() {
return StringUtil.stringToBytes(threePrimeAdapter);
}
示例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;
}