% ConvertPDB: Convert Protein Data Bank (PDB) File % to a simpler format % % Output is a file with one amino acid per row. % Each row contains four entries: % 1) One-letter amino acid code % 2) x-axis position % 3) y-axis position % 4) z-axis position % % Scott F. Smith % Department of Electrical and Computer Engineering % Boise State University % SFSmith@BoiseState.edu % % 17 February 2004 % Filename to read (PDB/fname.txt) and write(Simple/fname.txt) fname = '1gcv'; % Open files fidPDB = fopen(['PDB/' fname '.txt']); fidOut = fopen(['Simple/' fname '.txt'],'w'); % Process until the end of the input file StringCount = 1; while StringCount > 0 % Read line from PDB file [StringIn, StringCount] = fscanf(fidPDB,'%s',1); % If the line starts with "ATOM", use it if length(StringIn) > 3 if StringIn(1:4) == 'ATOM' % Ignore atom number [StringIn, StringCount] = fscanf(fidPDB,'%s',1); % If this atom is an alpha carbon, use it [StringIn, StringCount] = fscanf(fidPDB,'%s',1); if length(StringIn) > 1 if StringIn(1:2) == 'CA' % Get the type of amino acid and convert to single letter [StringIn, StringCount] = fscanf(fidPDB,'%s',1); AcidChar = StringIn(1); if StringIn(1:3) == 'PHE' AcidChar = 'F'; end if StringIn(1:3) == 'ASP' AcidChar = 'D'; end if StringIn(1:3) == 'GLU' AcidChar = 'E'; end if StringIn(1:3) == 'LYS' AcidChar = 'K'; end if StringIn(1:3) == 'ARG' AcidChar = 'R'; end if StringIn(1:3) == 'TYR' AcidChar = 'Y'; end if StringIn(1:3) == 'ASN' AcidChar = 'N'; end if StringIn(1:3) == 'GLN' AcidChar = 'Q'; end if StringIn(1:3) == 'TRP' AcidChar = 'W'; end if StringIn(1:3) == 'ASX' AcidChar = 'B'; end if StringIn(1:3) == 'GLX' AcidChar = 'Z'; end % Ignore amino acid number [StringIn, StringCount] = fscanf(fidPDB,'%s',1); % Get next string and check if it has a "." in it [StringIn, StringCount] = fscanf(fidPDB,'%s',1); NumbDecPoints = length(find(StringIn == '.')); % Get the x-axis location of this alpha carbon atom if NumbDecPoints > 0 Xloc = sscanf(StringIn,'%f',1); else [StringIn, StringCount] = fscanf(fidPDB,'%s',1); NumbDecPoints = length(find(StringIn == '.')); if NumbDecPoints > 0 Xloc = sscanf(StringIn,'%f',1); else [Xloc, StringCount] = fscanf(fidPDB,'%f',1); end end % Get the y-axis location of this alpha carbon atom [Yloc, StringCount] = fscanf(fidPDB,'%f',1); % Get the z-axis location of this alpha carbon atom [Zloc, StringCount] = fscanf(fidPDB,'%f',1); % Place values in output file fprintf(fidOut,'%c\t',AcidChar); fprintf(fidOut,'%.3f\t%.3f\t%.3f\r\n',[Xloc Yloc Zloc]); end end end end end % Close files fclose(fidPDB); fclose(fidOut);