comparison gene_family_aligner.py @ 0:6accbd3a1449 draft

Uploaded
author greg
date Fri, 07 Apr 2017 13:00:29 -0400
parents
children 01c08c35d051
comparison
equal deleted inserted replaced
-1:000000000000 0:6accbd3a1449
1 #!/usr/bin/env python
2 import argparse
3 import subprocess
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 trimAl's 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=None, type=float, help='Remove sites in alignments with gaps of')
14 parser.add_argument('--iterative_realignment', dest='iterative_realignment', type=int, default=None, help='"Maximum number of iterations')
15 parser.add_argument('--method', dest='method', help='Protein clustering method')
16 parser.add_argument('--num_threads', dest='num_threads', type=int, help='Number of threads to use for execution')
17 parser.add_argument('--orthogroup_faa', dest='orthogroup_faa', help="Directory of input fasta datasets")
18 parser.add_argument('--output', dest='output', help="Output dataset")
19 parser.add_argument('--output_dir', dest='output_dir', help="Output dataset file_path directory")
20 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')
21 parser.add_argument('--pasta_script_path', dest='pasta_script_path', default=None, help='Path to script for executing pasta')
22 parser.add_argument('--remove_sequences', dest='remove_sequences', default=None, type=float, help='Remove sequences with gaps of')
23 parser.add_argument('--scaffold', dest='scaffold', help='Orthogroups or gene families proteins scaffold')
24
25 args = parser.parse_args()
26
27 # Build the command line.
28 cmd = 'GeneFamilyAligner'
29 cmd += ' --orthogroup_faa %s' % args.orthogroup_faa
30 cmd += ' --scaffold %s' % args.scaffold
31 cmd += ' --method %s' % args.method
32 cmd += ' --alignment_method %s' % args.alignment_method
33 if args.alignment_method == 'pasta':
34 if args.pasta_script_path is not None:
35 cmd += ' --pasta_script_path %s' % args.pasta_script_path
36 if args.pasta_iter_limit is not None:
37 cmd += ' --pasta_iter_limit %d' % args.pasta_iter_limit
38 cmd += ' --num_threads %d' % args.num_threads
39 if args.orthogroup_fna is not None:
40 cmd += ' --orthogroup_fna'
41 if args.automated_trimming is not None:
42 cmd += ' --automated_trimming'
43 if args.gap_trimming is not None:
44 cmd += ' --gap_trimming %4f' % args.gap_trimming
45 if args.remove_sequences is not None:
46 cmd += ' --remove_sequences %4f' % args.remove_sequences
47 if args.iterative_realignment is not None:
48 cmd += ' --iterative_realignment %d' % args.iterative_realignment
49 # Run the command.
50 proc = subprocess.Popen(args=cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
51 rc = proc.wait()
52 utils.check_execution_errors(rc, proc.stderr)
53 utils.move_directory_files(OUTPUT_DIR, args.output_dir)
54 utils.write_html_output(args.output, 'Aligned gene family sequences', args.output_dir)