## Residues and chains in multi-chain models

Just as MODELLER automatically assigns residue numbers starting from 1 for the model sequence, it automatically assigns chain IDs when building multi-chain models. Chain IDs are assigned alphabetically: A, B, etc. Thus, in the previous example (see Section 2.2.12) the model contains residues labeled 1 through 74 in chain A, and 75 through 148 in chain B. You can change this behavior and label the chains and residues yourself by calling model.rename_segments() from within the automodel.special_patches() method.

When building multi-chain models, you must always specify the chain ID when refering to an atom (see model.atoms) or residue (see Sequence.residues). MODELLER will not 'guess' the chain for you if you leave it out. For example, the CA atom in residue 30 in chain B can be specified with the identifier 'CA:30:B'.

In the example below, the model is relabeled to contain residues 1 through 74 in chain X and 1 through 74 in chain Y. A user-defined restraint is also added between two atoms in the new chain Y. Note that in this example the two chains are not constrained to be symmetric; however, the symmetry restraint from the previous example can be added in if desired.

Example: examples/automodel/model-multichain.py

```# Comparative modeling by the automodel class
#
# Demonstrates how to build multi-chain models
#
from modeller import *
from modeller.automodel import *    # Load the automodel class

log.verbose()

class MyModel(automodel):
def special_patches(self, aln):
# Rename both chains and renumber the residues in each
self.rename_segments(segment_ids=['X', 'Y'],
renumber_residues=[1, 1])
# Another way to label individual chains:
self.chains[0].name = 'X'
self.chains[1].name = 'Y'

def special_restraints(self, aln):
rsr = self.restraints
at = self.atoms
#       Restrain the specified CB-CB distance to 8 angstroms (st. dev.=0.1)
#       Use a harmonic potential and X-Y distance group.
#       Note that because special_patches is called before special_restraints,
#       we must use the relabeled chain IDs and residue numbers here.
feature=features.distance(at['CB:40:Y'],
at['CB:71:Y']),
mean=8.0, stdev=0.1))

env = environ()
# directories for input atom files
env.io.atom_files_directory = ['.', '../atom_files']

# Be sure to use 'MyModel' rather than 'automodel' here!
a = MyModel(env,
alnfile  = 'twochain.ali' ,     # alignment filename
knowns   = '2abx',              # codes of the templates
sequence = '1hc9')              # code of the target

a.starting_model= 2                # index of the first model
a.ending_model  = 2                # index of the last model
# (determines how many models to calculate)
a.make()                           # do comparative modeling
```