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


Java SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX属性代码示例

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


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

示例1: transfer

/**
 * 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,代码行数:36,代码来源:SAMRecord2BasicTransfer.java

示例2: createArtificialRead

/**
 * Create an artificial read based on the parameters.  The cigar string will be *M, where * is the length of the read
 *
 * @param header         the SAM header to associate the read with
 * @param name           the name of the read
 * @param refIndex       the reference index, i.e. what chromosome to associate it with
 * @param alignmentStart where to start the alignment
 * @param length         the length of the read
 * @return the artificial read
 */
public static GATKSAMRecord createArtificialRead(SAMFileHeader header, String name, int refIndex, int alignmentStart, int length) {
    if ((refIndex == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX && alignmentStart != SAMRecord.NO_ALIGNMENT_START) ||
            (refIndex != SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX && alignmentStart == SAMRecord.NO_ALIGNMENT_START))
        throw new ReviewedGATKException("Invalid alignment start for artificial read, start = " + alignmentStart);
    GATKSAMRecord record = new GATKSAMRecord(header);
    record.setReadName(name);
    record.setReferenceIndex(refIndex);
    record.setAlignmentStart(alignmentStart);
    List<CigarElement> elements = new ArrayList<CigarElement>();
    elements.add(new CigarElement(length, CigarOperator.characterToEnum('M')));
    record.setCigar(new Cigar(elements));
    record.setProperPairFlag(false);

    // our reads and quals are all 'A's by default
    byte[] c = new byte[length];
    byte[] q = new byte[length];
    for (int x = 0; x < length; x++)
        c[x] = q[x] = 'A';
    record.setReadBases(c);
    record.setBaseQualities(q);

    if (refIndex == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX) {
        record.setReadUnmappedFlag(true);
    }

    return record;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:37,代码来源:ArtificialSAMUtils.java

示例3: map

@Override
protected void map(final ReferenceContext ref,
                   final GATKSAMRecord read,
                   final RefMetaDataTracker metaDataTracker) {
    if (currentInterval == null) {
        emit(read);
        return;
    }

    // edge case: when the last target interval abuts the end of the genome, we'll get one of the
    //   unmapped reads while the currentInterval still isn't null.  We need to trigger the cleaning
    //   at this point without trying to create a GenomeLoc.
    if (read.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX) {
        cleanAndCallMap(ref, read, metaDataTracker, null);
        return;
    }

    GenomeLoc readLoc = genomeLocParser.createGenomeLoc(read);
    // hack to get around unmapped reads having screwy locations
    if (readLoc.getStop() == 0)
        readLoc = genomeLocParser.createGenomeLoc(readLoc.getContig(), readLoc.getStart(), readLoc.getStart());

    if (readLoc.isBefore(currentInterval)) {
        if (!sawReadInCurrentInterval)
            emit(read);
        else
            readsNotToClean.add(read);
    } else if (readLoc.overlapsP(currentInterval)) {
        sawReadInCurrentInterval = true;

        if (doNotTryToClean(read)) {
            readsNotToClean.add(read);
        } else {
            readsToClean.add(read);

            // add the rods to the list of known variants
            populateKnownIndels(metaDataTracker);
        }

        if (readsToClean.size() + readsNotToClean.size() >= MAX_READS) {
            abortCleanForCurrentInterval();
        }
    } else {  // the read is past the current interval
        cleanAndCallMap(ref, read, metaDataTracker, readLoc);
    }

    return;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:48,代码来源:IndelRealigner.java

示例4: isReadUnmapped

/**
 * Due to (unfortunate) multiple ways to indicate that read is unmapped allowed by SAM format
 * specification, one may need this convenience shortcut. Checks both 'read unmapped' flag and
 * alignment reference index/start.
 *
 * Our life would be so much easier if all sam files followed the specs. In reality,
 * sam files (including those generated by maq or bwa) miss headers altogether. When
 * reading such a SAM file, reference name is set, but since there is no sequence dictionary,
 * null is always returned for referenceIndex. Let's be paranoid here, and make sure that
 * we do not call the read "unmapped" when it has only reference name set with ref. index missing
 * or vice versa.
 *
 * @param r a non-null record
 * @return true if read is unmapped
 */
public static boolean isReadUnmapped(final SAMRecord r) {
    if ( r == null )
        throw new IllegalArgumentException("Read cannot be null");

    return r.getReadUnmappedFlag() ||
            !((r.getReferenceIndex() != null && r.getReferenceIndex() != SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX ||
                    r.getReferenceName() != null && !r.getReferenceName().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_NAME)) &&
                    r.getAlignmentStart() != SAMRecord.NO_ALIGNMENT_START);

}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:25,代码来源:AlignmentUtils.java


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