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


Java SAMRecord.getReadName方法代码示例

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


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

示例1: sourceReads

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Get the reads from the appropriate source (implementation-specific).
 * Loads data to the fivePrimesList and hitsCountList
 */
public void sourceReads() {
	this.initialize();
	SAMFileReader reader = new SAMFileReader(file);
	reader.setValidationStringency(ValidationStringency.SILENT);
	CloseableIterator<SAMRecord> iter = reader.iterator();
	Collection<SAMRecord> byRead = new ArrayList<SAMRecord>();
	String lastread = null;
	while (iter.hasNext()) {
	    SAMRecord record = iter.next();
	    
	    if (record.getReadUnmappedFlag()) {continue; }
	    if (lastread == null || !lastread.equals(record.getReadName())) {
	    	processRead(byRead);
	    	byRead.clear();
	    }
	    lastread = record.getReadName();
	    byRead.add(record);
		    
	}
	processRead(byRead);
	iter.close();
	reader.close();
   }
 
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:28,代码来源:SAMFileHitLoader.java

示例2: read_Reads

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
/**
 * Reads the read alignments
 * reference ID format is
 *   [genome|nogenome]:[library]:[referenceID]
 * e.g.
 *   genome:miRNA:hsa-mir-486-1:MI0002470:Homo:sapiens:miR-486:stem-loop
 * 
 * @param path_readAlignments
 * @throws IOException 
 */

public boolean read_Reads(SAMFileReader inputSam) throws IOException{
	inputSam.setValidationStringency(ValidationStringency.SILENT);
	//inputSam.setValidationStringency(ValidationStringency.LENIENT);

	// TODO: put this if/else back when we're done testing
	//if(inputSam.getFileHeader().getSortOrder().equals(SAMFileHeader.SortOrder.queryname)){
	SAMRecord thisRecord;
	HashMap<SAMRecord, String> thisRead = new HashMap<SAMRecord, String>(); 
	SAMRecordIterator it = inputSam.iterator();
	String lastReadID = null;
	while(it.hasNext()){
		//count++;
		thisRecord = it.next();

		//System.out.println(thisRecord.getReferenceName());
		if(!thisRecord.getReadName().equals(lastReadID)  &&  lastReadID != null){
			// new, non first
			assignRead(thisRead);
			thisRead = new HashMap<SAMRecord, String>();
		}

		// put the SAM record into the map with the library type as the value
		//thisRead.put(thisRecord, thisRecord.getReferenceName().split(":")[1]);

		if(_forceLibrary != null)
			thisRead.put(thisRecord, _forceLibrary);
		else
			thisRead.put(thisRecord, thisRecord.getReferenceName().split(":")[0]);
		lastReadID = thisRecord.getReadName();

	}
	// assign the final read!
	if(thisRead.size() > 0)
		assignRead(thisRead);

	/*}else{
	Thunder.printLineErr("ERROR: Input SAM file must be sorted by readID");
	inputSam.close();
	return false;
	}*/

	inputSam.close();
	return true;
}
 
开发者ID:gersteinlab,项目名称:exceRpt,代码行数:56,代码来源:ProcessEndogenousAlignments.java

示例3: countReads

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
protected void countReads() {
readLength=-1;
totalHits=0;
totalWeight=0;

SAMFileReader reader = new SAMFileReader(inFile);
CloseableIterator<SAMRecord> iter = reader.iterator();
Collection<SAMRecord> byRead = new ArrayList<SAMRecord>();
String lastread = null;
while (iter.hasNext()) {
    currID++;
    SAMRecord record = iter.next();
    if(readLength ==-1)
    	readLength = record.getReadLength();
    
    if (record.getReadUnmappedFlag()) {continue; }
    if (lastread == null || !lastread.equals(record.getReadName())) {
    	processRead(byRead);
    	byRead.clear();
    }
    lastread = record.getReadName();
    byRead.add(record);
	    
}
processRead(byRead);
iter.close();
reader.close();
populateArrays();
  }
 
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:30,代码来源:SAMReader.java

示例4: toFastq

import net.sf.samtools.SAMRecord; //导入方法依赖的package包/类
private String toFastq(SAMRecord value1) {
	String seq=value1.getReadString();
	if(value1.getReadNegativeStrandFlag()){
		seq=Sequence.reverseSequence(seq);
	}
	String name=value1.getReadName();
	String quality=value1.getBaseQualityString();
	return name+"\n"+seq+"\n"+"+\n"+quality;
}
 
开发者ID:mgarber,项目名称:scriptureV2,代码行数:10,代码来源:ReadSimulator2.java

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


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