annotate gene_family_aligner.py @ 0:7ba9469800b9 draft

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