IUBio GIL .. BIOSCI/Bionet News .. Biosequences .. Software .. FTP

Brookhaven awk script?

Stefan Portmann stefan at org.chem.ethz.ch
Thu Aug 10 08:43:01 EST 1995



--========================_6455518==_
Content-Type: text/plain; charset="us-ascii"

> I'm going to deposit structures of DNA from NMR to Brookhaven PDB.
>Does anyone have a awk script to convert a X-PLOR pdb format to a
>Does anyone have a awk script to convert the  X-PLOR pdb format to a
>Brookhaven format?
>
>Thanks in advance.
>
>                         Tomoko Nishizaki
>
>                     Faculty of Pharmaceutical Sciences
>                     Hokkaido Univ.Kitaku Sapporo 060 Japan
>                     Tel    : 011-706-3976
>                     Fax    : 011-706-4989
>                     E-mail : zaki at ph.hines.hokudai.ac.jp


I use the following script including coordconv and pdbset from the CCP4
package to convert XPLOR to PDB:



--========================_6455518==_
Content-Type: text/plain; name="xplor2pdb.sh"; charset="us-ascii"
Content-Disposition: attachment; filename="xplor2pdb.sh"

#!/bin/sh
#
# X-PLOR to PDB
# nawk sorts the atoms in the residue
# $1 is input file without extension
#
######################################################
#
cell="25.196  40.798  66.265  90.000  90.000  90.000"
space="P212121"
#
######################################################
#
grep -v 'END' $1.xpl > x.xpl
#
coordconv \
XYZIN x.xpl \
XYZOUT x.pdb \
<<eof
INPUT XPLOR
OUTPUT PDB ORTH 1
CELL $cell
END
eof
#
sed '1,$s/'"'"'/*/' x.pdb > xx.pdb; mv xx.pdb x.pdb
#
#
#
##########################################################
nawk '
BEGIN {
 resnbr1 = "   1"
 i = 0
 first = 1

	while(getline <"x.pdb"> 0 ) {
		if ($1 == "ATOM"){
                 i += 1
                 resnbr2 = getatom($0,i)
                  if (resnbr1 != resnbr2){
                   sort(resnbr1,first,i-1)
                   first = i
                 resnbr1 = resnbr2
                  }
		}
                else {
                 print
                }
        }
 sort(resnbr1,first,i)
}


function getatom(a,ln){
                    atom_array[ln,1]        = "ATOM"
                    atom_array[ln,2]        = substr(a,7,5)    # Nr
                    atom_array[ln,3]        = substr(a,13,4)   # Name
                    atom_array[ln,4]        = substr(a,18,3)   # ResName
                    atom_array[ln,5]        = substr(a,23,4)   # ResNr
                    atom_array[ln,6]        = substr(a,31,8)   # X
                    atom_array[ln,7]        = substr(a,39,8)   # Y
                    atom_array[ln,8]        = substr(a,47,8)   # Z
                    atom_array[ln,9]        = substr(a,55,6)   # O
                    atom_array[ln,10]       = substr(a,61,6)   # T

                    return atom_array[ln,5]
}


function sort(n,fir,lst){
                 rtyp = atom_array[lst,4]
                 if ( rtyp ~ "GUA" ) { guanin(n,fir,lst)  }
                 if ( rtyp ~ "CYT" ) { cytosin(n,fir,lst) }
                 if ( rtyp ~ "ADE" ) { adenin(n,fir,lst)  }
                 if ( rtyp ~ "THY" ) { thymin(n,fir,lst)  }
                 if ( rtyp ~ "MCT" ) { mct(n,fir,lst)  }
                 if ( rtyp ~ "TIP" ) { print_atom(fir)  }
                 if ( rtyp ~ "SP " ) { print_atom(fir)  }
}


