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


Java SAMRecord.getAlignmentStart方法代码示例

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


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

示例3: createGenomeLoc

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Create a genome loc, given a read. If the read is unmapped, *and* yet the read has a contig and start position,
 * then a GenomeLoc is returned for contig:start-start, otherwise an UNMAPPED GenomeLoc is returned.
 *
 * @param read the read from which to create a genome loc
 * @return the GenomeLoc that was created
 */
public GenomeLoc createGenomeLoc(final SAMRecord read) {
    if (read.getReadUnmappedFlag() && read.getReferenceIndex() == -1)
        // read is unmapped and not placed anywhere on the genome
        return GenomeLoc.UNMAPPED;
    else {
        // Use Math.max to ensure that end >= start (Picard assigns the end to reads that are entirely within an insertion as start-1)
        final int end = read.getReadUnmappedFlag() ? read.getAlignmentStart() : Math.max(read.getAlignmentEnd(), read.getAlignmentStart());
        return createGenomeLoc(read.getReferenceName(), read.getReferenceIndex(), read.getAlignmentStart(), end, false);
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:18,代码来源:GenomeLocParser.java

示例4: 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

示例5: filterOut

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
@Override
public boolean filterOut(SAMRecord read) {
    return read.getAlignmentStart() <= 0 || ((GATKSAMRecord)read).getSoftStart() <= 0;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:5,代码来源:NegativeAlignmentStartFilter.java

示例6: filterOut

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
@Override
public boolean filterOut(SAMRecord read) {
    return read.getReadUnmappedFlag() || read.getAlignmentStart() == SAMRecord.NO_ALIGNMENT_START;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:5,代码来源:UnmappedReadFilter.java

示例7: filterOut

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
@Override
public boolean filterOut(SAMRecord read) {
    return read.getAlignmentStart() < refContentProvider.getOriginStartCoordinate()
            || read.getAlignmentStart() > refContentProvider.getOriginEndCoordinate();
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:6,代码来源:InOriginIntervalFilter.java

示例8: 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

示例9: noReadCanMoveBefore

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
private boolean noReadCanMoveBefore(int pos, SAMRecord addedRead) {
    return pos + 2 * MAX_POS_MOVE_ALLOWED < addedRead.getAlignmentStart();
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:4,代码来源:ConstrainedMateFixingManager.java

示例10: isReadUnmapped

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * 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,代码行数:26,代码来源:AlignmentUtils.java

示例11: getAdaptorBoundary

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Finds the adaptor boundary around the read and returns the first base inside the adaptor that is closest to
 * the read boundary. If the read is in the positive strand, this is the first base after the end of the
 * fragment (Picard calls it 'insert'), if the read is in the negative strand, this is the first base before the
 * beginning of the fragment.
 *
 * There are two cases we need to treat here:
 *
 * 1) Our read is in the reverse strand :
 *
 *     <----------------------| *
 *   |--------------------->
 *
 *   in these cases, the adaptor boundary is at the mate start (minus one)
 *
 * 2) Our read is in the forward strand :
 *
 *   |---------------------->   *
 *     <----------------------|
 *
 *   in these cases the adaptor boundary is at the start of the read plus the inferred insert size (plus one)
 *
 * @param read the read being tested for the adaptor boundary
 * @return the reference coordinate for the adaptor boundary (effectively the first base IN the adaptor, closest to the read.
 * CANNOT_COMPUTE_ADAPTOR_BOUNDARY if the read is unmapped or the mate is mapped to another contig.
 */
public static int getAdaptorBoundary(final SAMRecord read) {
    if ( ! hasWellDefinedFragmentSize(read) ) {
        return CANNOT_COMPUTE_ADAPTOR_BOUNDARY;
    } else if ( read.getReadNegativeStrandFlag() ) {
        return read.getMateAlignmentStart() - 1;           // case 1 (see header)
    } else {
        final int insertSize = Math.abs(read.getInferredInsertSize());    // the inferred insert size can be negative if the mate is mapped before the read (so we take the absolute value)
        return read.getAlignmentStart() + insertSize + 1;  // case 2 (see header)
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:37,代码来源:ReadUtils.java


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