def write_mapping_file(mapF, sampleIDs, barcodes, treatment=None):
header = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT:\n>']<EOL>if treatment is not None:<EOL><INDENT>header.insert(-<NUM_LIT:2>, treatment.name)<EOL><DEDENT>primer = '<STR_LIT>'<EOL>sampleMap = {}<EOL>with mapF:<EOL><INDENT>mapF.write('<STR_LIT:\t>'.join(header))<EOL>for sid, bc in zip(sampleIDs, barcodes):<EOL><INDENT>sampleMap[sid] = MapRecord(bc, primer, treatment.value, sid)<EOL>line = [sid, bc, primer, sid]<EOL>if treatment is not None:<EOL><INDENT>line.insert(-<NUM_LIT:1>, treatment.value)<EOL><DEDENT>mapF.write('<STR_LIT:\t>'.join(line) + '<STR_LIT:\n>')<EOL><DEDENT><DEDENT>return sampleMap<EOL>
Given a mapping from sample IDs to barcodes/primers/other info,
write out a QIIME-compatible mapping file.

File format described at: http://qiime.org/documentation/file_formats.html
Note that primer column can be left blank.