shell.prefix("source config.sh; set -eo pipefail ; ")

configfile: "config.json"

def _get_target_files(wildcards):
    return config["targets"][wildcards.target]

def _get_query_files(wildcards):
        return config["queries"][wildcards.query]

rule dummy:
     input: expand("variants/{target}-{query}.svs.bed", target=config["targets"], query=config["queries"])

rule callSVs:
     message: "Calling SVs"
     input  : SAM="mappings/{target}-{query}-aligned.sam", TARGET=_get_target_files, PG=config["install"] + "/bin/printgaps"
     output : "variants/{target}-{query}.svs.bed"
     shell  : """
            cat {input.SAM} | {input.PG} {input.TARGET} variants/{wildcards.target}-{wildcards.query}
     """

rule runBlasr:
     message: "Aligning query to target"
     input:   BL=config["install"] + "/bin/blasr", TARGET=_get_target_files, QUERY=_get_query_files
     output:  "mappings/{target}-{query}-aligned.sam", "unmappings/{target}-{query}-unaligned.fasta"
     shell:   """
              {input.BL} -clipping hard -alignContigs -sam -minMapQV 30 -nproc 6 -minPctIdentity 50 -unaligned {output[1]} {input.QUERY} {input.TARGET} -out {output[0]}
     """


ecbd769188fbcd19a7c66ff4ea5fd2d492e013b1
shell.prefix("source config.sh; set -eo pipefail ; ")

configfile: "config.json"

def _get_target_files(wildcards):
    return config["targets"][wildcards.target]

def _get_query_files(wildcards):
        return config["queries"][wildcards.query]

rule dummy:
     input: expand("variants/{target}-{query}.svs.bed", target=config["targets"], query=config["queries"])

rule callSVs:
     message: "Calling SVs"
     input  : SAM="mappings/{target}-{query}-aligned.sam", TARGET=_get_target_files, PG=config["install"] + "/bin/printgaps"
     output : "variants/{target}-{query}.svs.bed"
     shell  : """
            cat {input.SAM} | {input.PG} {input.TARGET} variants/{wildcards.target}-{wildcards.query}
     """

rule runBlasr:
     message: "Aligning query to target"
     input:   BL=config["install"] + "/bin/blasr", TARGET=_get_target_files, QUERY=_get_query_files
     output:  "mappings/{target}-{query}-aligned.sam", "unmappings/{target}-{query}-unaligned.fasta"
     shell:   """
              {input.BL} -clipping hard -alignContigs -sam -minMapQV 30 -nproc 6 -minPctIdentity 50 -unaligned {output[1]} {input.QUERY} {input.TARGET} -out {output[0]}
     """

