last last lastal

last lastal

Version:
874
Identifier: TL_98bd1c_c9.51
Tool
1""" Snakemake wrapper for lastal """
2
3__author__ = "N. Tessa Pierce"
4__copyright__ = "Copyright 2019, N. Tessa Pierce"
5__email__ = "ntpierce@gmail.com"
6__license__ = "MIT"
7
8from snakemake.shell import shell
9
10extra = snakemake.params.get("extra", "")
11log = snakemake.log_fmt_shell(stdout=False, stderr=True)
12
13# http://last.cbrc.jp/doc/last-evalues.html
14d_len = float(snakemake.params.get("D_length", 1000000))  # last default
15
16# set output file formats
17maf_out = snakemake.output.get("maf", "")
18tab_out = snakemake.output.get("tab", "")
19btab_out = snakemake.output.get("blasttab", "")
20btabplus_out = snakemake.output.get("blasttabplus", "")
21outfiles = [maf_out, tab_out, btab_out, btabplus_out]
22# TAB, MAF, BlastTab, BlastTab+ (default=MAF)
23assert (
24    list(map(bool, outfiles)).count(True) == 1
25), "please specify ONE output file using one of: 'maf', 'tab', 'blasttab', or 'blasttabplus' keywords in the output field)"
26
27out_cmd = ""
28
29if maf_out:
30    out_cmd = "-f {}".format("MAF")
31    outF = maf_out
32elif tab_out:
33    out_cmd = "-f {}".format("TAB")
34    outF = tab_out
35if btab_out:
36    out_cmd = "-f {}".format("BlastTab")
37    outF = btab_out
38if btabplus_out:
39    out_cmd = "-f {}".format("BlastTab+")
40    outF = btabplus_out
41
42frameshift_cost = snakemake.params.get("frameshift_cost", "")
43if frameshift_cost:
44    f_cmd = f"-F {frameshift_cost}"
45
46
47lastdb_name = str(snakemake.input["lastdb"]).rsplit(".", 1)[0]
48
49shell(
50    "lastal -D {d_len} -P {snakemake.threads} {extra} {lastdb_name} {snakemake.input.data} > {outF} {log}"
51)
52