next up previous contents index
Next: model.restraints.spline() approximate Up: Calculation of spatial restraints Previous: model.restraints.unpick() unselect   Contents   Index

model.restraints.reindex() -- renumber MODEL2 restraints for MODEL

mdl = <model>   Input model, with old restraint numbering

Requirements:
restraints

Description:
This command renumbers atom indices in all restraints in memory. It is expected that the input restraints refer to mdl; the re-indexed restraints will correspond to MODEL. Only those restraints that have all atoms in MODEL will be selected. You can remove the others by model.restraints.condense(). This command is useful when the old restraints have to be used while changing from one topology model to another.

Example: examples/commands/reindex_restraints.py


# Example for: model.restraints.reindex()

# This will reindex restraints obtained previously for a simpler topology so 
# that they will now apply to a more complicated topology.

env = environ()
tpl = env.libs.topology
par = env.libs.parameters

# Generate the model for the simpler topology (CA only in this case):
tpl.read(file='$(LIB)/top_ca.lib')
par.read(file='$(LIB)/par_ca.lib')

code = '1fas'
mdl = model(env, file=code)
aln = alignment(env)
aln.append_model(mdl, atom_files=code, align_codes=code)
aln.append_model(mdl, atom_files=code+'.ca', align_codes=code+'-ca')
mdl.generate_topology(aln, sequence=code+'-ca')
mdl.transfer_xyz(aln)
mdl.build(initialize_xyz=False, build_method='INTERNAL_COORDINATES')
mdl.write(file=code+'.ca')

# Generate the restraints for the simpler topology:
mdl.restraints.make(aln, restraint_type='stereo', spline_on_site=False)
mdl.restraints.write(file='1fas-ca.rsr')
mdl.energy()

# Generate the model for the more complicated topology:
tpl.read(file='$(LIB)/top_heav.lib')
par.read(file='$(LIB)/par.lib')

mdl.read(file=code)
aln = alignment(env)
aln.append_model(mdl, atom_files=code, align_codes=code)
aln.append_model(mdl, atom_files=code+'.ini', align_codes=code+'-ini')
mdl.generate_topology(aln, sequence=code+'-ini')
mdl.transfer_xyz(aln)
mdl.write(file='1fas.ini')

mdl2 = model(env, file='1fas.ca')
mdl.restraints.reindex(mdl2)
mdl.restraints.write(file='1fas.rsr')
mdl.energy()



Ben Webb 2006-02-28