예제 #1
0
def find_entry_score(ln, l, aliFormat, pScoreCutoff):
    mxBitSc = 700
    sigma2 = 3
    skipFlag = False
    if (aliFormat == 0):  # gnu-sam
        pScore = float(l[12].split(':')[2])
        if (pScore < pScoreCutoff):
            skipFlag = True
    elif (aliFormat == 1):  # sam
        pScore = samUtils.findSamAlignScore(l)
        if pScore is None:
            mapq = float(l[4])
            mapq2 = mapq / (-10.0)
            pScore = 1.0 - pow(10, mapq2)
            if (pScore < pScoreCutoff):
                skipFlag = True
    elif (aliFormat == 2):  # bl8
        eVal = float(l[10])
        if (eVal > pScoreCutoff):
            skipFlag = True
        bitSc = float(l[11]) / sigma2
        if bitSc > mxBitSc:
            bitSc = mxBitSc
        pScore = math.exp(bitSc)
    #pScore = int(round(pScore*100)) # Converting to integer to conserve memory space
    #if pScore < 1:
    #	skipFlag = true
    return (pScore, skipFlag)
예제 #2
0
def find_entry_score(ln, l, aliFormat, pScoreCutoff):
	mxBitSc = 700
	sigma2 = 3
	skipFlag = False
	if (aliFormat == 0): # gnu-sam
		pScore = float(l[12].split(':')[2])
		if (pScore < pScoreCutoff):
			skipFlag = True
	elif (aliFormat == 1): # sam
		pScore = samUtils.findSamAlignScore(l)
		if pScore is None:
			mapq = float(l[4])
			mapq2 = mapq/(-10.0)
			pScore = 1.0 - pow(10,mapq2)
			if (pScore < pScoreCutoff):
				skipFlag = True
	elif (aliFormat == 2): # bl8
		eVal = float(l[10])
		if (eVal > pScoreCutoff):
			skipFlag = True
		bitSc = float(l[11])/sigma2
		if bitSc > mxBitSc:
			bitSc = mxBitSc
		pScore = math.exp(bitSc)
	#pScore = int(round(pScore*100)) # Converting to integer to conserve memory space
	#if pScore < 1:
	#	skipFlag = true
	return (pScore, skipFlag)
예제 #3
0
def extractRead(appendAlignFile, readFile):
	h_readId = {}
	with open(appendAlignFile,'r') as in1:
		with open(readFile,'w') as out1:
			for ln in in1:
				if (ln[0] == '@' or ln[0] == '#'):
					continue
				l = ln.split('\t')
				aScore = samUtils.findSamAlignScore(l)
				if (aScore is None):
					continue
				readId=l[0]
				score = h_readId.get(readId,None)
				if (score is None):
					h_readId[readId] = aScore
					sequence = l[9]
					quality = l[10]
					out1.write('@%s\n%s\n+\n%s\n' % (readId, sequence, quality))
예제 #4
0
def extractRead(appendAlignFile, readFile):
    h_readId = {}
    with open(appendAlignFile, 'r') as in1:
        with open(readFile, 'w') as out1:
            for ln in in1:
                if (ln[0] == '@' or ln[0] == '#'):
                    continue
                l = ln.split('\t')
                aScore = samUtils.findSamAlignScore(l)
                if (aScore is None):
                    continue
                readId = l[0]
                score = h_readId.get(readId, None)
                if (score is None):
                    h_readId[readId] = aScore
                    sequence = l[9]
                    quality = l[10]
                    out1.write('@%s\n%s\n+\n%s\n' %
                               (readId, sequence, quality))