def IsAllIdenticalTopology(topoList): #{{{ numSeq = len(topoList) if numSeq <= 1: return True else: posTMList = [myfunc.GetTMPosition(topo) for topo in topoList] NtermStateList = [lcmp.GetNtermState(topo) for topo in topoList] numTMList = [len(posTM) for posTM in posTMList] for i in xrange(numSeq - 1): for j in xrange(i + 1, numSeq): if not lcmp.IsIdenticalTopology( NtermStateList[i], NtermStateList[j], numTMList[i], numTMList[j], posTMList[i], posTMList[j], topoList[i], topoList[j], min_TM_overlap): return False return True
def CountIdenticalTopology(pred_topodict, real_topodict, agreement, TM_type, fpout_wrong, seqDict, pred_method_item): #{{{ """ return (cntIDT, cntINV) """ numPredTopo = len(pred_topodict) cntIDT = 0 cntINV = 0 cntDIFF = 0 for seqid in pred_topodict: predtopo = pred_topodict[seqid] try: realtopo = real_topodict[seqid] except KeyError: print >> sys.stderr, "%s a nonTM protein predicted as TM protein" % ( seqid) realtopo = "i" * len(predtopo) pass pred_NtermState = lcmp.GetNtermState(predtopo) real_NtermState = lcmp.GetNtermState(realtopo.replace('.', '-')) pred_posTM = myfunc.GetTMPosition(predtopo) real_posTM = myfunc.GetTMPosition(realtopo) pred_numTM = len(pred_posTM) real_numTM = len(real_posTM) # if g_params['isDEBUG'] and seqid == "3cx5I": # print "pred_NtermState = <%s>"%pred_NtermState # print "real_NtermState = <%s>"% real_NtermState # print "pred_posTM = ", pred_posTM # print "real_posTM = ", real_posTM if lcmp.IsIdenticalTopology(pred_NtermState, real_NtermState, pred_numTM, real_numTM, pred_posTM, real_posTM, predtopo, realtopo, g_params['min_TM_overlap']): cntIDT += 1 else: if fpout_wrong != None: # output the wrongly predict topology fpout_wrong.write(">%s Number %d mtd_%s\n" % (seqid, cntDIFF + 1, pred_method_item)) try: seq = seqDict[seqid] fpout_wrong.write("%-10s %s\n" % ("AASeq", seq)) except KeyError: seq = "" fpout_wrong.write("%-10s %s\n" % ("RealTop", realtopo)) fpout_wrong.write("%-10s %s\n" % ("PredTop", predtopo)) fpout_wrong.write("\n") if lcmp.IsInvertedTopology(pred_NtermState, real_NtermState, pred_numTM, real_numTM, pred_posTM, real_posTM, predtopo, realtopo, g_params['min_TM_overlap']): cntINV += 1 if g_params['isDEBUG']: print >> sys.stderr, "%-7s(real %3s) nTM=%2d %s" % ( seqid, agreement, real_numTM, realtopo) print >> sys.stderr, "%-7s(pred %3s) nTM=%2d %s" % ( seqid, agreement, pred_numTM, predtopo) print >> sys.stderr cntDIFF += 1 return (cntIDT, cntINV)