Macro AA_DifferencesThis macro counts the number of sequence differences between two adjacent sequences in an alignment and highlights the individual differences. Usage:
Caution:
Sub AA_Differences() 'highlights positions which are different in adjacent sequences 'counts number of sequence differences (gaps/insertions do not count as differences) If Selection.Columns.Count = 0 Then 'Error, nothing selected MsgBox Prompt:="No cells selected, please select the sequences you wish to color" Exit Sub End If 'get extent of current selection i1 = Selection.Row i2 = i1 + Selection.Rows.Count - 1 j1 = Selection.Column j2 = j1 + Selection.Columns.Count - 1 'Format selected area Selection.Borders(xlLeft).LineStyle = xlNone Selection.Borders(xlRight).LineStyle = xlNone Selection.Borders(xlTop).LineStyle = xlNone Selection.Borders(xlBottom).LineStyle = xlNone Selection.BorderAround Weight:=xlThick Selection.Interior.ColorIndex = 2 Selection.Font.Name = "Geneva" Selection.Font.FontStyle = "Regular" Selection.Font.Size = 9 Selection.Font.ColorIndex = 1 Selection.Font.Bold = True Selection.HorizontalAlignment = xlCenter Selection.VerticalAlignment = xlCenter For i = i1 To i2 Step 1 Cells(i, j2 + 2) = 0 Next i For j = j1 To j2 Step 1 For i = i1 To i2 - 1 Step 1 If (Cells(i, j) = Cells(i + 1, j)) Then Cells(i, j).Select With Selection.Interior .ColorIndex = 2 .Pattern = xlSolid Selection.Font.ColorIndex = 1 End With Else If ((Cells(i + 1, j) = ".") Or (Cells(i, j) = ".")) Then Else Cells(i, j).Select With Selection.Interior .ColorIndex = 1 .Pattern = xlSolid Selection.Font.ColorIndex = 2 End With Cells(i, j2 + 2) = Cells(i, j2 + 2) + 1 End If End If Next i Next j End Sub |
|
|||||||||||||||||
Last Modified by A.Honegger |