IntroductionNumberingSequencesStructuresModellingMacrosPublicationsLinks
ColoringSequence StatisticsRenumberingAccessibilityTorsion AnglesStructural VariabilityHydrogen BondsDownloads

Macro AA_SeqLength

Counts the number of valid amino acid within each of the sequences in the selected sequence block. The result is placed in the first column to the right of the selected sequence block

Usage:

  • Select the range of cells containing the amino acids to be counted
  • Choose "Macro" for the "Tool" menu
  • Run macro AA_SeqLength

Caution:

The cell immediatly to the right of the selected sequence block will be overwritten by the results
Sub AA_SeqLength()

'Counts number of valid amino acid within the selected sequences
'The result is placed in the column following the selected 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
   
    For i = i1 To i2 Step 1
        a = 0
        For j = j1 To j2 Step 1     'row i1-i2, column j1-j2'
            If Not (Cells(i, j) = "" Or Cells(i, j) = "." Or Cells(i, j) = " ") Then a = a + 1
        Next j
        Cells(i, j2 + 1) = a
    Next i
    
    'Format result
    Range(Cells(i1, j2 + 1), Cells(i2, j2 + 1)).Select
        Selection.ColumnWidth = 5
        Selection.NumberFormat = "0"
        Selection.Font.Bold = True
        Selection.HorizontalAlignment = xlCenter
        Selection.VerticalAlignment = xlCenter

End Sub
AAAAA Homepage Zürich University Dept. of Biochemistry Plückthun Group Annemarie Honegger

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