IntroductionNumberingSequencesStructuresModellingMacrosPublicationsLinks
ColoringSequence StatisticsRenumberingAccessibilityTorsion AnglesStructural VariabilityHydrogen BondsDownloads

Macro AA_Composition

Determines the amino acid composition of the sequences in an alignment

Usage:

  • Select the range of cells containing the sequences (Amino acids only, without the sequence labels)
  • Choose "Macro" for the "Tool" menu
  • Run macro "AA_Composition"

Caution:

Requires 55 free cells to the right of the sequence alignment

Sub AA_Composition()

'Determines absolute and relative frequencies of amino acids occuring in a given sequence
'based on a selected Sequence alignment
'The results are placed in 55 cells to the right of the sequence block
'
    If Selection.Columns.Count = 0 Then      'Error, nothing selected
        MsgBox Prompt:="No cells selected, please select the sequences you wish to process"
        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

    Cells(i1 - 1, j2 + 3) = "D"
    Cells(i1 - 1, j2 + 4) = "E"
    Cells(i1 - 1, j2 + 5) = "K"
    Cells(i1 - 1, j2 + 6) = "R"
    Cells(i1 - 1, j2 + 7) = "H"
    Cells(i1 - 1, j2 + 8) = "T"
    Cells(i1 - 1, j2 + 9) = "S"
    Cells(i1 - 1, j2 + 10) = "N"
    Cells(i1 - 1, j2 + 11) = "Q"
    Cells(i1 - 1, j2 + 12) = "G"
    Cells(i1 - 1, j2 + 13) = "A"
    Cells(i1 - 1, j2 + 14) = "C"
    Cells(i1 - 1, j2 + 15) = "P"
    Cells(i1 - 1, j2 + 16) = "V"
    Cells(i1 - 1, j2 + 17) = "I"
    Cells(i1 - 1, j2 + 18) = "L"
    Cells(i1 - 1, j2 + 19) = "M"
    Cells(i1 - 1, j2 + 20) = "F"
    Cells(i1 - 1, j2 + 21) = "Y"
    Cells(i1 - 1, j2 + 22) = "W"
    Cells(i1 - 1, j2 + 23) = "B"
    Cells(i1 - 1, j2 + 24) = "Z"
    Cells(i1 - 1, j2 + 25) = "X"
    Cells(i1 - 1, j2 + 26) = "sum"
    
    Cells(i1 - 1, j2 + 28) = "D"
    Cells(i1 - 1, j2 + 29) = "E"
    Cells(i1 - 1, j2 + 30) = "K"
    Cells(i1 - 1, j2 + 31) = "R"
    Cells(i1 - 1, j2 + 32) = "H"
    Cells(i1 - 1, j2 + 33) = "T"
    Cells(i1 - 1, j2 + 34) = "S"
    Cells(i1 - 1, j2 + 35) = "N"
    Cells(i1 - 1, j2 + 36) = "Q"
    Cells(i1 - 1, j2 + 37) = "G"
    Cells(i1 - 1, j2 + 38) = "A"
    Cells(i1 - 1, j2 + 39) = "C"
    Cells(i1 - 1, j2 + 40) = "P"
    Cells(i1 - 1, j2 + 41) = "V"
    Cells(i1 - 1, j2 + 42) = "I"
    Cells(i1 - 1, j2 + 43) = "L"
    Cells(i1 - 1, j2 + 44) = "M"
    Cells(i1 - 1, j2 + 45) = "F"
    Cells(i1 - 1, j2 + 46) = "Y"
    Cells(i1 - 1, j2 + 47) = "W"
    Cells(i1 - 1, j2 + 48) = "B"
    Cells(i1 - 1, j2 + 49) = "Z"
    Cells(i1 - 1, j2 + 50) = "X"
  
    For j = (j2 + 3) To (j2 + 26) Step 1
        For i = i1 To i2 Step 1
            Cells(i, j) = 0
        Next i
    Next j
  
    For j = j1 To j2 Step 1
        For i = i1 To i2 Step 1
        
            For k = (j2 + 3) To (j2 + 25) Step 1
                If Cells(i, j) Like Cells(i1 - 1, k) Then
                    Cells(i, k) = Cells(i, k) + 1
                    Cells(i, j2 + 26) = Cells(i, j2 + 26) + 1
                End If
            Next k
        Next i
    Next j
                    
    'Abs2Rel
    'Calculating relative Frequencies
   
    For i = i1 To i2 Step 1
        For k = j2 + 28 To j2 + 50 Step 1
            If (Cells(i, j2 + 26) > 0) Then
                Cells(i, k) = 100 * Cells(i, k - 25) / Cells(i, j2 + 26)
                Else: Cells(k, j) = "0"
            End If
        Next k
    Next i
    
    Range(Cells(i1 - 1, j2 + 3), Cells(i1 - 1, j2 + 50)).Select                   'legend
        Selection.ColumnWidth = 4
        Selection.Font.Size = 9
        Selection.Font.Bold = True
        Selection.HorizontalAlignment = xlCenter
    
    Range(Cells(i1, j2 + 3), Cells(i2, j2 + 25)).Select                           'absolut number of amino acids
        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 = xlNone
        Selection.Font.Bold = False
        Selection.NumberFormat = "0"
        
     Range(Cells(i1, j2 + 26), Cells(i2, j2 + 26)).Select
        Selection.ColumnWidth = 4
        Selection.Font.Size = 9
        Selection.Font.Bold = True
        Selection.NumberFormat = "0"
    
    Range(Cells(i1, j2 + 28), Cells(i2, j2 + 50)).Select                           'relative proportion of amino acids
        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 = xlNone
        Selection.Font.Bold = False
        Selection.NumberFormat = "0.0"
      
End Sub
AAAAA Homepage Zürich University Dept. of Biochemistry Plückthun Group Annemarie Honegger

Last Modified by A.Honegger Wednesday, January 26, 2005