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


Java BinaryCodec.writeInt方法代码示例

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


在下文中一共展示了BinaryCodec.writeInt方法的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);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:37,代码来源:BamToBfqWriter.java

示例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);
    }
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:35,代码来源:SparkUtils.java

示例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());
	}
}
 
开发者ID:enasequence,项目名称:cramtools,代码行数:16,代码来源:SAMFileHeader_Utils.java


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