def add_metadata(infile, outfile, sample_metadata):
    """Add sample-level metadata to a biom file. Sample-level metadata
    should be in a format akin to
    http://qiime.org/tutorials/tutorial.html#mapping-file-tab-delimited-txt

    :param infile: String; name of the biom file to which metadata 
                   shall be added
    :param outfile: String; name of the resulting metadata-enriched biom file
    :param sample_metadata: String; name of the sample-level metadata 
                            tab-delimited text file. Sample attributes are
                            taken from this file. Note: the sample names in
                            the `sample_metadata` file must match the sample
                            names in the biom file.

    External dependencies
      - biom-format: http://biom-format.org/
    """

    return {
        "name": "biom_add_metadata: " + infile,
        "actions": [("biom add-metadata"
                     " -i "+infile+
                     " -o "+outfile+
                     " -m "+sample_metadata)],
        "file_dep": [infile],
        "targets": [outfile]
    }