IntroductionNumberingSequencesStructuresModellingMacrosPublicationsLinks
ColoringSequence StatisticsRenumberingAccessibilityTorsion AnglesStructural VariabilityHydrogen BondsDownloads

Macro AA_Parse

Converts a text string in a single cell or in several consecutive cells in the same column into individual characters in consecutive cells to the right of the source string. The original string will be deleted, the cells containing the parsed string formatted.

Usage:

  • Select the range of cells containing the sequences to be parsed (only one column)
  • Choose "Macro" for the "Tool" menu
  • Run macro AA_Parse
Caution:
Cells to the right of the selected cells will be overwritten by the parsed sequence.
Sequences containing more than 250 amino acids will be truncated.
The original sequences will be deleted


Sub AA_Parse()

    'converts a text string in a single cell into individual characters in consecutive cells
    'you can select a range of cells within the same column
    'do not select more than one column, cells to the right of this column will be overwritten

    If Selection.Columns.Count = 0 Then      'Error, nothing selected
        MsgBox Prompt:="No cells selected, please select the sequences you wish to parse"
        Exit Sub
    End If
    
    If Selection.Columns.Count > 1 Then      'Error, more than one column selected
        MsgBox Prompt:="More than one column selected, select only one column"
        Exit Sub
    End If
   
    'get extent of current selection
    i1 = Selection.Row
    i2 = i1 + Selection.Rows.Count - 1
    j = Selection.Column
    n = 0                                               'length of longest sequence

    For i = i1 To i2 Step 1                             'for all selected cells
        aaa = Cells(i, j)
        
            If TypeName(aaa) = "String" Then
                a = Len(aaa)
                
                If a > 254 - j Then                     'Not enough cells available for entire sequence
                    a = 250 - j
                    Msg = "The sequence is too long, only the first " & a & " amino acids used"
                    MsgBox Prompt:=Msg
                End If
                
                    If a > n Then n = a                 'determine length of longest sequence
                    
                    For k = 1 To a Step 1               'parse the sequence
                        Cells(i, j + k) = Mid(aaa, k, 1)
                    Next k
            Else
                                                        'Error, is not a character string
            End If
    
    Next i

    Selection.Delete Shift:=xlToLeft                    'Delete original strings
    Range(Cells(i1, j), Cells(i2, j + n)).Select        'select sequence alignment
    Selection.ColumnWidth = 1                           'set column width to 1

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

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