annotate amplicon_analysis_pipeline.py @ 22:eb7d118dd322 draft

planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit bae32168fbfd40305a4768b889a8e7689e5987e3-dirty
author pjbriggs
date Wed, 04 Jul 2018 06:56:48 -0400
parents 092e39db5f59
children fe354f5dd0ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
1 #!/usr/bin/env python
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
2 #
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
3 # Wrapper script to run Amplicon_analysis_pipeline.sh
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
4 # from Galaxy tool
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
5
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
6 import sys
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
7 import os
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
8 import argparse
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
9 import subprocess
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
10 import glob
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
11
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
12 class PipelineCmd(object):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
13 def __init__(self,cmd):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
14 self.cmd = [str(cmd)]
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
15 def add_args(self,*args):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
16 for arg in args:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
17 self.cmd.append(str(arg))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
18 def __repr__(self):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
19 return ' '.join([str(arg) for arg in self.cmd])
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
20
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
21 def ahref(target,name=None,type=None):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
22 if name is None:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
23 name = os.path.basename(target)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
24 ahref = "<a href='%s'" % target
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
25 if type is not None:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
26 ahref += " type='%s'" % type
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
27 ahref += ">%s</a>" % name
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
28 return ahref
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
29
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
30 def check_errors():
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
31 # Errors in Amplicon_analysis_pipeline.log
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
32 with open('Amplicon_analysis_pipeline.log','r') as pipeline_log:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
33 log = pipeline_log.read()
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
34 if "Names in the first column of Metatable.txt and in the second column of Final_name.txt do not match" in log:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
35 print_error("""*** Sample IDs don't match dataset names ***
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
36
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
37 The sample IDs (first column of the Metatable file) don't match the
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
38 supplied sample names for the input Fastq pairs.
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
39 """)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
40 # Errors in pipeline output
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
41 with open('pipeline.log','r') as pipeline_log:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
42 log = pipeline_log.read()
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
43 if "Errors and/or warnings detected in mapping file" in log:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
44 with open("Metatable_log/Metatable.log","r") as metatable_log:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
45 # Echo the Metatable log file to the tool log
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
46 print_error("""*** Error in Metatable mapping file ***
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
47
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
48 %s""" % metatable_log.read())
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
49 elif "No header line was found in mapping file" in log:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
50 # Report error to the tool log
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
51 print_error("""*** No header in Metatable mapping file ***
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
52
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
53 Check you've specified the correct file as the input Metatable""")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
54
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
55 def print_error(message):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
56 width = max([len(line) for line in message.split('\n')]) + 4
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
57 sys.stderr.write("\n%s\n" % ('*'*width))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
58 for line in message.split('\n'):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
59 sys.stderr.write("* %s%s *\n" % (line,' '*(width-len(line)-4)))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
60 sys.stderr.write("%s\n\n" % ('*'*width))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
61
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
62 def clean_up_name(sample):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
63 # Remove trailing "_L[0-9]+_001" from Fastq
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
64 # pair names
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
65 split_name = sample.split('_')
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
66 if split_name[-1] == "001":
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
67 split_name = split_name[:-1]
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
68 if split_name[-1].startswith('L'):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
69 try:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
70 int(split_name[-1][1:])
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
71 split_name = split_name[:-1]
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
72 except ValueError:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
73 pass
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
74 return '_'.join(split_name)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
75
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
76 def list_outputs(filen=None):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
77 # List the output directory contents
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
78 # If filen is specified then will be the filename to
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
79 # write to, otherwise write to stdout
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
80 if filen is not None:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
81 fp = open(filen,'w')
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
82 else:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
83 fp = sys.stdout
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
84 results_dir = os.path.abspath("RESULTS")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
85 fp.write("Listing contents of output dir %s:\n" % results_dir)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
86 ix = 0
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
87 for d,dirs,files in os.walk(results_dir):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
88 ix += 1
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
89 fp.write("-- %d: %s\n" % (ix,
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
90 os.path.relpath(d,results_dir)))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
91 for f in files:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
92 ix += 1
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
93 fp.write("---- %d: %s\n" % (ix,
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
94 os.path.relpath(f,results_dir)))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
95 # Close output file
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
96 if filen is not None:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
97 fp.close()
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
98
8
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
99 def find_executable(name):
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
100 # Locate executable on PATH
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
101 for p in os.environ['PATH'].split(os.pathsep):
12
fb2af52d67d1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit 53544cd620f81c5cfbdcb277e835f1c6da8588b0-dirty
pjbriggs
parents: 11
diff changeset
102 exe = os.path.join(p,name)
9
32a43bc3dd58 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 8
diff changeset
103 if os.path.isfile(exe) and os.access(exe,os.X_OK):
8
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
104 return exe
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
105 return None
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
106
0
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
107 if __name__ == "__main__":
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
108 # Command line
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
109 print "Amplicon analysis: starting"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
110 p = argparse.ArgumentParser()
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
111 p.add_argument("metatable",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
112 metavar="METATABLE_FILE",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
113 help="Metatable.txt file")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
114 p.add_argument("fastq_pairs",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
115 metavar="SAMPLE_NAME FQ_R1 FQ_R2",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
116 nargs="+",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
117 default=list(),
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
118 help="Triplets of SAMPLE_NAME followed by "
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
119 "a R1/R2 FASTQ file pair")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
120 p.add_argument("-g",dest="forward_pcr_primer")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
121 p.add_argument("-G",dest="reverse_pcr_primer")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
122 p.add_argument("-q",dest="trimming_threshold")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
123 p.add_argument("-O",dest="minimum_overlap")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
124 p.add_argument("-L",dest="minimum_length")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
125 p.add_argument("-l",dest="sliding_window_length")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
126 p.add_argument("-P",dest="pipeline",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
127 choices=["vsearch","uparse","qiime"],
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
128 type=str.lower,
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
129 default="vsearch")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
130 p.add_argument("-S",dest="use_silva",action="store_true")
2
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
131 p.add_argument("-H",dest="use_homd",action="store_true")
0
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
132 p.add_argument("-r",dest="reference_data_path")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
133 p.add_argument("-c",dest="categories_file")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
134 args = p.parse_args()
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
135
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
136 # Build the environment for running the pipeline
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
137 print "Amplicon analysis: building the environment"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
138 metatable_file = os.path.abspath(args.metatable)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
139 os.symlink(metatable_file,"Metatable.txt")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
140 print "-- made symlink to Metatable.txt"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
141
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
142 # Link to Categories.txt file (if provided)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
143 if args.categories_file is not None:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
144 categories_file = os.path.abspath(args.categories_file)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
145 os.symlink(categories_file,"Categories.txt")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
146 print "-- made symlink to Categories.txt"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
147
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
148 # Link to FASTQs and construct Final_name.txt file
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
149 sample_names = []
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
150 with open("Final_name.txt",'w') as final_name:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
151 fastqs = iter(args.fastq_pairs)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
152 for sample_name,fqr1,fqr2 in zip(fastqs,fastqs,fastqs):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
153 sample_name = clean_up_name(sample_name)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
154 r1 = "%s_R1_.fastq" % sample_name
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
155 r2 = "%s_R2_.fastq" % sample_name
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
156 os.symlink(fqr1,r1)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
157 os.symlink(fqr2,r2)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
158 final_name.write("%s\n" % '\t'.join((r1,sample_name)))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
159 final_name.write("%s\n" % '\t'.join((r2,sample_name)))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
160 sample_names.append(sample_name)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
161
2
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
162 # Reference database
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
163 if args.use_silva:
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
164 ref_database = "silva"
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
165 elif args.use_homd:
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
166 ref_database = "homd"
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
167 else:
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
168 ref_database = "gg"
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
169
8
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
170 # Executables
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
171 os.mkdir("bin")
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
172 os.environ["PATH"] = os.path.abspath("bin") + \
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
173 os.pathsep + \
10
b47cf1d6fb47 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 9
diff changeset
174 os.environ["PATH"]
8
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
175 print "-- updated PATH: %s" % os.environ["PATH"]
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
176 # Pipeline wants 'vsearch113' but bioconda version is just
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
177 # 'vsearch'
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
178 vsearch = find_executable("vsearch113")
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
179 if vsearch is None:
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
180 vsearch = find_executable("vsearch")
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
181 if vsearch:
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
182 os.symlink(vsearch,os.path.join("bin","vsearch113"))
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
183 print "-- made symlink to %s" % vsearch
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
184 else:
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
185 sys.stderr.write("Missing 'vsearch[113]'\n")
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
186 # Pipeline wants 'fasta-splitter.pl' but bioconda provides
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
187 # 'fasta-splitter'
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
188 fasta_splitter = find_executable("fasta-splitter.pl")
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
189 if fasta_splitter is None:
11
570228bb2fb7 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit 53544cd620f81c5cfbdcb277e835f1c6da8588b0
pjbriggs
parents: 10
diff changeset
190 fasta_splitter = os.readlink(
8
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
191 find_executable("fasta-splitter"))
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
192 if fasta_splitter:
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
193 os.symlink(vsearch,os.path.join("bin","fasta-splitter.pl"))
13
c87b166cbfe1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit 777167fc30406b792d0cf924753069526f8b3e5e-dirty
pjbriggs
parents: 12
diff changeset
194 print "-- made symlink to %s" % fasta_splitter
8
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
195 else:
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
196 sys.stderr.write("Missing 'fasta-splitter[.pl]'\n")
15
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
197 # Qiime 1.8.0 wants 'RDP_JAR_PATH' env var to point to
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
198 # the rdp_classifier.jar file
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
199 # biconda provides this in the 'share/rdp_classifier/' dir
18
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
200 # which is a link to the 'share/rdp_classifier-<VERSION>/' dir
15
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
201 rdp_classifier = find_executable("rdp_classifier")
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
202 if rdp_classifier:
18
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
203 # Generate expected path to JAR file
16
4bd582d23d4e planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 15
diff changeset
204 rdp_classifier = os.path.normpath(
4bd582d23d4e planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 15
diff changeset
205 os.path.join(os.path.dirname(rdp_classifier),
15
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
206 "..",
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
207 "share",
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
208 "rdp_classifier",
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
209 "rdp_classifier.jar"))
17
e1ba19551395 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 16
diff changeset
210 if rdp_classifier and os.path.exists(rdp_classifier):
18
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
211 # Get real directory (which contains version)
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
212 rdp_classifier_dir = os.readlink(
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
213 os.path.dirname(rdp_classifier))
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
214 # Extract the version
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
215 rdp_version = '-'.join(os.path.basename(
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
216 rdp_classifier_dir).split('-')[1:])
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
217 # Make a symlink to JAR file with version in the name
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
218 rdp_jar_path = os.path.join(os.path.abspath("bin"),
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
219 "rdp_classifier-%s.jar" %
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
220 rdp_version)
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
221 os.symlink(rdp_classifier,rdp_jar_path)
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
222 print "-- made symlink to %s" % rdp_classifier
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
223 # Set the RDP_JAR_PATH env var
877d53e2d963 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 17
diff changeset
224 os.environ["RDP_JAR_PATH"] = rdp_jar_path
15
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
225 print "-- set RDP_JAR_PATH: %s" % os.environ["RDP_JAR_PATH"]
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
226 else:
07b04a63abf1 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit af3afa7bd2c2441074879938cd93d9965908bbc7-dirty
pjbriggs
parents: 13
diff changeset
227 sys.stderr.write("Missing 'rdp_classifier.jar'\n")
21
092e39db5f59 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit bae32168fbfd40305a4768b889a8e7689e5987e3-dirty
pjbriggs
parents: 18
diff changeset
228 # Set up qiime_config file
092e39db5f59 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit bae32168fbfd40305a4768b889a8e7689e5987e3-dirty
pjbriggs
parents: 18
diff changeset
229 qiime_config_file = os.path.abspath("qiime_config")
092e39db5f59 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit bae32168fbfd40305a4768b889a8e7689e5987e3-dirty
pjbriggs
parents: 18
diff changeset
230 with open(qiime_config_file,'w') as qiime_config:
092e39db5f59 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit bae32168fbfd40305a4768b889a8e7689e5987e3-dirty
pjbriggs
parents: 18
diff changeset
231 # Set qiime_scripts_dir
22
eb7d118dd322 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit bae32168fbfd40305a4768b889a8e7689e5987e3-dirty
pjbriggs
parents: 21
diff changeset
232 qiime_config.write("qiime_scripts_dir\t%s" %
21
092e39db5f59 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit bae32168fbfd40305a4768b889a8e7689e5987e3-dirty
pjbriggs
parents: 18
diff changeset
233 os.path.dirname(
092e39db5f59 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit bae32168fbfd40305a4768b889a8e7689e5987e3-dirty
pjbriggs
parents: 18
diff changeset
234 find_executable("single_rarefaction.py")))
092e39db5f59 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit bae32168fbfd40305a4768b889a8e7689e5987e3-dirty
pjbriggs
parents: 18
diff changeset
235 os.environ["QIIME_CONFIG_FP"] = qiime_config_file
092e39db5f59 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit bae32168fbfd40305a4768b889a8e7689e5987e3-dirty
pjbriggs
parents: 18
diff changeset
236 print "-- set QIIME_CONFIG_FP: %s" % os.environ["QIIME_CONFIG_FP"]
8
8292f8262a9d planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit f72ff88ee11d09703bf38524dbb8026ee14bc3ef-dirty
pjbriggs
parents: 2
diff changeset
237
0
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
238 # Construct the pipeline command
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
239 print "Amplicon analysis: constructing pipeline command"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
240 pipeline = PipelineCmd("Amplicon_analysis_pipeline.sh")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
241 if args.forward_pcr_primer:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
242 pipeline.add_args("-g",args.forward_pcr_primer)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
243 if args.reverse_pcr_primer:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
244 pipeline.add_args("-G",args.reverse_pcr_primer)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
245 if args.trimming_threshold:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
246 pipeline.add_args("-q",args.trimming_threshold)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
247 if args.minimum_overlap:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
248 pipeline.add_args("-O",args.minimum_overlap)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
249 if args.minimum_length:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
250 pipeline.add_args("-L",args.minimum_length)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
251 if args.sliding_window_length:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
252 pipeline.add_args("-l",args.sliding_window_length)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
253 if args.reference_data_path:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
254 pipeline.add_args("-r",args.reference_data_path)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
255 pipeline.add_args("-P",args.pipeline)
2
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
256 if ref_database == "silva":
0
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
257 pipeline.add_args("-S")
2
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
258 elif ref_database == "homd":
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
259 pipeline.add_args("-H")
0
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
260
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
261 # Echo the pipeline command to stdout
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
262 print "Running %s" % pipeline
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
263
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
264 # Run the pipeline
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
265 with open("pipeline.log","w") as pipeline_out:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
266 try:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
267 subprocess.check_call(pipeline.cmd,
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
268 stdout=pipeline_out,
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
269 stderr=subprocess.STDOUT)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
270 exit_code = 0
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
271 print "Pipeline completed ok"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
272 except subprocess.CalledProcessError as ex:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
273 # Non-zero exit status
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
274 sys.stderr.write("Pipeline failed: exit code %s\n" %
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
275 ex.returncode)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
276 exit_code = ex.returncode
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
277 except Exception as ex:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
278 # Some other problem
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
279 sys.stderr.write("Unexpected error: %s\n" % str(ex))
2
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
280 exit_code = 1
0
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
281
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
282 # Write out the list of outputs
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
283 outputs_file = "Pipeline_outputs.txt"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
284 list_outputs(outputs_file)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
285
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
286 # Check for log file
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
287 log_file = "Amplicon_analysis_pipeline.log"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
288 if os.path.exists(log_file):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
289 print "Found log file: %s" % log_file
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
290 if exit_code == 0:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
291 # Create an HTML file to link to log files etc
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
292 # NB the paths to the files should be correct once
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
293 # copied by Galaxy on job completion
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
294 with open("pipeline_outputs.html","w") as html_out:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
295 html_out.write("""<html>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
296 <head>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
297 <title>Amplicon analysis pipeline: log files</title>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
298 <head>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
299 <body>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
300 <h1>Amplicon analysis pipeline: log files</h1>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
301 <ul>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
302 """)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
303 html_out.write(
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
304 "<li>%s</li>\n" %
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
305 ahref("Amplicon_analysis_pipeline.log",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
306 type="text/plain"))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
307 html_out.write(
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
308 "<li>%s</li>\n" %
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
309 ahref("pipeline.log",type="text/plain"))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
310 html_out.write(
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
311 "<li>%s</li>\n" %
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
312 ahref("Pipeline_outputs.txt",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
313 type="text/plain"))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
314 html_out.write(
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
315 "<li>%s</li>\n" %
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
316 ahref("Metatable.html"))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
317 html_out.write("""<ul>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
318 </body>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
319 </html>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
320 """)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
321 else:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
322 # Check for known error messages
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
323 check_errors()
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
324 # Write pipeline stdout to tool stderr
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
325 sys.stderr.write("\nOutput from pipeline:\n")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
326 with open("pipeline.log",'r') as log:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
327 sys.stderr.write("%s" % log.read())
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
328 # Write log file contents to tool log
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
329 print "\nAmplicon_analysis_pipeline.log:"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
330 with open(log_file,'r') as log:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
331 print "%s" % log.read()
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
332 else:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
333 sys.stderr.write("ERROR missing log file \"%s\"\n" %
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
334 log_file)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
335
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
336 # Handle FastQC boxplots
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
337 print "Amplicon analysis: collating per base quality boxplots"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
338 with open("fastqc_quality_boxplots.html","w") as quality_boxplots:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
339 # PHRED value for trimming
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
340 phred_score = 20
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
341 if args.trimming_threshold is not None:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
342 phred_score = args.trimming_threshold
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
343 # Write header for HTML output file
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
344 quality_boxplots.write("""<html>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
345 <head>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
346 <title>Amplicon analysis pipeline: Per-base Quality Boxplots (FastQC)</title>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
347 <head>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
348 <body>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
349 <h1>Amplicon analysis pipeline: Per-base Quality Boxplots (FastQC)</h1>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
350 """)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
351 # Look for raw and trimmed FastQC output for each sample
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
352 for sample_name in sample_names:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
353 fastqc_dir = os.path.join(sample_name,"FastQC")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
354 quality_boxplots.write("<h2>%s</h2>" % sample_name)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
355 for d in ("Raw","cutdapt_sickle/Q%s" % phred_score):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
356 quality_boxplots.write("<h3>%s</h3>" % d)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
357 fastqc_html_files = glob.glob(
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
358 os.path.join(fastqc_dir,d,"*_fastqc.html"))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
359 if not fastqc_html_files:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
360 quality_boxplots.write("<p>No FastQC outputs found</p>")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
361 continue
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
362 # Pull out the per-base quality boxplots
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
363 for f in fastqc_html_files:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
364 boxplot = None
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
365 with open(f) as fp:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
366 for line in fp.read().split(">"):
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
367 try:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
368 line.index("alt=\"Per base quality graph\"")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
369 boxplot = line + ">"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
370 break
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
371 except ValueError:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
372 pass
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
373 if boxplot is None:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
374 boxplot = "Missing plot"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
375 quality_boxplots.write("<h4>%s</h4><p>%s</p>" %
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
376 (os.path.basename(f),
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
377 boxplot))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
378 quality_boxplots.write("""</body>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
379 </html>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
380 """)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
381
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
382 # Handle additional output when categories file was supplied
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
383 if args.categories_file is not None:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
384 # Alpha diversity boxplots
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
385 print "Amplicon analysis: indexing alpha diversity boxplots"
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
386 boxplots_dir = os.path.abspath(
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
387 os.path.join("RESULTS",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
388 "%s_%s" % (args.pipeline.title(),
2
a898ee628343 Updated to version 1.2.1.0
pjbriggs
parents: 0
diff changeset
389 ref_database),
0
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
390 "Alpha_diversity",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
391 "Alpha_diversity_boxplot",
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
392 "Categories_shannon"))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
393 print "Amplicon analysis: gathering PDFs from %s" % boxplots_dir
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
394 boxplot_pdfs = [os.path.basename(pdf)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
395 for pdf in
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
396 sorted(glob.glob(
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
397 os.path.join(boxplots_dir,"*.pdf")))]
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
398 with open("alpha_diversity_boxplots.html","w") as boxplots_out:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
399 boxplots_out.write("""<html>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
400 <head>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
401 <title>Amplicon analysis pipeline: Alpha Diversity Boxplots (Shannon)</title>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
402 <head>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
403 <body>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
404 <h1>Amplicon analysis pipeline: Alpha Diversity Boxplots (Shannon)</h1>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
405 """)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
406 boxplots_out.write("<ul>\n")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
407 for pdf in boxplot_pdfs:
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
408 boxplots_out.write("<li>%s</li>\n" % ahref(pdf))
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
409 boxplots_out.write("<ul>\n")
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
410 boxplots_out.write("""</body>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
411 </html>
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
412 """)
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
413
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
414 # Finish
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
415 print "Amplicon analysis: finishing, exit code: %s" % exit_code
b433086738d6 planemo upload for repository https://github.com/pjbriggs/Amplicon_analysis-galaxy commit ba3e5b591407db52a586361efb21927c8171ec0e
pjbriggs
parents:
diff changeset
416 sys.exit(exit_code)