PEATDB/sequence_alignment.py
def calc_identity(seq1,seq2):
    """Calculate the sequence identity for these two aligned sequences"""
    id=0
    if len(seq1)!=len(seq2):
        print 'Sequences have different length! %d %d' %(len(seq1),len(seq2))
        raise Exception('Incorrect alignment')
    #
    for pos in range(len(seq1)):
        if seq1[pos]==seq2[pos] and seq1[pos]!='-':
            id=id+1
    print 'ID',id
    s1=seq1.replace('-','')
    s2=seq2.replace('-','')
    return max(float(id)/len(s1),float(id)/len(s2))*100.0
Calculate the sequence identity for these two aligned sequences
Calculate the sequence identity for these two aligned sequences
Calculate the sequence identity for these two aligned sequences
def calc_identity(seq1,seq2):
    id=0
    if len(seq1)!=len(seq2):
        print 'Sequences have different length! %d %d' %(len(seq1),len(seq2))
        raise Exception('Incorrect alignment')
    for pos in range(len(seq1)):
        if seq1[pos]==seq2[pos] and seq1[pos]!='-':
            id=id+1
    print 'ID',id
    s1=seq1.replace('-','')
    s2=seq2.replace('-','')
    return max(float(id)/len(s1),float(id)/len(s2))*100.0
def calc_identity ( seq1 , seq2 ) : id = 0 if len ( seq1 ) != len ( seq2 ) : print 'Sequences have different length! %d %d' % ( len ( seq1 ) , len ( seq2 ) ) raise Exception ( 'Incorrect alignment' ) for pos in range ( len ( seq1 ) ) : if seq1 [ pos ] == seq2 [ pos ] and seq1 [ pos ] != '-' : id = id + 1 print 'ID' , id s1 = seq1 . replace ( '-' , '' ) s2 = seq2 . replace ( '-' , '' ) return max ( float ( id ) / len ( s1 ) , float ( id ) / len ( s2 ) ) * 100.0
Calculate the sequence identity for these two aligned sequences
Calculate the sequence identity for these two aligned sequences
"""Calculate the sequence identity for these two aligned sequences""" #
seq1
seq2