[Chimera-users] Assigning pre-calculated attribute to B-factor column of pdb

Mark Girvin mark.girvin at einstein.yu.edu
Tue Aug 26 09:39:56 PDT 2014


Hi Oliver,

If you don't get any better suggestions/offers, and if having the same value for all atoms in a given residue is acceptable, below is an ancient, dirty perl script that might do the trick for you.

 - Mark

=========== Script: ==========
#!/usr/bin/perl
#
# Number2TempFactInPDB.pl
# USAGE: Number2TempFactInPDB.pl pdbfile temperaturefile > out_file.pdb
# 
# Takes a standard PDB file and a tab (or space)-delimeted text file of the form:
# Res#  Value (value range = 0 to 100.0)
# and for each residue, inserts the value into the temperature (B)-factor
# column of the PDB file, sending the result to standard output
#
# the information can then be used to color code a molecular image in most
# molec. graphics programs
#
# 12/31/02  mg


$PDBfile = $ARGV[0];
$TempFile = $ARGV[1];


open(TEMPFILE, $TempFile) or die "can't open Temperature file";
while(<TEMPFILE>) {
        @line = split;
        $Temper{$line[0]} = $line[1];
}
close(TEMPFILE);

open(PDBFILE, $PDBfile) or die "can't open PDB file";
while(<PDBFILE>) {
        $line = $_;
        @modified_line = readAtomLine($line);
        if (($modified_line[0] ne "ATOM  ")) {
                print $line;
                next
        }
        $resnum = $modified_line[8];
        $modified_line[14] = $Temper{$resnum};
        printAtomLine(@modified_line);
}
close(PDBFILE);


# Functions below:

#call as: @output_string = readAtomLine(input_line_as_string);
sub readAtomLine {
        $OuT[0] = substr $_[0], 0, 6;   #atom 1-6
        $OuT[1] = int(substr $_[0], 6, 5);      #atom serial number 7-11
        $OuT[2] = substr $_[0], 7, 1;   #???
        $OuT[3] = substr $_[0], 12, 4;  #atom name 13-16
        $OuT[4] = substr $_[0], 16, 1;  #alt loc indicator 17
        $OuT[5] = substr $_[0], 17, 3;  #res name 18-20
        $OuT[6] = substr $_[0], 20, 1;  #??? 21
        $OuT[7] = substr $_[0], 21, 1;  #chain ID 22
        $OuT[8] = int(substr $_[0], 22, 4);     #res seq number 23-26
        $OuT[9] = substr $_[0], 26, 4;  #icode for insert of residues 27 +
        $OuT[10] = substr $_[0], 30, 8; #X 8.3 31-38
        $OuT[11] = substr $_[0], 38, 8; #Y 8.3 39-46
        $OuT[12] = substr $_[0], 46, 8; #Z 8.3 47-54
        $OuT[13] = substr $_[0], 54, 6; # Occupancy 6.2 55-60
        $OuT[14] = substr $_[0], 60, 6; # B-factor 6.2 61-66
        $OuT[15] = substr $_[0], 66, 10;# Element right-justif (2) 77-78
        $OuT[16] = substr $_[0], 76, 2; # Element right-justif (2) 77-78
        $OuT[17] = substr $_[0], 78, 2; # Charge (right-just string(2) 79-80
        return @OuT;
}

sub printAtomLine {
        printf("%-6s%5d%1s%4s%1s%3s%1s%1s%4d%4s%8.3f%8.3f%8.3f%6.2f%6.2f%10s%2s%2s\n", @_);
}

========== end of script ========

________________________________________
From: chimera-users-bounces at cgl.ucsf.edu [chimera-users-bounces at cgl.ucsf.edu] on behalf of Oliver Clarke [olibclarke at gmail.com]
Sent: Tuesday, August 26, 2014 11:52 AM
To: chimera-users at cgl.ucsf.edu
Subject: [Chimera-users] Assigning pre-calculated attribute to B-factor column of pdb

Hi all,

Is there an easy way to assign a pre-calculated attribute (for example, ramachandran probability) to the b-factor (or occupancy) column of a pdb file using chimera?

I’d like to do this so I can color a pdb by ramachandran probability (or other custom attributes, e.g map-model correlation) and use it as a guide while rebuilding in Coot (which has options for coloring by b-factor or occupancy, but no other capacity for custom coloring of molecules).

Best,
Oliver.



_______________________________________________
Chimera-users mailing list
Chimera-users at cgl.ucsf.edu
http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users




More information about the Chimera-users mailing list