Skip to content
Snippets Groups Projects
Commit 6eb19d18 authored by Jasper Koehorst's avatar Jasper Koehorst
Browse files

sync

parent 5617ab74
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ def main():
args = parse_arguments()
mini_align(args)
medaka_consensus(args)
medaka_stich(args)
def parse_arguments():
# Initialize parser
......@@ -23,7 +23,7 @@ def parse_arguments():
parser.add_argument("-m", help = "fill MD tag")
parser.add_argument("-p", help = "output file prefix (default: reads)",nargs='?', default="reads", type=str)
parser.add_argument("-c", "--contig-chunks", help = "Number of contigs per medaka_consensus step", nargs='?',default=100, type=int)
parser.add_argument("--model", help = "Model definition, default is equivalent to r94.", default="r94")
parser.add_argument("--model", help = "Model definition, default is equivalent to r941_min_fast_g303.", default="r941_min_fast_g303")
# Adding optional argument for ....
# ...
......@@ -42,9 +42,10 @@ def parse_arguments():
# -p calls_to_draft.bam -t <threads>
def mini_align(args):
if os.path.exists(args.reference + ".mmi"):
print("Index file is already present")
# Checks for mmi and bam file?
if os.path.exists(args.reference + ".mmi") and os.path.exists(args.p + ".bam"):
print("Index and bam file are already present")
return
print(args)
arguments = ["mini_align", "-i", args.input, "-r", args.reference, "-m", "-p", args.p, "-t", args.threads]
command = ' '.join(map(str,arguments))
......@@ -94,12 +95,12 @@ def medaka_consensus(args):
reader.close()
# Run this in parallel for each chunk by number of threads / 2
commands = set()
commands = []
for chunk in chunks:
arguments = ["medaka", "consensus", args.p + ".bam", "results/chunk_" + str(chunk), "--model", args.model, "--threads", "2", "--region", ' '.join(chunks[chunk])]
arguments = ' '.join(map(str,arguments))
commands.add(arguments)
commands.append(arguments)
# Multi thread section
from functools import partial
from multiprocessing.dummy import Pool
......@@ -110,9 +111,9 @@ def medaka_consensus(args):
pool = Pool(jobs) # two concurrent commands at a time
for i, returncode in enumerate(pool.imap(partial(call, shell=True), commands)):
if returncode != 0:
print("%d command failed: %d" % (i, returncode))
print("%d command failed with exit code %d and command %s" % (i, returncode, commands[i]))
else:
print("%d command finished: %d" % (i, returncode))
print("%d command finished: %d %s" % (i, returncode, commands[i]))
## SINGLE RUN
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment