annotate gene_family_aligner.py @ 5:a73c2e65098e draft

Uploaded
author greg
date Fri, 25 Aug 2017 13:01:25 -0400
parents ab1f0bab96f3
children
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')
1
ab1f0bab96f3 Uploaded
greg
parents: 0
diff changeset
19 parser.add_argument('--output_dataset_collection', dest='output_dataset_collection', default=None, help='Output additional dataset collection of files.')
0
7ba9469800b9 Uploaded
greg
parents:
diff changeset
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')
7ba9469800b9 Uploaded
greg
parents:
diff changeset
21 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
22 parser.add_argument('--remove_sequences', dest='remove_sequences', default=0, type=float, help='Remove sequences with gaps of')
7ba9469800b9 Uploaded
greg
parents:
diff changeset
23
7ba9469800b9 Uploaded
greg
parents:
diff changeset
24 args = parser.parse_args()
7ba9469800b9 Uploaded
greg
parents:
diff changeset
25
7ba9469800b9 Uploaded
greg
parents:
diff changeset
26 # Build the command line.
7ba9469800b9 Uploaded
greg
parents:
diff changeset
27 cmd = 'GeneFamilyAligner'
7ba9469800b9 Uploaded
greg
parents:
diff changeset
28 cmd += ' --orthogroup_faa %s' % args.orthogroup_faa
7ba9469800b9 Uploaded
greg
parents:
diff changeset
29 cmd += ' --alignment_method %s' % args.alignment_method
7ba9469800b9 Uploaded
greg
parents:
diff changeset
30 if args.alignment_method == 'pasta':
7ba9469800b9 Uploaded
greg
parents:
diff changeset
31 if args.pasta_script_path is not None:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
32 cmd += ' --pasta_script_path %s' % args.pasta_script_path
7ba9469800b9 Uploaded
greg
parents:
diff changeset
33 if args.pasta_iter_limit is not None:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
34 cmd += ' --pasta_iter_limit %d' % args.pasta_iter_limit
7ba9469800b9 Uploaded
greg
parents:
diff changeset
35 cmd += ' --num_threads %d' % args.num_threads
7ba9469800b9 Uploaded
greg
parents:
diff changeset
36 if args.codon_alignments is not None:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
37 cmd += ' --codon_alignments'
7ba9469800b9 Uploaded
greg
parents:
diff changeset
38 if args.automated_trimming is not None:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
39 cmd += ' --automated_trimming'
7ba9469800b9 Uploaded
greg
parents:
diff changeset
40 if args.gap_trimming > 0:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
41 cmd += ' --gap_trimming %4f' % args.gap_trimming
7ba9469800b9 Uploaded
greg
parents:
diff changeset
42 if args.remove_sequences > 0:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
43 cmd += ' --remove_sequences %4f' % args.remove_sequences
7ba9469800b9 Uploaded
greg
parents:
diff changeset
44 if args.iterative_realignment > 0:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
45 cmd += ' --iterative_realignment %d' % args.iterative_realignment
7ba9469800b9 Uploaded
greg
parents:
diff changeset
46
7ba9469800b9 Uploaded
greg
parents:
diff changeset
47 # Run the command.
7ba9469800b9 Uploaded
greg
parents:
diff changeset
48 utils.run_command(cmd)
7ba9469800b9 Uploaded
greg
parents:
diff changeset
49
7ba9469800b9 Uploaded
greg
parents:
diff changeset
50 # Handle outputs.
7ba9469800b9 Uploaded
greg
parents:
diff changeset
51 if args.codon_alignments is None:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
52 src_output_dir = OUTPUT_DIR
7ba9469800b9 Uploaded
greg
parents:
diff changeset
53 else:
7ba9469800b9 Uploaded
greg
parents:
diff changeset
54 src_output_dir = os.path.join(OUTPUT_DIR, 'orthogroups_aln')
1
ab1f0bab96f3 Uploaded
greg
parents: 0
diff changeset
55 if args.output_dataset_collection is not None:
ab1f0bab96f3 Uploaded
greg
parents: 0
diff changeset
56 utils.move_directory_files(src_output_dir, args.output_dataset_collection, copy=True)
0
7ba9469800b9 Uploaded
greg
parents:
diff changeset
57 utils.move_directory_files(src_output_dir, args.output_dir)
7ba9469800b9 Uploaded
greg
parents:
diff changeset
58 utils.write_html_output(args.output, 'Aligned gene family sequences', args.output_dir)