本文整理汇总了Java中htsjdk.samtools.util.BinaryCodec.writeString方法的典型用法代码示例。如果您正苦于以下问题:Java BinaryCodec.writeString方法的具体用法?Java BinaryCodec.writeString怎么用?Java BinaryCodec.writeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.util.BinaryCodec
的用法示例。
在下文中一共展示了BinaryCodec.writeString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeFastqRecord
import htsjdk.samtools.util.BinaryCodec; //导入方法依赖的package包/类
/**
* Writes out a SAMRecord in Maq fastq format
*
* @param codec the code to write to
* @param rec the SAMRecord to write
*/
private void writeFastqRecord(final BinaryCodec codec, final SAMRecord rec) {
// Trim the run barcode off the read name
String readName = rec.getReadName();
if (namePrefix != null && readName.startsWith(namePrefix)) {
readName = readName.substring(nameTrim);
}
// Writes the length of the read name and then the name (null-terminated)
codec.writeString(readName, true, true);
final char[] seqs = rec.getReadString().toCharArray();
final char[] quals = rec.getBaseQualityString().toCharArray();
int retainedLength = seqs.length;
if (clipAdapters){
// adjust to a shorter length iff clipping tag exists
Integer trimPoint = rec.getIntegerAttribute(ReservedTagConstants.XT);
if (trimPoint != null) {
assert (rec.getReadLength() == seqs.length);
retainedLength = Math.min(seqs.length, Math.max(SEED_REGION_LENGTH, trimPoint -1));
}
}
// Write the length of the sequence
codec.writeInt(basesToWrite != null ? basesToWrite : seqs.length);
// Calculate and write the sequence and qualities
final byte[] seqsAndQuals = encodeSeqsAndQuals(seqs, quals, retainedLength);
codec.writeBytes(seqsAndQuals);
}
示例2: writeBAMHeaderToStream
import htsjdk.samtools.util.BinaryCodec; //导入方法依赖的package包/类
/**
* Private helper method for {@link #convertHeaderlessHadoopBamShardToBam} that takes a SAMFileHeader and writes it
* to the provided `OutputStream`, correctly encoded for the BAM format and preceded by the BAM magic bytes.
*
* @param samFileHeader SAM header to write
* @param outputStream stream to write the SAM header to
*/
private static void writeBAMHeaderToStream( final SAMFileHeader samFileHeader, final OutputStream outputStream ) {
final BlockCompressedOutputStream blockCompressedOutputStream = new BlockCompressedOutputStream(outputStream, null);
final BinaryCodec outputBinaryCodec = new BinaryCodec(new DataOutputStream(blockCompressedOutputStream));
final String headerString;
final Writer stringWriter = new StringWriter();
new SAMTextHeaderCodec().encode(stringWriter, samFileHeader, true);
headerString = stringWriter.toString();
outputBinaryCodec.writeBytes(ReadUtils.BAM_MAGIC);
// calculate and write the length of the SAM file header text and the header text
outputBinaryCodec.writeString(headerString, true, false);
// write the sequences binarily. This is redundant with the text header
outputBinaryCodec.writeInt(samFileHeader.getSequenceDictionary().size());
for (final SAMSequenceRecord sequenceRecord: samFileHeader.getSequenceDictionary().getSequences()) {
outputBinaryCodec.writeString(sequenceRecord.getSequenceName(), true, true);
outputBinaryCodec.writeInt(sequenceRecord.getSequenceLength());
}
try {
blockCompressedOutputStream.flush();
} catch (final IOException ioe) {
throw new RuntimeIOException(ioe);
}
}
示例3: writeHeader
import htsjdk.samtools.util.BinaryCodec; //导入方法依赖的package包/类
static void writeHeader(final BinaryCodec outputBinaryCodec, final SAMFileHeader samFileHeader,
final String headerText) {
outputBinaryCodec.writeBytes("BAM\1".getBytes());
// calculate and write the length of the SAM file header text and the
// header text
outputBinaryCodec.writeString(headerText, true, false);
// write the sequences binarily. This is redundant with the text header
outputBinaryCodec.writeInt(samFileHeader.getSequenceDictionary().size());
for (final SAMSequenceRecord sequenceRecord : samFileHeader.getSequenceDictionary().getSequences()) {
outputBinaryCodec.writeString(sequenceRecord.getSequenceName(), true, true);
outputBinaryCodec.writeInt(sequenceRecord.getSequenceLength());
}
}