def sortmerna_map(seq_path,
                  output_dir,
                  refseqs_fp,
                  sortmerna_db,
                  e_value=1,
                  threads=1,
                  best=None,
                  num_alignments=None,
                  HALT_EXEC=False,
                  output_sam=False,
                  sam_SQ_tags=False,
                  blast_format=3,
                  print_all_reads=True,
                  ):
    if not (blast_format or output_sam):
        raise ValueError("Either Blast or SAM output alignment "
                         "format must be chosen.")
    if (best and num_alignments):
        raise ValueError("Only one of --best or --num_alignments "
                         "options must be chosen.")
    smr = Sortmerna(HALT_EXEC=HALT_EXEC)
    smr.Parameters['--ref'].on("%s,%s" % (refseqs_fp, sortmerna_db))
    smr.Parameters['--reads'].on(seq_path)
    if blast_format:
        smr.Parameters['--blast'].on(blast_format)
    if output_sam:
        smr.Parameters['--sam'].on()
        if sam_SQ_tags:
            smr.Parameters['--SQ'].on()
    if print_all_reads:
        smr.Parameters['--print_all_reads'].on()
    output_file = join(output_dir, "sortmerna_map")
    smr.Parameters['--aligned'].on(output_file)
    if e_value is not None:
        smr.Parameters['-e'].on(e_value)
    if best is not None:
        smr.Parameters['--best'].on(best)
    if num_alignments is not None:
        smr.Parameters['--num_alignments'].on(num_alignments)
    if threads is not None:
        smr.Parameters['-a'].on(threads)
    smr.Parameters['--fastx'].off()
    smr.Parameters['--otu_map'].off()
    smr.Parameters['--de_novo_otu'].off()
    smr.Parameters['--id'].off()
    smr.Parameters['--coverage'].off()
    app_result = smr()
    return app_result