function cytosin(n,fir,lst){
                      search_atom(" P  ",n,fir,lst)
                      search_atom(" O1P",n,fir,lst)
                      search_atom(" O2P",n,fir,lst)
                      search_atom(" O5*",n,fir,lst)
                      search_atom(" C5*",n,fir,lst)
                      search_atom(" C4*",n,fir,lst)
                      search_atom(" O4*",n,fir,lst)
                      search_atom(" C3*",n,fir,lst)
                      search_atom(" O3*",n,fir,lst)
                      search_atom(" C2*",n,fir,lst)
                      search_atom(" O2*",n,fir,lst)
                      search_atom(" C1*",n,fir,lst)
                      search_atom(" N1 ",n,fir,lst)
                      search_atom(" C2 ",n,fir,lst)
                      search_atom(" O2 ",n,fir,lst)
                      search_atom(" N3 ",n,fir,lst)
                      search_atom(" C4 ",n,fir,lst)
                      search_atom(" N4 ",n,fir,lst)
                      search_atom(" C5 ",n,fir,lst)
                      search_atom(" C6 ",n,fir,lst)


}

function guanin(n,fir,lst){
                      search_atom(" P  ",n,fir,lst)
                      search_atom(" O1P",n,fir,lst)
                      search_atom(" O2P",n,fir,lst)
                      search_atom(" O5*",n,fir,lst)
                      search_atom(" C5*",n,fir,lst)
                      search_atom(" C4*",n,fir,lst)
                      search_atom(" O4*",n,fir,lst)
                      search_atom(" C3*",n,fir,lst)
                      search_atom(" O3*",n,fir,lst)
                      search_atom(" C2*",n,fir,lst)
                      search_atom(" O2*",n,fir,lst)
                      search_atom(" C1*",n,fir,lst)
                      search_atom(" N9 ",n,fir,lst)
                      search_atom(" C8 ",n,fir,lst)
                      search_atom(" N7 ",n,fir,lst)
                      search_atom(" C5 ",n,fir,lst)
                      search_atom(" C6 ",n,fir,lst)
                      search_atom(" O6 ",n,fir,lst)
                      search_atom(" N1 ",n,fir,lst)
                      search_atom(" C2 ",n,fir,lst)
                      search_atom(" N2 ",n,fir,lst)
                      search_atom(" N3 ",n,fir,lst)
                      search_atom(" C4 ",n,fir,lst)
}

function adenin(n,fir,lst){
                      search_atom(" P  ",n,fir,lst)
                      search_atom(" O1P",n,fir,lst)
                      search_atom(" O2P",n,fir,lst)
                      search_atom(" O5*",n,fir,lst)
                      search_atom(" C5*",n,fir,lst)
                      search_atom(" C4*",n,fir,lst)
                      search_atom(" O4*",n,fir,lst)
                      search_atom(" C3*",n,fir,lst)
                      search_atom(" O3*",n,fir,lst)
                      search_atom(" C2*",n,fir,lst)
                      search_atom(" O2*",n,fir,lst)
                      search_atom(" C1*",n,fir,lst)
                      search_atom(" N9 ",n,fir,lst)
                      search_atom(" C8 ",n,fir,lst)
                      search_atom(" N7 ",n,fir,lst)
                      search_atom(" C5 ",n,fir,lst)
                      search_atom(" C6 ",n,fir,lst)
                      search_atom(" N6 ",n,fir,lst)
                      search_atom(" N1 ",n,fir,lst)
                      search_atom(" C2 ",n,fir,lst)
                      search_atom(" N3 ",n,fir,lst)
                      search_atom(" C4 ",n,fir,lst)

}

