
#replace some PDB AA name
atom resn newname=ASP  select="resn ASX"
atom resn newname=CYS  select="resn CYX CYM"
atom resn newname=GLU  select="resn GLX"
atom resn newname=HID  select="resn HIS"

#replace some PDB Nucelic name
atom resn newname=ADE select="resn A +A"
atom resn newname=CYT select="resn C +C"
atom resn newname=GUA select="resn G +G"
atom resn newname=INO select="resn I +I"
atom resn newname=THY select="resn T +T"
atom resn newname=URA select="resn U +U"

tell nseg select="ALL"  #tell segments count in the system
iseg=0
while($iseg<$nseg){    #loop over all segments
  tell segn $iseg select="ALL"   #tell segment name and residues count
  newsegn=""
  nlen=strlen($segn)
  if(strlen($segn)==1) {
     if($segtype=="protein")  newsegn="PRO$segn"
     else if($segtype=="dna") newsegn="DNA$segn"
     else if($segtype=="rna") newsegn="RNA$segn"
     else                     newsegn="HET$segn"
     if(!-z $newsegn) {
       atom segn newname="$newsegn" select="iseg $iseg" 
       echo -hs "rename segment $segn to $newsegn"
     }
  }
  iseg++
}


