本文整理汇总了Java中net.sf.samtools.SAMRecord.getProperPairFlag方法的典型用法代码示例。如果您正苦于以下问题:Java SAMRecord.getProperPairFlag方法的具体用法?Java SAMRecord.getProperPairFlag怎么用?Java SAMRecord.getProperPairFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.samtools.SAMRecord
的用法示例。
在下文中一共展示了SAMRecord.getProperPairFlag方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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++;
}
}
示例2: 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++;
}
示例3: 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;
}
示例4: 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++;
}
}
}
示例5: 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++;
}
}
}
示例6: 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++;
}
}
}
示例7: 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;
}