function mct(n,fir,lst){
                      search_atom(" P  ",n,fir,lst)
                      search_atom(" O1P",n,fir,lst)
                      search_atom(" O2P",n,fir,lst)
                      search_atom(" O5*",n,fir,lst)
                      search_atom(" C5*",n,fir,lst)
                      search_atom(" C4*",n,fir,lst)
                      search_atom(" C6*",n,fir,lst)
                      search_atom(" C7*",n,fir,lst)
                      search_atom(" C3*",n,fir,lst)
                      search_atom(" O3*",n,fir,lst)
                      search_atom(" C2*",n,fir,lst)
                      search_atom(" O2*",n,fir,lst)
                      search_atom(" C1*",n,fir,lst)
                      search_atom(" N1 ",n,fir,lst)
                      search_atom(" C2 ",n,fir,lst)
                      search_atom(" O2 ",n,fir,lst)
                      search_atom(" N3 ",n,fir,lst)
                      search_atom(" C4 ",n,fir,lst)
                      search_atom(" O4 ",n,fir,lst)
                      search_atom(" C5 ",n,fir,lst)
                      search_atom(" C5A",n,fir,lst)
                      search_atom(" C6 ",n,fir,lst)
}

function thymin(n,fir,lst){
                      search_atom(" P  ",n,fir,lst)
                      search_atom(" O1P",n,fir,lst)
                      search_atom(" O2P",n,fir,lst)
                      search_atom(" O5*",n,fir,lst)
                      search_atom(" C5*",n,fir,lst)
                      search_atom(" C4*",n,fir,lst)
                      search_atom(" O4*",n,fir,lst)
                      search_atom(" C3*",n,fir,lst)
                      search_atom(" O3*",n,fir,lst)
                      search_atom(" C2*",n,fir,lst)
                      search_atom(" O2*",n,fir,lst)
                      search_atom(" C1*",n,fir,lst)
                      search_atom(" N1 ",n,fir,lst)
                      search_atom(" C2 ",n,fir,lst)
                      search_atom(" O2 ",n,fir,lst)
                      search_atom(" N3 ",n,fir,lst)
                      search_atom(" C4 ",n,fir,lst)
                      search_atom(" O4 ",n,fir,lst)
                      search_atom(" C5 ",n,fir,lst)
                      search_atom(" C5A",n,fir,lst)
                      search_atom(" C6 ",n,fir,lst)
}

function print_atom(b){
                    printf "%-4s%7d %-4s %3s  %4d    %8.3f%8.3f%8.3f%6.2f%6.2f\n",
	             atom_array[b,1],atom_array[b,2],atom_array[b,3],atom_array[b,4],

atom_array[b,5],atom_array[b,6],atom_array[b,7],atom_array[b,8],
                     atom_array[b,9],atom_array[b,10]



}

function search_atom(name,n,fir,lst){
                  while ( fir <= lst ){
                   if ( atom_array[fir,3] == name ){
                    print_atom(fir)
                   }
                   fir += 1
                  }


}
' > xx.pdb
#
################################################################################
#
mv xx.pdb x.pdb
#
pdbset \
  xyzin  x.pdb \
  xyzout xx.pdb \
  <<eof-1
renumber 1
cell $cell
spacegroup $space
eof-1
#
sed '1,$s/CYT/  C/' xx.pdb > x.pdb; mv x.pdb xx.pdb
sed '1,$s/GUA/  G/' xx.pdb > x.pdb; mv x.pdb xx.pdb
sed '1,$s/ADE/  A/' xx.pdb > x.pdb; mv x.pdb xx.pdb
sed '1,$s/THY/  T/' xx.pdb > x.pdb; mv x.pdb xx.pdb
sed '1,$s/TIP/HOH/' xx.pdb > x.pdb; mv x.pdb xx.pdb

mv xx.pdb $1.pdb

/bin/rm x.xpl
#



--========================_6455518==_
Content-Type: text/plain; charset="us-ascii"

##############################################################################
# Stefan Portmann                                                            #
# Organic Chemistry Laboratory                                               #
# ETH Swiss Federal Institute of Technology                                  #
# CH-8092 Zuerich                                                            #
# Switzerland                                                                #
#                                                                            #
# e-mail stefan at org.chem.ethz.ch                                             #
# phone 01 632 66 38                                                         #
############################################################################
##



--========================_6455518==_--




More information about the X-plor mailing list

Send comments to us at archive@iubioarchive.bio.net