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


Java SAMRecord.getReadUnmappedFlag方法代码示例

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


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

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

示例2: createGenomeLocUnclipped

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Create a genome loc, given a read using its unclipped alignment. 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 createGenomeLocUnclipped(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.getUnclippedEnd() : Math.max(read.getUnclippedEnd(), read.getUnclippedStart());
        return createGenomeLoc(read.getReferenceName(), read.getReferenceIndex(), read.getUnclippedStart(), end, false);
    }
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:18,代码来源:GenomeLocParser.java

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

示例4: loadReads

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
public void loadReads(File[] bams) throws IOException{

int count = 0;
int numOp = 0;

for(File bam : bams){
    HLA.log.appendln("Loading reads from:\t" + bam.getName());
    Object2IntOpenHashMap<String> readLoadingSet = new Object2IntOpenHashMap<String>();
    readLoadingSet.defaultReturnValue(0);
    
    final SamReader reader = SamReaderFactory.makeDefault().open(bam);
    
    //Kourami bam checker added
    if(!checkHeader(reader.getFileHeader())){
	HLA.log.appendln("Unexpected BAM :\t"+ bam.getName() 
			+"\nThe input BAM MUST be aligned to the set of IMGT/HLA alleles in " + HLA.MSAFILELOC + "\n" 
			+ "Please use the recommended preprocessing steps explained on the github page:\n"
			+ "https://github.com/Kingsford-Group/kourami");
	System.err.println("Unexpected BAM :\t"+ bam.getName() 
			   +"\nThe input BAM MUST be aligned to the set of IMGT/HLA alleles in " + HLA.MSAFILELOC + "\n" 
			   + "Please use the recommended preprocessing steps explained on the github page:\n"
			   + "https://github.com/Kingsford-Group/kourami");
	HLA.log.outToFile();
	System.exit(1);
    }

    for(final SAMRecord samRecord : reader){
	if(count == 0){
	    HLA.READ_LENGTH = samRecord.getReadLength();
	    HLA.log.appendln("Setting HLA.READ_LEGNTH = " + HLA.READ_LENGTH);
	}
	//added checking to process reads matching to HLA-type sequences
	//discarding decoy hits (DQB2, DQA2)
	boolean qc = false;
	if( (samRecord.getReferenceName().indexOf("*") > -1) 
	    && !samRecord.getReadUnmappedFlag() 
	    && !samRecord.isSecondaryOrSupplementary() 
	    && !this.startWIns(samRecord)){
	    count++;
	    if(samRecord.getReadPairedFlag())
		numOp += processRecord(samRecord, readLoadingSet);
	    else
		numOp += processRecordUnpaired(samRecord);
	}
	
	if(HLA.DEBUG && count%10000 == 0)
	    HLA.log.appendln("Processed 10000 reads...");
    }
    reader.close();
}
HLA.log.appendln("Loaded a total of " + count + " mapped reads.");
HLA.log.appendln("A total of " + numOp + " bases");
   }
 
开发者ID:Kingsford-Group,项目名称:kourami,代码行数:54,代码来源:HLA.java

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

示例6: pairedReadIsMovable

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
private boolean pairedReadIsMovable(SAMRecord read) {
    return read.getReadPairedFlag()                                          // we're a paired read
            && (!read.getReadUnmappedFlag() || !read.getMateUnmappedFlag())  // at least one read is mapped
            && !iSizeTooBigToMove(read);                                     // insert size isn't too big

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

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

示例8: excludeReadFromBAQ

import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Returns true if we don't think this read is eligible for the BAQ calculation.  Examples include non-PF reads,
 * duplicates, or unmapped reads.  Used by baqRead to determine if a read should fall through the calculation.
 *
 * @param read
 * @return
 */
public boolean excludeReadFromBAQ(SAMRecord read) {
    // keeping mapped reads, regardless of pairing status, or primary alignment status.
    return read.getReadUnmappedFlag() || read.getReadFailsVendorQualityCheckFlag() || read.getDuplicateReadFlag();
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:12,代码来源:BAQ.java


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