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


Java SAMRecord.getAlignmentEnd方法代码示例

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


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

示例1: calcBAQFromHMM

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
public BAQCalculationResult calcBAQFromHMM(SAMRecord read, RefContentProvider refContentProvider) {
    // start is alignment start - band width / 2 - size of first I element, if there is one.  Stop is similar
    int offset = getBandWidth() / 2;
    long readStart = includeClippedBases ? read.getUnclippedStart() : read.getAlignmentStart();
    long start = Math.max(readStart - offset - ReadUtils.getFirstInsertionOffset(read), 0);
    long stop = (includeClippedBases ? read.getUnclippedEnd() : read.getAlignmentEnd()) + offset + ReadUtils.getLastInsertionOffset(read);

    if ( stop > refContentProvider.getSamSequenceDictionary().getSequence(read.getReferenceName()).getSequenceLength() ) {
        return null;
    } else {
        // now that we have the start and stop, get the reference sequence covering it
        GenomeLoc locus = new GenomeLoc(read.getReferenceName(), read.getReferenceIndex(), (int)start, (int)stop);
        byte[] refSeq = refContentProvider.getReferenceContext(locus).getBases();
        return calcBAQFromHMM(read, refSeq, (int)(start - readStart));
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:17,代码来源:BAQ.java

示例2: hasWellDefinedFragmentSize

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
     * Can the adaptor sequence of read be reliably removed from the read based on the alignment of
     * read and its mate?
     *
     * @param read the read to check
     * @return true if it can, false otherwise
     */
    public static boolean hasWellDefinedFragmentSize(final SAMRecord read) {
        if ( read.getInferredInsertSize() == 0 )
            // no adaptors in reads with mates in another chromosome or unmapped pairs
            return false;
        if ( ! read.getReadPairedFlag() )
            // only reads that are paired can be adaptor trimmed
            return false;
        if ( read.getReadUnmappedFlag() || read.getMateUnmappedFlag() )
            // only reads when both reads are mapped can be trimmed
            return false;
//        if ( ! read.getProperPairFlag() )
//            // note this flag isn't always set properly in BAMs, can will stop us from eliminating some proper pairs
//            // reads that aren't part of a proper pair (i.e., have strange alignments) can't be trimmed
//            return false;
        if ( read.getReadNegativeStrandFlag() == read.getMateNegativeStrandFlag() )
            // sanity check on getProperPairFlag to ensure that read1 and read2 aren't on the same strand
            return false;

        if ( read.getReadNegativeStrandFlag() ) {
            // we're on the negative strand, so our read runs right to left
            return read.getAlignmentEnd() > read.getMateAlignmentStart();
        } else {
            // we're on the positive strand, so our mate should be to our right (his start + insert size should be past our start)
            return read.getAlignmentStart() <= read.getMateAlignmentStart() + read.getInferredInsertSize();
        }
    }
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:34,代码来源:ReadUtils.java

示例3: create

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Generic algorithm that takes an iterable over T objects, a getter routine to extract the reads in T,
 * and returns a FragmentCollection that contains the T objects whose underlying reads either overlap (or
 * not) with their mate pairs.
 *
 * @param readContainingObjects An iterator of objects that contain GATKSAMRecords
 * @param nElements the number of elements to be provided by the iterator, which is usually known upfront and
 *                  greatly improves the efficiency of the fragment calculation
 * @param getter a helper function that takes an object of type T and returns is associated GATKSAMRecord
 * @param <T>
 * @return a fragment collection
 */
private static <T> FragmentCollection<T> create(final Iterable<T> readContainingObjects, final int nElements, final ReadGetter<T> getter) {
    Collection<T> singletons = null;
    Collection<List<T>> overlapping = null;
    Map<String, T> nameMap = null;

    int lastStart = -1;

    // build an initial map, grabbing all of the multi-read fragments
    for ( final T p : readContainingObjects ) {
        final SAMRecord read = getter.get(p);

        if ( read.getAlignmentStart() < lastStart ) {
            throw new IllegalArgumentException(String.format(
                    "FragmentUtils.create assumes that the incoming objects are ordered by " +
                            "SAMRecord alignment start, but saw a read %s with alignment start " +
                            "%d before the previous start %d", read.getSAMString(), read.getAlignmentStart(), lastStart));
        }
        lastStart = read.getAlignmentStart();

        final int mateStart = read.getMateAlignmentStart();
        if ( mateStart == 0 || mateStart > read.getAlignmentEnd() ) {
            // if we know that this read won't overlap its mate, or doesn't have one, jump out early
            if ( singletons == null ) singletons = new ArrayList<T>(nElements); // lazy init
            singletons.add(p);
        } else {
            // the read might overlap it's mate, or is the rightmost read of a pair
            final String readName = read.getReadName();
            final T pe1 = nameMap == null ? null : nameMap.get(readName);
            if ( pe1 != null ) {
                // assumes we have at most 2 reads per fragment
                if ( overlapping == null ) overlapping = new ArrayList<List<T>>(); // lazy init
                overlapping.add(Arrays.asList(pe1, p));
                nameMap.remove(readName);
            } else {
                if ( nameMap == null ) nameMap = new HashMap<String, T>(nElements); // lazy init
                nameMap.put(readName, p);
            }
        }
    }

    // add all of the reads that are potentially overlapping but whose mate never showed
    // up to the oneReadPile
    if ( nameMap != null && ! nameMap.isEmpty() ) {
        if ( singletons == null )
            singletons = nameMap.values();
        else
            singletons.addAll(nameMap.values());
    }

    return new FragmentCollection<T>(singletons, overlapping);
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:64,代码来源:FragmentUtils.java


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