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


Java SAMRecord.getReadPairedFlag方法代码示例

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


在下文中一共展示了SAMRecord.getReadPairedFlag方法的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: processSequence

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
@Override
public void processSequence(SAMRecord read) {

	int inferredInsertSize = Math.abs(read.getInferredInsertSize());

	reads++;

	if (read.getReadPairedFlag() && read.getProperPairFlag()) {
		if (inferredInsertSize > MAX_INSERT_SIZE) {
			log.debug("inferredInsertSize = " + inferredInsertSize);
			aboveMaxInsertLengthCount++;
		}
		else {
			if (inferredInsertSize >= insertLengthCounts.size()) {
				for (long i = insertLengthCounts.size(); i < inferredInsertSize; i++) {
					insertLengthCounts.add(0L);
				}
				insertLengthCounts.add(1L);
			}
			else {
				long existingValue = insertLengthCounts.get(inferredInsertSize);

				insertLengthCounts.set(inferredInsertSize, ++existingValue);
			}
		}
	}
	else {
		unpairedReads++;
	}
}
 
开发者ID:s-andrews,项目名称:BamQC,代码行数:31,代码来源:InsertLengthDistribution.java

示例3: processSequence

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
@Override
public void processSequence(SAMRecord sequence) {
	
	// extract the method used for generating the SAM/BAM file if present in the header file.
	if(!headerParsed) {
		String fullHeader = sequence.getHeader().getTextHeader();
		if(fullHeader != null) {
			String[] headerLines = fullHeader.split("@");
			for(int i=0; i<headerLines.length; i++) {
				if(headerLines[i].startsWith("PG")) {
					command += headerLines[i].replace("PG\t", "").replace('\t', ' ');
				}
			}
		}
		headerParsed = true;
	}
	
	
	actualCount++;
	if (!sequence.isSecondaryOrSupplementary()) {
		++primaryCount;
	}
	
	if (sequence.getReadPairedFlag()) {
		pairedCount++;
		if (sequence.getProperPairFlag()) properPairCount++;
		if (sequence.getMateUnmappedFlag() && ! sequence.getReadUnmappedFlag()) singletonCount++;
	}
	
	if (sequence.getReadUnmappedFlag()) unmappedCount++;
	if (sequence.getReadFailsVendorQualityCheckFlag()) qcFailCount++;
	if (sequence.getDuplicateReadFlag()) duplicateCount++;
	
}
 
开发者ID:s-andrews,项目名称:BamQC,代码行数:35,代码来源:BasicStatistics.java

示例4: convertToPairedEndFragment

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
public static SAMRecord convertToPairedEndFragment(SAMRecord rec) {
	int insertSize = Math.abs(rec.getInferredInsertSize());
	//TODO: possible to remove (insertSize > 0) clause? What does an insert size of 0 mean?
	if (rec.getReadPairedFlag() && rec.getProperPairFlag() && !rec.getReadUnmappedFlag() 
			&& (insertSize <= MAX_INSERT) && (rec.getAlignmentStart() < rec.getMateAlignmentStart())
			&& rec.getReferenceName() != "chrM") // current paired end representation doesn't do well with circular chromosomes
	{
		//We need to get the full fragment contained by read.getStart to pair.getEnd
		int readEnd=rec.getAlignmentEnd();
		int mateStart=rec.getMateAlignmentStart();
					
		//int extension = insertSize - rec.getReadLength();
		int extension=(mateStart-readEnd)+rec.getReadLength();
		if (extension <= MAX_INSERT) {
			String newRead = rec.getReadString() + StringUtils.repeat("N", extension);
			rec.setReadString(newRead);
			String newQual = StringUtils.repeat("A", newRead.length());
			if(!rec.getBaseQualityString().equals("*")) newQual = rec.getBaseQualityString() + StringUtils.repeat("A", extension);
			rec.setBaseQualityString(newQual);
			String newCigar=newRead.length()+"M";
			rec.setCigarString(newCigar);

			// Change attributes to represent single read
			rec.setMateReferenceName("*");
			rec.setMateAlignmentStart(0);
			rec.setFirstOfPairFlag(false);
			rec.setMateNegativeStrandFlag(false);
			rec.setMateUnmappedFlag(false);
			rec.setProperPairFlag(false);
			rec.setReadPairedFlag(false);
			rec.setSecondOfPairFlag(false);
		}
	} else {
		rec = null;
	}
	return rec;
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:38,代码来源:SAMPairedEndFileReader.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: setOptionsFromFile

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
private void setOptionsFromFile (File file) {

		// This just reads the first few thousand lines from the first file and
		// tries to set the preferences options to the correct defaults.
		
		SAMFileReader.setDefaultValidationStringency(SAMFileReader.ValidationStringency.SILENT);

		SAMFileReader inputSam = new SAMFileReader(file); 

		int lineCount = 0;
		// Now process the file

		boolean pairedEnd = false;
		boolean spliced = false;
		
		int maxQ = 0;
		
		
		for (SAMRecord samRecord : inputSam) {
			++lineCount;
			
			if (lineCount == 100000) break;
			
			if (samRecord.getMappingQuality() > maxQ) {
				maxQ = samRecord.getMappingQuality();
			}
			
			if (samRecord.getCigarString().contains("N")) {
				spliced = true;
			}
			if (samRecord.getReadPairedFlag()) {
				pairedEnd = true;
			}
			
		}
		
		inputSam.close();
		
		prefs.setPairedEnd(pairedEnd);
		prefs.setSpliced(spliced);
		prefs.setMinMappingQuality(Math.min(maxQ,20));
		

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


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