## model.generate_topology() — generate MODEL topology

`generate_topology(alnseq, patch_default=None, io=None)`

> This command calculates the model's covalent topology (i.e., atomic connectivity) and internal coordinates, and assigns CHARMM atom types, MODELLER atom types for non-bonded spline restraints, atomic charges, and atomic radii.

> The residue sequence to generate is taken from the alignment sequence given by alnseq.

> The sequence is added to the model as a new chain; if you want to first remove any existing chains, call model.clear_topology() prior to this command.

> A sequence in the alignment can use any residue listed in the single-character code column of the `$RESTYP_LIB` library (`'modlib/restyp.lib'`). Examples of non-standard residue types include water (`'w'`), zinc (`'z'`), calcium (`'3'`), heme (`'h'`), and many others. If you wish to use patch residues, use model.patch() subsequently. You can generate multiple chains by including chain break characters ‘/’ in the alignment. A chain break prevents MODELLER from connecting two otherwise adjacent residues.

> If only one chain is generated, it is given a blank chain ID. Otherwise, the chains are labeled `'A'`, `'B'`, `'C'` and so on. Residues in each chain are numbered sequentially, starting at 1. If you want to use the chain IDs and residue numbers from an existing PDB file, use model.res_num_from().

> IF patch_default is `True`, each chain in the sequence is patched with the `'NTER'` and `'CTER'` patches (see model.patch()). These patches are applied to the first and last residue respectively in a connected chain of residues (generally this excludes residues that are not in the amino acid chain, such as HETATM residues).

> The model.generate_topology() command generates only the topology of the model, not its Cartesian coordinates; the Cartesian coordinates are assigned by the model.build(), model.transfer_xyz(), or model.read() commands.

> In general, the model.generate_topology() command has to be executed before any energy commands (selection.energy(), selection.hot_atoms()) or optimizations (Section 6.11).

> The variables Sequence.atom_file, io and Topology.submodel are necessary only when residues lacking topology information (e.g., `'BLK'` residues) are present in the sequence. In that case, the template PDB files are read in.

Example: See model.patch() command.