comparison gene_family_aligner.py @ 0:7ba9469800b9 draft

Uploaded
author greg
date Thu, 08 Jun 2017 12:46:20 -0400
parents
children ab1f0bab96f3
comparison
equal deleted inserted replaced
-1:000000000000 0:7ba9469800b9
1 #!/usr/bin/env python
2 import argparse
3 import os
4
5 import utils
6
7 OUTPUT_DIR = 'geneFamilyAlignments_dir'
8
9 parser = argparse.ArgumentParser()
10 parser.add_argument('--alignment_method', dest='alignment_method', help='Multiple sequence alignments method')
11 parser.add_argument('--automated_trimming', dest='automated_trimming', default=None, help='Trims alignments using trimAls ML heuristic trimming approach')
12 parser.add_argument('--codon_alignments', dest='codon_alignments', default=None, help='Flag for constructing orthogroup multiple codon alignments')
13 parser.add_argument('--gap_trimming', dest='gap_trimming', default=0, type=float, help='Remove sites in alignments with gaps of')
14 parser.add_argument('--iterative_realignment', dest='iterative_realignment', type=int, default=0, help='Maximum number of iterations')
15 parser.add_argument('--num_threads', dest='num_threads', type=int, help='Number of threads to use for execution')
16 parser.add_argument('--orthogroup_faa', dest='orthogroup_faa', help='Directory of input fasta datasets')
17 parser.add_argument('--output', dest='output', help='Output dataset')
18 parser.add_argument('--output_dir', dest='output_dir', help='Output dataset files_path directory')
19 parser.add_argument('--pasta_iter_limit', dest='pasta_iter_limit', type=int, default=None, help='Maximum number of iteration that the PASTA algorithm will execute')
20 parser.add_argument('--pasta_script_path', dest='pasta_script_path', default=None, help='Path to script for executing pasta')
21 parser.add_argument('--remove_sequences', dest='remove_sequences', default=0, type=float, help='Remove sequences with gaps of')
22
23 args = parser.parse_args()
24
25 # Build the command line.
26 cmd = 'GeneFamilyAligner'
27 cmd += ' --orthogroup_faa %s' % args.orthogroup_faa
28 cmd += ' --alignment_method %s' % args.alignment_method
29 if args.alignment_method == 'pasta':
30 if args.pasta_script_path is not None:
31 cmd += ' --pasta_script_path %s' % args.pasta_script_path
32 if args.pasta_iter_limit is not None:
33 cmd += ' --pasta_iter_limit %d' % args.pasta_iter_limit
34 cmd += ' --num_threads %d' % args.num_threads
35 if args.codon_alignments is not None:
36 cmd += ' --codon_alignments'
37 if args.automated_trimming is not None:
38 cmd += ' --automated_trimming'
39 if args.gap_trimming > 0:
40 cmd += ' --gap_trimming %4f' % args.gap_trimming
41 if args.remove_sequences > 0:
42 cmd += ' --remove_sequences %4f' % args.remove_sequences
43 if args.iterative_realignment > 0:
44 cmd += ' --iterative_realignment %d' % args.iterative_realignment
45
46 # Run the command.
47 utils.run_command(cmd)
48
49 # Handle outputs.
50 if args.codon_alignments is None:
51 src_output_dir = OUTPUT_DIR
52 else:
53 src_output_dir = os.path.join(OUTPUT_DIR, 'orthogroups_aln')
54 utils.move_directory_files(src_output_dir, args.output_dir)
55 utils.write_html_output(args.output, 'Aligned gene family sequences', args.output_dir)