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


Java SAMRecord.getFirstOfPairFlag方法代码示例

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


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

示例1: count

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
private void count(int adjustedStart, int adjustedEnd, ReadCounter counter, SAMRecord alignment) {
	
	
	for (int pos = adjustedStart; pos < adjustedEnd; pos++) {
		if (!alignment.getReadPairedFlag()||alignment.getFirstOfPairFlag()) {
			if (!alignment.getReadNegativeStrandFlag())
				counter.incrementCount(pos,ReadType.FIRSTREADFORWARDMAP);
			else
				counter.incrementCount(pos,ReadType.FIRSTREADREVERSEMAP);
		}else{
			if (!alignment.getReadNegativeStrandFlag())
				counter.incrementCount(pos,ReadType.SECONDREADFORWARDMAP);
			else
				counter.incrementCount(pos,ReadType.SECONDREADREVERSEMAP);
		}
	}
	
}
 
开发者ID:AbeelLab,项目名称:genometools,代码行数:19,代码来源:CoverageCounter.java

示例2: acceptRead

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
@Override
protected void acceptRead(final SAMRecord rec, final ReferenceSequence refSeq) {
	Alignment read = new SingleEndAlignment(rec);
	Annotation closest = excludedRegions.getClosest(read);
	if (closest != null && closest.overlaps(read, BUFFER)) {
		if (closest.getStrand() == read.getStrand() && !rec.getFirstOfPairFlag() ||
				closest.getStrand() != read.getStrand() && rec.getFirstOfPairFlag()) {
			++excludedCount;
		} else {
			++excludedCountAntisense;
		}
	} else {
		super.acceptRead(rec, refSeq);
	}
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:16,代码来源:CollectRnaSeqMetrics.java

示例3: updateNumHits

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
private void updateNumHits(SAMRecord record) {
	Object nh=record.getAttribute("NH");
	
	if(nh!=null){
		int num=new Integer(nh.toString());
		//if the next hit is on a different chromosome
		Object cc=record.getAttribute("CC");			
		//IF NH > 1
			// IF NEXT ALIGNMENT IS NOT ON THE SAME CHROMOSOME
			//TODO: CHECK IF DISTANCE TO TOO FAR, THEN WRITE THIS ONE
			// OR 
			// IF NH>1 && cc==null meaning this is the last alignment in a multi-mapped read alignment
		if(num>1){// && ((cc!=null && !cc.toString().equals("="))||(cc==null))){
			if(record.getFirstOfPairFlag()){
				numHits.setValue1(getValue1().size());
			}
			else{
				numHits.setValue2(getValue2().size());
			}
		}
		// IF NH ==1
		// OR
		// IF NH>1 && NEXT ALIGNMENT IS ON THE SAME CHROMOSOME
		else{
			if(record.getFirstOfPairFlag()){
				numHits.setValue1(num);
			}
			else{
				numHits.setValue2(num);
			}
		}
	}
	else{
		//The NH flag is not set so we will default to 1,1
		numHits=new Pair<Integer>(1,1);
	}
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:38,代码来源:AlignmentPair.java

示例4: getPairedEndRead

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Gets a paired end read.  This method assumes that it will only be passed reads which map
 * to the reverse strand since these are the ones which contain enough information to 
 * unambiguously locate both ends of the pair.
 * 
 * @param sections The tab split sections from the SAM file
 * @param flag The binary flag field
 * @return The read which was read
 * @throws SeqMonkException
 */
private SequenceReadWithChromosome getPairedEndRead (SAMRecord samRecord) throws SeqMonkException {
	int strand;
	int start;
	int end;

	if (!samRecord.getReadNegativeStrandFlag()) {
		throw new SeqMonkException("Read passed to parse pair was not on the negative strand");
	}
	
	if (samRecord.getMateNegativeStrandFlag()) {
		throw new SeqMonkException("Ignored discordantly stranded read pair");
	}
	
	end = samRecord.getAlignmentEnd();
	start = samRecord.getMateAlignmentStart();
	
	if (start > end) {
		throw new SeqMonkException("Ignored discordantly stranded read pair");
	}
	
	if (samRecord.getFirstOfPairFlag()) {
		strand = Location.REVERSE;
	}
	else {
		strand = Location.FORWARD;
	}
	
	if ((end - start)+1 > pairedEndDistance) {
		throw new SeqMonkException("Distance between ends "+((end - start)+1)+" was larger than cutoff ("+pairedEndDistance+")");
	}

	ChromosomeWithOffset c;

	try {
		c = dataCollection().genome().getChromosome(samRecord.getReferenceName());
	}
	catch (Exception e) {
		throw new SeqMonkException(e.getLocalizedMessage());
	}
	
	start = c.position(start);
	end = c.position(end);

	// We also don't allow readings which are beyond the end of the chromosome
	if (end > c.chromosome().length()) {
		int overrun = end - c.chromosome().length();
		throw new SeqMonkException("Reading position "+end+" was "+overrun+"bp beyond the end of chr"+c.chromosome().name()+" ("+c.chromosome().length()+")");
	}
	if (start < 1) {
		throw new SeqMonkException("Reading position "+start+" was before the start of chr"+c.chromosome().name()+" ("+c.chromosome().length()+")");			
	}

	// We can now make the new reading
	SequenceReadWithChromosome read = new SequenceReadWithChromosome(c.chromosome(),SequenceRead.packPosition(start,end,strand));

	return read;
}
 
开发者ID:s-andrews,项目名称:SeqMonk,代码行数:68,代码来源:BAMFileParser.java

示例5: processSAMRecord

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
public void processSAMRecord(SAMRecord r){
	totalReads++;
	if(!r.getReadUnmappedFlag()){
		totalHits++;
		int count = 1;  //Have to figure out something for BWA when reporting multiple alignments
		if(r.getIntegerAttribute("NH")!=null)
			count = r.getIntegerAttribute("NH");
		if(count==1 && r.getMappingQuality()!=0) //Second clause for BWA
			uniquelyMapped++;
		
		weight += 1/(float)count;

		if(r.getReadPairedFlag()){
			if(r.getMateUnmappedFlag()){
				singleEnd++;
			}else{
				pairMapped++;
				if(r.getMateReferenceName().equals(r.getReferenceName())){
					pairedEndSameChr++;
				}else{
					pairedEndDiffChr++;
				}
			}
		}else{
			singleEnd++;
		}
		
		List<AlignmentBlock> blocks = r.getAlignmentBlocks();
   		if(blocks.size()>=2){
   			junctions+=blocks.size()-1;
   		}
		
		if(!r.getNotPrimaryAlignmentFlag()){
			if(!r.getReadPairedFlag() || r.getFirstOfPairFlag()){
				LHits++;
				if(r.getReadPairedFlag() && r.getProperPairFlag()){
					properPair++;
					if(!r.getReadNegativeStrandFlag() && r.getMateNegativeStrandFlag()){
						double dist = (r.getMateAlignmentStart()+r.getReadLength())-r.getAlignmentStart();
						histo.addValue(dist);
					}
				}
			}else if(r.getSecondOfPairFlag()){
				RHits++;
			}
		}else{
			notPrimary++;
		}
	}
}
 
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:51,代码来源:SAMStats.java

示例6: processBT1SAMRecord

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
public void processBT1SAMRecord(SAMRecord r){
	totalReads++;
	if(!r.getReadUnmappedFlag())
		if(r.getIntegerAttribute("XM")!=null){
			int xm = r.getIntegerAttribute("XM");
			if(xm!=0)
				weight++;
		}
	else{
		totalHits++;
		int count =1; //TODO: Fix this if using bowtie for multi-mapping reads
		boolean currUnique = true;
    	
		if(count==1 && currUnique){
			uniquelyMapped++;
		}
		
		weight += 1/(float)count;
		
		if(r.getReadPairedFlag()){
			if(r.getMateUnmappedFlag()){
				singleEnd++;
			}else{
				pairMapped++;
				if(r.getMateReferenceName().equals(r.getReferenceName())){
					pairedEndSameChr++;
				}else{
					pairedEndDiffChr++;
				}
			}
		}else{
			singleEnd++;
		}
		
		List<AlignmentBlock> blocks = r.getAlignmentBlocks();
   		if(blocks.size()>=2){
   			junctions+=blocks.size()-1;
   		}
   		
		if(!r.getNotPrimaryAlignmentFlag()){
			if(!r.getReadPairedFlag() || r.getFirstOfPairFlag()){
				LHits++;
				if(r.getReadPairedFlag() && r.getProperPairFlag()){
					properPair++;
					if(!r.getReadNegativeStrandFlag() && r.getMateNegativeStrandFlag()){
						double dist = (r.getMateAlignmentStart()+r.getReadLength())-r.getAlignmentStart();
						histo.addValue(dist);
					}
				}
			}else if(r.getSecondOfPairFlag()){
				RHits++;
			}
		}else{
			notPrimary++;
		}
	}
}
 
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:58,代码来源:SAMStats.java

示例7: processBT2SAMRecord

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
public void processBT2SAMRecord(SAMRecord r){
	totalReads++;
	if(!r.getReadUnmappedFlag()){
		totalHits++;
		int count =1; //TODO: Fix this if using bowtie2 for multi-mapping reads
		
		int primAScore = r.getIntegerAttribute("AS");
    	int secAScore=-1000000;
    	if(r.getIntegerAttribute("XS")!=null)
    		secAScore = r.getIntegerAttribute("XS");
    	boolean currUnique = primAScore > secAScore ? true : false;
    	
		if(count==1 && currUnique){
			uniquelyMapped++;
		}
		
		weight += 1/(float)count;
		
		if(r.getReadPairedFlag()){
			if(r.getMateUnmappedFlag()){
				singleEnd++;
			}else{
				pairMapped++;
				if(r.getMateReferenceName().equals(r.getReferenceName())){
					pairedEndSameChr++;
				}else{
					pairedEndDiffChr++;
				}
			}
		}else{
			singleEnd++;
		}
		
		List<AlignmentBlock> blocks = r.getAlignmentBlocks();
   		if(blocks.size()>=2){
   			junctions+=blocks.size()-1;
   		}
   		
		if(!r.getNotPrimaryAlignmentFlag()){
			if(!r.getReadPairedFlag() || r.getFirstOfPairFlag()){
				LHits++;
				if(r.getReadPairedFlag() && r.getProperPairFlag()){
					properPair++;
					if(!r.getReadNegativeStrandFlag() && r.getMateNegativeStrandFlag()){
						double dist = (r.getMateAlignmentStart()+r.getReadLength())-r.getAlignmentStart();
						histo.addValue(dist);
					}
				}
			}else if(r.getSecondOfPairFlag()){
				RHits++;
			}
		}else{
			notPrimary++;
		}
	}
}
 
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:57,代码来源:SAMStats.java

示例8: getSamString

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Get sam line for record
 * @param rec The record
 * @return Sam formatted line ending in newline
 */
public static String getSamString(SAMRecord rec) {
	
	// Make string representation of record in sam format
	String rtrn = rec.getReadName() + "\t";
	
	// Get sam flags
	int flags = 0;
	// 0x1 template having multiple segments in sequencing
	if(rec.getReadPairedFlag()) flags += 1;
	// 0x4 segment unmapped
	if(rec.getReadUnmappedFlag()) flags += 4;
	// 0x10 SEQ being reverse complemented
	if(rec.getReadNegativeStrandFlag()) flags += 16;
	// 0x100 secondary alignment
	if(rec.getNotPrimaryAlignmentFlag()) flags += 256;
	// 0x200 not passing quality controls
	if(rec.getReadFailsVendorQualityCheckFlag()) flags += 512;
	// 0x400 PCR or optical duplicate
	if(rec.getDuplicateReadFlag()) flags += 1024;
	
	if(rec.getReadPairedFlag()) {
		// 0x2 each segment properly aligned according to the aligner
		if(rec.getProperPairFlag()) flags += 2;
		// 0x8 next segment in the template unmapped
		if(rec.getMateUnmappedFlag()) flags += 8;
		// 0x20 SEQ of the next segment in the template being reversed
		if(rec.getMateNegativeStrandFlag()) flags += 32;
		// 0x40 the first segment in the template
		if(rec.getFirstOfPairFlag()) flags += 64;
		// 0x80 the last segment in the template
		if(rec.getSecondOfPairFlag()) flags += 128;
	}
	
	rtrn += Integer.valueOf(flags).toString() + "\t";
	
	// The rest of the sam fields
	rtrn += rec.getReferenceName() + "\t";
	rtrn += rec.getAlignmentStart() + "\t";
	rtrn += rec.getMappingQuality() + "\t";
	rtrn += rec.getCigarString() + "\t";
	rtrn += rec.getMateReferenceName() + "\t";
	rtrn += rec.getMateAlignmentStart() + "\t";
	rtrn += rec.getInferredInsertSize() + "\t";
	rtrn += rec.getReadString() + "\t";
	rtrn += rec.getBaseQualityString() + "\n";
	
	return rtrn;
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:54,代码来源:SAMFragmentWriter.java

示例9: evaluate

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
@Override
public boolean evaluate(Alignment align) {
	SAMRecord samRecord = align.toSAMRecord();
	return samRecord.getFirstOfPairFlag();
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:6,代码来源:FirstOfPairFilter.java


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