comparison assembly_post_processor.py @ 0:fcc558568020 draft

Uploaded
author greg
date Thu, 08 Jun 2017 12:44:09 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:fcc558568020
1 #!/usr/bin/env python
2 import argparse
3 import os
4 import shutil
5
6 import utils
7
8 OUTPUT_DIR = 'assemblyPostProcessing_dir'
9
10 parser = argparse.ArgumentParser()
11 parser.add_argument('--dereplicate', dest='dereplicate', default=None, help='Remove duplicate sequences')
12 parser.add_argument('--gap_trimming', dest='gap_trimming', type=float, default=0, help='Trim alignments')
13 parser.add_argument('--gene_family_search', dest='gene_family_search', default=None, help='Targeted gene families')
14 parser.add_argument('--method', dest='method', default=None, help='Protein clustering method')
15 parser.add_argument('--min_length', dest='min_length', type=int, default=0, help='Minimum sequence length')
16 parser.add_argument('--num_threads', dest='num_threads', type=int, help='Number of processors')
17 parser.add_argument('--output_pttgf', dest='output_pttgf', default=None, help='Primary targeted gene families dataset')
18 parser.add_argument('--output_cds', dest='output_cds', help='Output transcripts.cds')
19 parser.add_argument('--output_cleaned_cds', dest='output_cleaned_cds', help='Output transcripts.cleaned.cds')
20 parser.add_argument('--output_cleaned_nr_cds', dest='output_cleaned_nr_cds', default=None, help='Output transcripts.cleaned.nr.cds')
21 parser.add_argument('--output_cleaned_nr_pep', dest='output_cleaned_nr_pep', default=None, help='Output transcripts.cleaned.nr.pep')
22 parser.add_argument('--output_cleaned_pep', dest='output_cleaned_pep', help='Output transcripts.cleaned.pep')
23 parser.add_argument('--output_pep', dest='output_pep', help='Output transcripts.pep')
24 parser.add_argument('--output_pttgf_dir', dest='output_pttgf_dir', default=None, help='Directory hierarchy of targeted gene family datasets')
25 parser.add_argument('--prediction_method', dest='prediction_method', help='Coding regions prediction method')
26 parser.add_argument('--scaffold', dest='scaffold', default=None, help='Gene family scaffold')
27 parser.add_argument('--score_matrices', dest='score_matrices', default=None, help='Scores matrices')
28 parser.add_argument('--strand_specific', dest='strand_specific', default=None, help='Strand-specific assembly')
29 parser.add_argument('--transcripts', dest='transcripts', help='Transcriptome assembly fasta file')
30
31 args = parser.parse_args()
32
33 # Build the command line.
34 cmd = 'AssemblyPostProcessor'
35 if args.dereplicate is not None:
36 cmd += ' --dereplicate'
37 if args.gap_trimming > 0:
38 cmd += ' --gap_trimming %4f' % args.gap_trimming
39 if args.gene_family_search is not None:
40 cmd += ' --gene_family_search %s' % args.gene_family_search
41 if args.method is not None:
42 cmd += ' --method %s' % args.method
43 if args.min_length > 0:
44 cmd += ' --min_length %d' % args.min_length
45 cmd += ' --num_threads %d' % args.num_threads
46 cmd += ' --prediction_method %s' % args.prediction_method
47 if args.scaffold is not None:
48 cmd += ' --scaffold %s' % args.scaffold
49 if args.score_matrices is not None:
50 cmd += ' --score_matrices %s' % args.score_matrices
51 if args.strand_specific is not None:
52 cmd += ' --strand_specific'
53 cmd += ' --transcripts %s' % args.transcripts
54 # Run the command.
55 utils.run_command(cmd)
56
57 # Handle outputs.
58 shutil.move(os.path.join(OUTPUT_DIR, 'transcripts.cds'), args.output_cds)
59 shutil.move(os.path.join(OUTPUT_DIR, 'transcripts.cleaned.cds'), args.output_cleaned_cds)
60 if args.output_cleaned_nr_cds is not None:
61 shutil.move(os.path.join(OUTPUT_DIR, 'transcripts.cleaned.nr.cds'), args.output_cleaned_nr_cds)
62 if args.output_cleaned_nr_pep is not None:
63 shutil.move(os.path.join(OUTPUT_DIR, 'transcripts.cleaned.nr.pep'), args.output_cleaned_nr_pep)
64 shutil.move(os.path.join(OUTPUT_DIR, 'transcripts.cleaned.pep'), args.output_cleaned_pep)
65 shutil.move(os.path.join(OUTPUT_DIR, 'transcripts.pep'), args.output_pep)
66 if args.output_pttgf is not None and args.output_pttgf_dir is not None:
67 src_output_dir = os.path.join(OUTPUT_DIR, 'targeted_gene_families')
68 utils.move_directory_files(src_output_dir, args.output_pttgf_dir)
69 utils.write_html_output(args.output_pttgf, 'Targeted gene families', args.output_pttgf_dir)