IntroductionNumberingSequencesStructuresModellingMacrosPublicationsLinks
ColoringSequence StatisticsRenumberingAccessibilityTorsion AnglesStructural VariabilityHydrogen BondsDownloads

Macro PDB_GetFiles

xxx.

Usage:

  • xxx
  • xxx

Cauton:

xxx

Sub PDB_GetFiles()

'collects individual PDB files into a single workbook,
'formatted in such a way that "save as space delimited text"
'produces a correctly formatted pdb file
'all fields are defined as "text"

'filenames are listed in the first column of the "Files"-worksheet,
'the Excel file must be in the same folder as the data files

    WBname = ActiveWorkbook.Name
    For i = 1 To 250 Step 1
        If IsEmpty(Sheets("Files").Cells(i, 1)) Then Exit For
            FName = Sheets("Files").Cells(i, 1)
            Workbooks.OpenText FileName:=FName, Origin:= _
                xlMacintosh, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array( _
                0, 1), Array(6, 1), Array(11, 1), Array(12, 1), Array(16, 1), Array(17, 1), _
                Array(20, 1), Array(21, 1), Array(22, 1), Array(26, 1), Array(27, 1), Array(30, 1), _
                Array(38, 1), Array(46, 1), Array(54, 1), Array(60, 1), Array(66, 1), Array(72, 1), _
                Array(76, 1), Array(78, 1), Array(80, 1))
                
            Columns("A:A").Select                               'Column 1: Record Type, ATOM or HETATM
            Selection.ColumnWidth = 6
            
            Columns("B:B").Select                               'Column 2: Atom serial number
            Selection.ColumnWidth = 5
            
            Columns("C:C").Select                               'Column 3: not used
            Selection.ColumnWidth = 2                           'but sometimes inofficially contains modifier to Atom name
            Selection.HorizontalAlignment = xlRight
            
            Columns("D:D").Select                               'Column 4: Atom name
            Selection.ColumnWidth = 3
            Selection.HorizontalAlignment = xlLeft
            
            Columns("E:E").Select                               'Column 5: Alternate location indicator
            Selection.ColumnWidth = 1
            
            Columns("F:F").Select                               'Column 6: Residue name (SEQ)
            Selection.ColumnWidth = 3
            Selection.HorizontalAlignment = xlRight

            Columns("G:G").Select
            Selection.ColumnWidth = 1                           'Column 7: not used
        
            Columns("H:H").Select
            Selection.ColumnWidth = 1                           'Column 8: Chain identifier (CHAIN)
        
            Columns("I:I").Select
            Selection.ColumnWidth = 4                           'Column 9: Residue sequence number (LABEL)
        
            Columns("J:J").Select                               'Column 10: Insertion code
            Selection.ColumnWidth = 1
        
            Columns("K:K").Select                               'Column 11: not used
            Selection.ColumnWidth = 3
        
            Columns("L:L").Select                               'Column 12: X-coordinate
            Selection.ColumnWidth = 8
            Selection.NumberFormat = "0.000"
        
            Columns("M:M").Select                               'Column 13: Y-coordinate
            Selection.ColumnWidth = 8
            Selection.NumberFormat = "0.000"
        
            Columns("N:N").Select                               'Column 14: Z-coordinate
            Selection.ColumnWidth = 8
            Selection.NumberFormat = "0.000"
        
            Columns("O:O").Select                               'Column 15: Occupancy
            Selection.ColumnWidth = 6
            Selection.NumberFormat = "0.00"
        
            Columns("P:P").Select                               'Column 16: temperature factor
            Selection.ColumnWidth = 6
            Selection.NumberFormat = "0.00"
        
            Columns("Q:Q").Select                               'Column 17: not used
            Selection.ColumnWidth = 6
        
            Columns("R:R").Select                               'Column 18: Segment identifier
            Selection.ColumnWidth = 4
            Selection.HorizontalAlignment = xlLeft
        
            Columns("S:S").Select                               'Column 19: Segment identifier
            Selection.ColumnWidth = 2
            Selection.HorizontalAlignment = xlRight
        
            Columns("T:T").Select                               'Column 20: Segment identifier
            Selection.ColumnWidth = 2
       
            For j = 1 To 32768 Step 1                           'Delete any records which are not ATOM or HETATM records
                If IsEmpty(Cells(j, 1)) Then Exit For
                    If Not ((Cells(j, 1) = "ATOM") Or (Cells(j, 1) = "HETATM")) Then
                        Rows(j).Select
                        Selection.Delete Shift:=xlUp
                        j = j - 1
                End If
            Next j
            
        Sheets(FName).Move After:=Workbooks(WBname).Sheets(i)

    Next i
    
End Sub

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

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