When I ran MethylCoder with gsnap by passing arguments like:
--extra-args "--mode=cmet-stranded -Q -n 1 -t 4"
KeyError: 'cmet' was raised.
I think cmet variable in gsnap.py should be declared beforehand so that we can avoid the error when the --mode argument is specified in the --extra-args.
def run_gsnap(gsnap_dir, gsnap_args, out_dir, ref_fasta, reads_paths, cpu_count):
ref_base = op.splitext(ref_fasta)[0]
ref_name = op.basename(ref_base)
ref_dir = op.dirname(ref_fasta)
reads_paths = [op.abspath(r) for r in reads_paths]
log = op.join(out_dir, "gsnap_run.log")
# cmet = " " <--- declare beforehand
if not "--mode" in gsnap_args:
cmet = "--mode=cmet-nonstranded"
print >>sys.stderr, "using non-stranded mode, specify " \
+ " --mode=cmet-stranded in --extra-args for stranded mode"
if any(r.endswith(".gz") for r in reads_paths):
gsnap_args += " --gunzip "
reads_paths_str = " ".join(reads_paths)
out_sam = op.abspath(op.join(out_dir, "methylcoded.gsnap.sam"))
cmd = "gsnap --quiet-if-excessive -A sam -k 15 "
cmd += " --nofails --nthreads %(cpu_count)i -D %(ref_dir)s %(gsnap_args)s"
# KeyError: 'cmet' occurs because cmet cannot be generated when the "--mode" string is in gsnap_args
cmd += " -d %(ref_name)s %(cmet)s %(reads_paths_str)s > %(out_sam)s 2> %(log)s"
cmd %= locals()
When I ran MethylCoder with gsnap by passing arguments like:
--extra-args "--mode=cmet-stranded -Q -n 1 -t 4"
KeyError: 'cmet'
was raised.I think
cmet
variable ingsnap.py
should be declared beforehand so that we can avoid the error when the--mode
argument is specified in the--extra-args
.