## alignment.write() — write sequences and/or their alignment

`write(file, alignment_format='PIR', alignment_features='INDICES CONSERVATION', align_block=0, align_alignment=False)`

> This command writes the whole alignment to a text file.

> file can be either a file name or a writeable file handle (see modfile.File()).

> alignment_format selects the format to write the alignment in; see alignment.append().

> The `'PAP'` format, which corresponds to a relatively nice looking alignment, has several additional formatting options that can be selected by the alignment_features variable. This scalar variable can contain any combination of the following keywords:

- `'INDICES'`, the alignment position indices;

- `'CONSERVATION'`, a star for each absolutely conserved position;

- `'ACCURACY'`, the alignment accuracy indices, scaled between 0-9, as calculated by alignment.consensus();

- `'HELIX'`, average content of helical residues for structures 1 - align_block at each position, 0 for 0% and 9 for 100%, as calculated by alignment.align2d().

- `'BETA'`, average content of β-strand residues for structures 1 - align_block at each position, 0 for 0% and 9 for 100%, as calculated `by alignment.align2d().

- `'ACCESSIBILITY'`, average relative sidechain buriedness for structures 1 - align_block, 0 for 0% (100% accessibility) and 9 for 100% (0% accessibility), as calculated by alignment.align2d();

- `'STRAIGHTNESS'`, average mainchain straightness structures 1 - align_block at each position 0 for 0% and 9 for 100%, as calculated by alignment.align2d().

- `'PRED_SS'`, predicted secondary structure (H,E,C)
- `'CONF_SS'`, confidence of predicted secondary structure (0(low) - 9(high))

> Options `'HELIX'`, `'BETA'`, `'ACCESSIBILITY'`, and `'STRAIGHTNESS'` are valid only after executing command alignment.align2d(), where the corresponding quantities are defined. They refer to the 3D profile defined for the first align_block structures (run alignment.align2d() with fit = `False` to prepare these structural data without changing the input alignment). Similarly, the `'ACCURACY'` option is valid only after the alignment.consensus() command. Options `'PRED_SS'` and `'CONF_SS'` are best exercised after reading in a ".PSS" file of secondary structure predictions. In the case of multiple sequences, it may be necessary to use the command Sequence.transfer_res_prop() first.

> align_alignment and align_block are used to ensure correct indication of identical alignment positions, depending on whether sequences or two blocks of sequences were aligned: For sequences (align_alignment = `False` and align_block is ignored), a `'*'` indicating a conserved position is printed where all sequences have the same residue type. For blocks (align_alignment = `True` and align_block indicates the last sequence of the first block), a `'*'` is printed only where the two blocks have the same order of residue types (there has to be the same number of sequences in both blocks). The blocks option is useful when comparing two alignments, possibly aligned by the alignment.align() command.

Example: See alignment.append() command.