Creates the dataset header for NEXUS files from ``#NEXUS`` to ``MATRIX``.

    Parameters:
        data (namedtuple):    with necessary info for dataset creation.
        file_format (str):    TNT, PHYLIP, NEXUS, FASTA
        aminoacids (boolean): If ``aminoacids is True`` the header will show
                              ``DATATYPE=PROTEIN`` otherwise it will be ``DNA``.

def make_dataset_header(data, file_format, aminoacids):
    """Creates the dataset header for NEXUS files from ``#NEXUS`` to ``MATRIX``.

    Parameters:
        data (namedtuple):    with necessary info for dataset creation.
        file_format (str):    TNT, PHYLIP, NEXUS, FASTA
        aminoacids (boolean): If ``aminoacids is True`` the header will show
                              ``DATATYPE=PROTEIN`` otherwise it will be ``DNA``.
    """
    if aminoacids:
        datatype = 'PROTEIN'
    else:
        datatype = 'DNA'

    if file_format in ['NEXUS', 'PHYLIP', 'FASTA']:
        header = """
#NEXUS

BEGIN DATA;
DIMENSIONS NTAX={0} NCHAR={1};
FORMAT INTERLEAVE DATATYPE={2} MISSING=? GAP=-;
MATRIX
""".format(data.number_taxa, data.number_chars, datatype)

    elif file_format == 'MEGA':
        return "#MEGA\n!TITLE title;"

    else:  # file_format: TNT
        if aminoacids:
            molecule_type = "prot"
        else:
            molecule_type = "dna"
        header = """
nstates {0};
xread
{1} {2}""".format(molecule_type, data.number_chars, data.number_taxa)

    return header.strip()