Skip to content

Commit 4dc499e

Browse files
committed
added option specify 'none' as the aligner. This allows for alignment to be run separately as requested in #306
1 parent f3d664a commit 4dc499e

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

panaroo/__main__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def get_options(args):
243243
help=
244244
"Specify an aligner. Options:'prank', 'clustal', and default: 'mafft'",
245245
type=str,
246-
choices=['prank', 'clustal', 'mafft'],
246+
choices=['prank', 'clustal', 'mafft', 'none'],
247247
default="mafft")
248248
core.add_argument(
249249
"--codons",
@@ -550,9 +550,10 @@ def main():
550550
if args.verbose: print("generating pan genome MSAs...")
551551
generate_pan_genome_alignment(G, temp_dir, args.output_dir, args.n_cpu,
552552
args.alr, args.codons, isolate_names)
553-
core_nodes = get_core_gene_nodes(G, args.core, len(args.input_files))
554-
core_names = [G.nodes[x]["name"] for x in core_nodes]
555-
concatenate_core_genome_alignments(core_names, args.output_dir, args.hc_threshold)
553+
if args.alr!='none':
554+
core_nodes = get_core_gene_nodes(G, args.core, len(args.input_files))
555+
core_names = [G.nodes[x]["name"] for x in core_nodes]
556+
concatenate_core_genome_alignments(core_names, args.output_dir, args.hc_threshold)
556557
elif args.aln == "core":
557558
if args.verbose: print("generating core genome MSAs...")
558559
generate_core_genome_alignment(G, temp_dir, args.output_dir,

panaroo/generate_alignments.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def check_aligner_install(aligner):
4040
command = "prank -help"
4141
elif aligner == "mafft":
4242
command = "mafft --help"
43+
elif aligner == "none":
44+
return True
4345
else:
4446
sys.stderr.write("Incorrect aligner specification\n")
4547
sys.exit()

panaroo/generate_output.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ def generate_pan_genome_alignment(G, temp_dir, output_dir, threads, aligner,
315315
aligner,
316316
threads)
317317
else:
318+
if aligner=='none':
319+
temp_dir = output_dir + "unaligned_gene_sequences/"
320+
if not os.path.exists(temp_dir):
321+
os.mkdir(temp_dir)
322+
318323
#Multithread writing gene sequences to disk (temp directory) so aligners can find them
319324
unaligned_sequence_files = Parallel(n_jobs=threads)(
320325
delayed(output_sequence)(G.nodes[x], isolates, temp_dir, output_dir)
@@ -323,6 +328,10 @@ def generate_pan_genome_alignment(G, temp_dir, output_dir, threads, aligner,
323328
#remove single sequence files
324329
unaligned_sequence_files = filter(None, unaligned_sequence_files)
325330

331+
if aligner=='none':
332+
print("No aligner specified. Returning unaligned gene fasta files.")
333+
return
334+
326335
#Get Biopython command calls for each output gene sequences
327336
commands = [
328337
get_alignment_commands(fastafile, output_dir, aligner, threads)
@@ -531,10 +540,20 @@ def generate_core_genome_alignment(
531540
output_dir, temp_dir,
532541
aligner, threads)
533542
else:
543+
if aligner=='none':
544+
temp_dir = output_dir + "unaligned_gene_sequences/"
545+
if not os.path.exists(temp_dir):
546+
os.mkdir(temp_dir)
547+
534548
#Output core node sequences
535549
unaligned_sequence_files = Parallel(n_jobs=threads)(
536550
delayed(output_sequence)(G.nodes[x], isolates, temp_dir, output_dir)
537551
for x in tqdm(core_genes))
552+
553+
if aligner=='none':
554+
print("No aligner specified. Returning unaligned gene fasta files.")
555+
return
556+
538557
#remove single sequence files
539558
unaligned_sequence_files = filter(None, unaligned_sequence_files)
540559

panaroo/post_run_alignment_gen.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_options():
4141
help=
4242
"Specify an aligner. Options:'prank', 'clustal', and default: 'mafft'",
4343
type=str,
44-
choices={'prank', 'clustal', 'mafft'},
44+
choices={'prank', 'clustal', 'mafft', 'none'},
4545
default="mafft")
4646
core.add_argument(
4747
"--codons",
@@ -109,11 +109,12 @@ def main():
109109
if args.verbose: print("generating pan genome MSAs...")
110110
generate_pan_genome_alignment(G, temp_dir, args.output_dir, args.n_cpu,
111111
args.alr, args.codons, isolate_names)
112-
113-
core_nodes = get_core_gene_nodes(G, args.core, len(isolate_names))
114-
core_names = [G.nodes[x]["name"] for x in core_nodes]
115-
concatenate_core_genome_alignments(core_names, args.output_dir,
116-
args.hc_threshold)
112+
113+
if args.alr!='none':
114+
core_nodes = get_core_gene_nodes(G, args.core, len(isolate_names))
115+
core_names = [G.nodes[x]["name"] for x in core_nodes]
116+
concatenate_core_genome_alignments(core_names, args.output_dir,
117+
args.hc_threshold)
117118
elif args.aln == "core":
118119
if args.verbose: print("generating core genome MSAs...")
119120
generate_core_genome_alignment(G, temp_dir, args.output_dir,

0 commit comments

Comments
 (0)