def best_blat_al(onequery_psltable, get_translocations = False): index1, index2, max_trans_score = -1,-1,-500000 qsize = onequery_psltable[0][10] scores = [int(match) + (int(repmatch)>>1) - int(mismatch) - int(qgapbases) - int(tgapbases) for [match, mismatch, repmatch, ncount, qgapcount, qgapbases, tgapcount, tgapbases, strand, qname, qsize, qstart, qend, tname, tsize, tstart, tend, blockcount, blocksizes, qstarts, qends] in onequery_psltable] max_score = max(scores) print(max_score) max_ind = scores.index(max_score) is_good = max_score >= 0.95*qsize #bug in the translocations part if get_translocations & not is_good: ind_product = [[ind1, ind2] for ind1 in range(0,len(scores)) for ind2 in range(0, len(scores)) if ind1 qend1) & (qstart2 > qstart1) & (qstart2 - qend1 in ran)) | ((qend1 > qend2) & (qstart1 > qstart2) & (qstart1 - qend2 in ran)): if (scores[ind1] + scores[ind2] > max_trans_score): index1, index2, max_trans_score = ind1, ind2, scores[ind1]+scores[ind2] if max_trans_score>max_score: print("Translocation detected") print(max_trans_score) return [onequery_psltable[index1], onequery_psltable[index2]] else: return[onequery_psltable[max_ind]] else: return [onequery_psltable[max_ind]] #best blat alignment for multiple queries def best_blat_alignment(psltable, writefile = ""): psldata = psltable[1:] best_alignment = [] best_alignment.append(psldata[0]) #print(psltable) q_names = set([pslrow[9] for pslrow in psldata]) print(q_names) for q_name in q_names: