annotate assembly_stats_txt.py @ 1:7556309ffbaf draft default tip

"planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
author nml
date Fri, 29 May 2020 13:51:50 -0400
parents ad2b274663f8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
1 #!/usr/bin/env python
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
2 # -*- coding: utf-8 -*-
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
3
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
4 # Version 1.01 - bugs kindly corrected by Jan van Haarst
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
5 # Modified by Matthew Gopez October 13th, 2017
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
6 # Rewritten by Matthew Gopez May 25th, 2020
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
7
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
8 import argparse
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
9 import os
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
10 import shutil
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
11 import subprocess
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
12 from pathlib import Path
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
13
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
14
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
15 PERL_OUT_FILES = ['stats.txt', 'sorted_contigs.fa', 'histogram_bins.dat.png',
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
16 'summed_contig_lengths.dat.png', 'histogram_bins.dat',
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
17 'summed_contig_lengths.dat']
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
18
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
19
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
20 def init_parser():
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
21 """Create argument parser and return parser obj."""
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
22 parser = argparse.ArgumentParser(description="usage: %prog [options]")
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
23
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
24 parser.add_argument(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
25 "-d",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
26 "--working-dir",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
27 dest="working_dir",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
28 required=True)
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
29
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
30 parser.add_argument(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
31 "-t",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
32 "--type",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
33 dest="file_type",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
34 required=True)
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
35
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
36 parser.add_argument(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
37 "-b",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
38 "--bucket",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
39 dest="bucket",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
40 action='store_true')
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
41
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
42 parser.add_argument(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
43 "-i",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
44 "--input",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
45 dest="input",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
46 required=True)
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
47
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
48 parser.add_argument(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
49 "-s",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
50 "--stats",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
51 dest="stats",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
52 required=True)
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
53
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
54 parser.add_argument(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
55 "-sc",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
56 "--sorted-contigs",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
57 dest="sorted_contigs",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
58 required=True)
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
59
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
60 parser.add_argument(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
61 "-hpng",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
62 "--histogram-png",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
63 dest="histogram_png",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
64 required=True)
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
65
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
66 parser.add_argument(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
67 "-spng",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
68 "--summed-contigs-png",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
69 dest="summed_contigs_png",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
70 required=True)
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
71
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
72 parser.add_argument(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
73 "-hd",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
74 "--histogram-data",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
75 dest="histogram_data",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
76 required=True)
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
77
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
78 parser.add_argument(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
79 "-scd",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
80 "--summed-config-data",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
81 dest="summed_contig_data",
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
82 required=True)
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
83
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
84 return parser
0
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
85
ad2b274663f8 planemo upload for repository https://github.com/phac-nml/galaxy_tools commit 3f9ae719338c7c8db81d645b8ee09727e2d9ce23
nml
parents:
diff changeset
86
1
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
87 def exec_fasta_summary(input_data, file_type, bucket, working_dir):
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
88 """Execute fasta_summary.pl script with user arguments."""
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
89 script_dir = Path(__file__).parent.absolute()
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
90
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
91 if bucket:
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
92 bucket_arg = '-b'
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
93 else:
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
94 bucket_arg = ''
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
95
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
96 cli_command = \
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
97 '{}/fasta_summary.pl -i {} -t {} {} -o {} > /dev/null'.format(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
98 script_dir, input_data, file_type, bucket_arg, working_dir)
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
99
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
100 try:
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
101 subprocess.check_output(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
102 cli_command,
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
103 stderr=subprocess.STDOUT,
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
104 shell=True,
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
105 universal_newlines=True)
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
106 except subprocess.CalledProcessError as exc:
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
107 raise RuntimeError('Error running assembly_stats.py!\n'
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
108 'Return Code: {}\nOutput: {}'.format(
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
109 exc.returncode, exc.output))
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
110
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
111
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
112 def main():
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
113 """This is where the magic happens. (not really)
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
114
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
115 1. Gets command line arguments.
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
116 2. Grabs the user's desired parameters for running the perl script.
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
117 3. Ensures the directories are in place.
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
118 4. Executes fasta_summary.pl
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
119 5. Move the out files from the perl script to the desired
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
120 location the user specified.
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
121
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
122 """
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
123 parser = init_parser()
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
124 args = parser.parse_args()
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
125
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
126 working_dir = args.working_dir
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
127
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
128 out_file_names = [args.stats, args.sorted_contigs, args.histogram_png,
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
129 args.summed_contigs_png, args.histogram_data,
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
130 args.summed_contig_data]
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
131
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
132 # Ensure working directory is created.
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
133 Path(working_dir).mkdir(parents=True, exist_ok=True)
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
134
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
135 # Execute Perl Script
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
136 exec_fasta_summary(args.input, args.file_type, args.bucket, working_dir)
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
137
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
138 # Rename out files to desired file names
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
139 for perl_out_file, dest_file in zip(PERL_OUT_FILES, out_file_names):
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
140 shutil.move(os.path.join(working_dir, perl_out_file),
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
141 dest_file)
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
142
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
143
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
144 if __name__ == "__main__":
7556309ffbaf "planemo upload for repository https://github.com/phac-nml/galaxy_tools commit fb4c29f720748f46ff501140f2cd306bab6614f9"
nml
parents: 0
diff changeset
145 main()