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


Java SAMRecord.getAttributes方法代码示例

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


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

示例1: transfer

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Write the record.
 *
 * @param alignment SAMRecord.
 */
public BasicSamRecord transfer(final SAMRecord alignment) {
    String readName = alignment.getReadName();
    int flags = alignment.getFlags();
    int contigId = alignment.getReferenceIndex();
    if (contigId == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX) {
        contigId = FAKE_CONTIG_ID;
    }
    String contigName = alignment.getReferenceName();
    int position = alignment.getAlignmentStart();
    int mapQ = alignment.getMappingQuality();
    String cigar = alignment.getCigarString();
    int mateContigId = alignment.getMateReferenceIndex();
    if (mateContigId == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX) {
        mateContigId = FAKE_CONTIG_ID;
    }
    String mateContigName = alignment.getMateReferenceName();
    int matePosition = alignment.getMateAlignmentStart();
    int inferredSize = alignment.getInferredInsertSize();
    byte[] sequence = alignment.getReadString().getBytes();
    byte[] quality = alignment.getBaseQualityString().getBytes();
    List<SAMRecord.SAMTagAndValue> attributes = alignment.getAttributes();
    List<String> encodedTags = new ArrayList<>(attributes.size());
    for (SAMRecord.SAMTagAndValue attribute : attributes) {
        encodedTags.add(tagCodec.encode(attribute.tag, attribute.value));
    }

    // 在这里统一不压缩,压缩操作是由scala代码中的执行引擎统一调配的。
    return BasicSamRecord.apply(false, readName, flags, contigId, contigName, position, mapQ,
            cigar, mateContigId, mateContigName, matePosition, inferredSize,
            sequence, quality, encodedTags);
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:37,代码来源:SAMRecord2BasicTransfer.java

示例2: GATKSAMRecord

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * HACK TO CREATE GATKSAMRECORD BASED ONLY A SAMRECORD FOR TESTING PURPOSES ONLY
 * @param read
 */
public GATKSAMRecord(final SAMRecord read) {
    super(read.getHeader());
    setReferenceIndex(read.getReferenceIndex());
    setAlignmentStart(read.getAlignmentStart());
    mReadNameLength = (short)read.getReadNameLength();
    setMappingQuality(read.getMappingQuality());
    mCigarLength = read.getCigarLength();
    setFlags(read.getFlags());
    mReadLength = read.getReadLength();
    setMateReferenceIndex(read.getMateReferenceIndex());
    setMateAlignmentStart(read.getMateAlignmentStart());
    setInferredInsertSize(read.getInferredInsertSize());
    mRestOfBinaryData = null;

    super.setReadName(read.getReadName());
    super.setCigarString(read.getCigarString());
    super.setReadBases(read.getReadBases());
    super.setBaseQualities(read.getBaseQualities());

    SAMReadGroupRecord samRG = read.getReadGroup();
    clearAttributes();
    if (samRG != null) {
        GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(samRG);
        setReadGroup(rg);
    }
    List<SAMTagAndValue> attributes = read.getAttributes();
    for(SAMTagAndValue tagAndValue : attributes) {
        setAttribute(tagAndValue.tag, tagAndValue.value);
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:35,代码来源:GATKSAMRecord.java


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