Hi,
    This is a good question, and I've been trying to do this myself.

My solution is somewhat crude: take two input PDB files, one containing the
majority that you want to keep, and one which acts as a mask to delete the
atoms which overlap from the two structures.

How do you define the overlapping region?  For me, I just calculated a box
around the masking pdb file, but it could be more elegantly done with a
proper mask.

Here is my solution, written in ruby (I haven't tried  scheme yet so I can't
do it in COOT). The script outputs the 'intersecting' residues as well as
the 'remaining' residues.

If your residues are symmetry related Jenny, you'll have to use Coot's
"File>Save Symmetry Coordinates" menu item to save the truly overlapping
coordinates of chains A and B, before using this script. It uses ruby and
bioruby ("apt-get install ruby-1.8 libbio-ruby" under Debian/Ubuntu).

If anyone has an easier or more elegant solution, it would be useful!

Mark

====delete_masked.rb================================================
#!/usr/bin/ruby1.8
# == delete_masked.rb
#
# == Synopsis
#
# Script to delete atoms masked by atoms
# from another superposed PDB file.
#
# A box around the atoms from the maskfile is
# used to delete residues from the second file.
#
# == Usage
#
#  delete_masked.rb -m <maskfile> -c <compfile> -o [outfile]
#
# -h, --help:           Show help (Optional)
#
# --maskfile, -m    Name of the input PDB file to be used for the coordinate
mask (Required)
#
# --compfile, -c    Name of the file to be compared to the maskfile
(Required)
#
# --outfile, -o        Name of the output file    (Optional)
# Default: masked.pdb

require 'getoptlong'
require 'bio/db/pdb'
require 'rdoc/usage'

if  (ARGV.length != 1) && (ARGV.length != 4) && (ARGV.length != 6)
 puts ARGV.length.to_s + " arguments"
 puts "Incorrect argument(s)"
  RDoc::usage(-1)
end

opts = GetoptLong.new(
                           ['--maskfile',   '-m',
GetoptLong::REQUIRED_ARGUMENT],
                           ['--compfile',   '-c',
GetoptLong::REQUIRED_ARGUMENT],
               ['--outfile',    '-o',   GetoptLong::OPTIONAL_ARGUMENT],
                           ['--help',       '-h',   GetoptLong::NO_ARGUMENT]
                           )

maskfile = nil
compfile = nil
chain = "A"
first = 1
last = 100000
opts.each do |opt, arg|
  case opt
    when '--help'
      RDoc::usage
    when '--maskfile'
      maskfile = arg.to_s
    when '--outfile'
      outfile = arg.to_s
    when '--compfile'
      compfile = arg.to_s
  end
end
if (first != 1)
    firstname =  "-" + first.to_s
else
    firstname = ""
end
if (last != 100000)
    lastname  =  "-" + last.to_s
else
    lastname = ""
end
maskfilebase = maskfile.gsub('.pdb','')
outfile1 ||= maskfilebase + "-deleted" ".pdb"
outfile2 ||= maskfilebase + "-masked" ".pdb"

file1 = File.new(maskfile).gets(nil)
file2 = File.new(compfile).gets(nil)
structure1 = Bio::PDB.new(file1)
xmin = 10000.0
ymin = 10000.0
zmin = 10000.0
xmax = -10000.0
ymax = -10000.0
zmax = -10000.0
structure1.each_atom do |atom|
  xyz = atom.xyz
  if xyz.x < xmin
    xmin = xyz.x
  end
  if xyz.y < ymin
    ymin = xyz.y
  end
  if xyz.z < zmin
    zmin = xyz.z
  end
  if xyz.x > xmax
    xmax = xyz.x
  end
  if xyz.y > ymax
    ymax = xyz.y
  end
  if xyz.z > zmax
    zmax = xyz.z
  end
end
deleted_atom_counter = 0
saved_atom_counter = 0
puts "Atoms are being deleted from this box:"
puts "X axis coordinates from min:" + xmin.to_s + " to max: " + xmax.to_s +
"\n"
puts "Y axis coordinates from min:" + ymin.to_s + " to max: " + ymax.to_s +
"\n"
puts "Z axis coordiantes from min:" + zmin.to_s + " to max: " + zmax.to_s +
"\n"
#Compare structure2
structure2 = Bio::PDB.new(file2)
deleted_fragment = ""
saved_fragment = ""
structure2.each_atom do |atom2|
xyz2 = atom2.xyz
  if xyz2.x > xmin && xyz2.x < xmax && xyz2.y > ymin && xyz2.y < ymax &&
xyz2.z > zmin && xyz2.z < zmax
        deleted_fragment << atom2.to_s
    deleted_atom_counter += 1
      else
        saved_fragment << atom2.to_s
    saved_atom_counter += 1
  end
end
outFh1 = File.new(outfile1, 'w')
puts "Writing #{deleted_atom_counter} deleted atoms to: #{outfile1}"
outFh1.puts deleted_fragment
outFh1.close
outFh2 = File.new(outfile2, 'w')
puts "Writing #{saved_atom_counter} masked atoms to: #{outfile2}"
outFh2.puts saved_fragment
outFh2.close
=====end of file===========================================


2008/8/7 jenny flower <[EMAIL PROTECTED]>

> Hello
>
> I have a partial model with 4 chains,  but some part of A chain is in B
> chain, can I merge the symmetry  related atoms to make a right A chain?
>
> thanks
>
> Qing Chen
>



-- 
Mark BROOKS
Telephone: 0169157968
Fax: 0169853715
Institut de Biochmie et de Biophysique Moleculaire et Cellulaire
UMR8619 - Bât 430 - Université de Paris-Sud
91405 Orsay CEDEX
Skype: markabrooks

Reply via email to