Mercurial > repos > iuc > vsnp_build_tables
annotate vsnp_statistics.py @ 7:3dff2d30c608 draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
author | iuc |
---|---|
date | Fri, 27 Aug 2021 11:45:05 +0000 |
parents | |
children | 25714108bb22 |
rev | line source |
---|---|
7
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
2 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
3 import argparse |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
4 import csv |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
5 import gzip |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
6 import os |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
7 from functools import partial |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
8 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
9 import numpy |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
10 import pandas |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
11 from Bio import SeqIO |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
12 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
13 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
14 def nice_size(size): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
15 # Returns a readably formatted string with the size |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
16 words = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
17 prefix = '' |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
18 try: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
19 size = float(size) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
20 if size < 0: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
21 size = abs(size) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
22 prefix = '-' |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
23 except Exception: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
24 return '??? bytes' |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
25 for ind, word in enumerate(words): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
26 step = 1024 ** (ind + 1) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
27 if step > size: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
28 size = size / float(1024 ** ind) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
29 if word == 'bytes': # No decimals for bytes |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
30 return "%s%d bytes" % (prefix, size) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
31 return "%s%.1f %s" % (prefix, size, word) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
32 return '??? bytes' |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
33 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
34 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
35 def output_statistics(fastq_files, idxstats_files, metrics_files, output_file, gzipped, dbkey): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
36 # Produce an Excel spreadsheet that |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
37 # contains a row for each sample. |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
38 columns = ['Reference', 'File Size', 'Mean Read Length', 'Mean Read Quality', 'Reads Passing Q30', |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
39 'Total Reads', 'All Mapped Reads', 'Unmapped Reads', 'Unmapped Reads Percentage of Total', |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
40 'Reference with Coverage', 'Average Depth of Coverage', 'Good SNP Count'] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
41 data_frames = [] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
42 for i, fastq_file in enumerate(fastq_files): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
43 idxstats_file = idxstats_files[i] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
44 metrics_file = metrics_files[i] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
45 file_name_base = os.path.basename(fastq_file) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
46 # Read fastq_file into a data frame. |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
47 _open = partial(gzip.open, mode='rt') if gzipped else open |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
48 with _open(fastq_file) as fh: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
49 identifiers = [] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
50 seqs = [] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
51 letter_annotations = [] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
52 for seq_record in SeqIO.parse(fh, "fastq"): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
53 identifiers.append(seq_record.id) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
54 seqs.append(seq_record.seq) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
55 letter_annotations.append(seq_record.letter_annotations["phred_quality"]) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
56 # Convert lists to Pandas series. |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
57 s1 = pandas.Series(identifiers, name='id') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
58 s2 = pandas.Series(seqs, name='seq') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
59 # Gather Series into a data frame. |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
60 fastq_df = pandas.DataFrame(dict(id=s1, seq=s2)).set_index(['id']) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
61 total_reads = int(len(fastq_df.index) / 4) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
62 current_sample_df = pandas.DataFrame(index=[file_name_base], columns=columns) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
63 # Reference |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
64 current_sample_df.at[file_name_base, 'Reference'] = dbkey |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
65 # File Size |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
66 current_sample_df.at[file_name_base, 'File Size'] = nice_size(os.path.getsize(fastq_file)) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
67 # Mean Read Length |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
68 sampling_size = 10000 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
69 if sampling_size > total_reads: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
70 sampling_size = total_reads |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
71 fastq_df = fastq_df.iloc[3::4].sample(sampling_size) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
72 dict_mean = {} |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
73 list_length = [] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
74 i = 0 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
75 for id, seq, in fastq_df.iterrows(): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
76 dict_mean[id] = numpy.mean(letter_annotations[i]) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
77 list_length.append(len(seq.array[0])) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
78 i += 1 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
79 current_sample_df.at[file_name_base, 'Mean Read Length'] = '%.1f' % numpy.mean(list_length) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
80 # Mean Read Quality |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
81 df_mean = pandas.DataFrame.from_dict(dict_mean, orient='index', columns=['ave']) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
82 current_sample_df.at[file_name_base, 'Mean Read Quality'] = '%.1f' % df_mean['ave'].mean() |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
83 # Reads Passing Q30 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
84 reads_gt_q30 = len(df_mean[df_mean['ave'] >= 30]) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
85 reads_passing_q30 = '{:10.2f}'.format(reads_gt_q30 / sampling_size) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
86 current_sample_df.at[file_name_base, 'Reads Passing Q30'] = reads_passing_q30 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
87 # Total Reads |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
88 current_sample_df.at[file_name_base, 'Total Reads'] = total_reads |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
89 # All Mapped Reads |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
90 all_mapped_reads, unmapped_reads = process_idxstats_file(idxstats_file) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
91 current_sample_df.at[file_name_base, 'All Mapped Reads'] = all_mapped_reads |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
92 # Unmapped Reads |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
93 current_sample_df.at[file_name_base, 'Unmapped Reads'] = unmapped_reads |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
94 # Unmapped Reads Percentage of Total |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
95 if unmapped_reads > 0: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
96 unmapped_reads_percentage = '{:10.2f}'.format(unmapped_reads / total_reads) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
97 else: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
98 unmapped_reads_percentage = 0 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
99 current_sample_df.at[file_name_base, 'Unmapped Reads Percentage of Total'] = unmapped_reads_percentage |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
100 # Reference with Coverage |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
101 ref_with_coverage, avg_depth_of_coverage, good_snp_count = process_metrics_file(metrics_file) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
102 current_sample_df.at[file_name_base, 'Reference with Coverage'] = ref_with_coverage |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
103 # Average Depth of Coverage |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
104 current_sample_df.at[file_name_base, 'Average Depth of Coverage'] = avg_depth_of_coverage |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
105 # Good SNP Count |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
106 current_sample_df.at[file_name_base, 'Good SNP Count'] = good_snp_count |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
107 data_frames.append(current_sample_df) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
108 output_df = pandas.concat(data_frames) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
109 output_df.to_csv(output_file, sep='\t', quoting=csv.QUOTE_NONE, escapechar='\\') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
110 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
111 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
112 def process_idxstats_file(idxstats_file): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
113 all_mapped_reads = 0 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
114 unmapped_reads = 0 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
115 with open(idxstats_file, "r") as fh: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
116 for i, line in enumerate(fh): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
117 line = line.rstrip('\r\n') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
118 items = line.split("\t") |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
119 if i == 0: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
120 # NC_002945.4 4349904 213570 4047 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
121 all_mapped_reads = int(items[2]) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
122 elif i == 1: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
123 # * 0 0 82774 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
124 unmapped_reads = int(items[3]) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
125 return all_mapped_reads, unmapped_reads |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
126 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
127 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
128 def process_metrics_file(metrics_file): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
129 ref_with_coverage = '0%' |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
130 avg_depth_of_coverage = 0 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
131 good_snp_count = 0 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
132 with open(metrics_file, "r") as ifh: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
133 for i, line in enumerate(ifh): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
134 if i == 0: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
135 # Skip comments. |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
136 continue |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
137 line = line.rstrip('\r\n') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
138 items = line.split("\t") |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
139 if i == 1: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
140 # MarkDuplicates 10.338671 98.74% |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
141 ref_with_coverage = items[3] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
142 avg_depth_of_coverage = items[2] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
143 elif i == 2: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
144 # VCFfilter 611 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
145 good_snp_count = items[1] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
146 return ref_with_coverage, avg_depth_of_coverage, good_snp_count |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
147 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
148 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
149 parser = argparse.ArgumentParser() |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
150 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
151 parser.add_argument('--dbkey', action='store', dest='dbkey', help='Reference dbkey') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
152 parser.add_argument('--gzipped', action='store_true', dest='gzipped', required=False, default=False, help='Input files are gzipped') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
153 parser.add_argument('--input_idxstats_dir', action='store', dest='input_idxstats_dir', required=False, default=None, help='Samtools idxstats input directory') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
154 parser.add_argument('--input_metrics_dir', action='store', dest='input_metrics_dir', required=False, default=None, help='vSNP add zero coverage metrics input directory') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
155 parser.add_argument('--input_reads_dir', action='store', dest='input_reads_dir', required=False, default=None, help='Samples input directory') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
156 parser.add_argument('--list_paired', action='store_true', dest='list_paired', required=False, default=False, help='Input samples is a list of paired reads') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
157 parser.add_argument('--output', action='store', dest='output', help='Output Excel statistics file') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
158 parser.add_argument('--read1', action='store', dest='read1', help='Required: single read') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
159 parser.add_argument('--read2', action='store', dest='read2', required=False, default=None, help='Optional: paired read') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
160 parser.add_argument('--samtools_idxstats', action='store', dest='samtools_idxstats', help='Output of samtools_idxstats') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
161 parser.add_argument('--vsnp_azc', action='store', dest='vsnp_azc', help='Output of vsnp_add_zero_coverage') |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
162 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
163 args = parser.parse_args() |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
164 |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
165 fastq_files = [] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
166 idxstats_files = [] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
167 metrics_files = [] |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
168 # Accumulate inputs. |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
169 if args.read1 is not None: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
170 # The inputs are not dataset collections, so |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
171 # read1, read2 (possibly) and vsnp_azc will also |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
172 # not be None. |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
173 fastq_files.append(args.read1) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
174 idxstats_files.append(args.samtools_idxstats) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
175 metrics_files.append(args.vsnp_azc) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
176 if args.read2 is not None: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
177 fastq_files.append(args.read2) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
178 idxstats_files.append(args.samtools_idxstats) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
179 metrics_files.append(args.vsnp_azc) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
180 else: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
181 for file_name in sorted(os.listdir(args.input_reads_dir)): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
182 fastq_files.append(os.path.join(args.input_reads_dir, file_name)) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
183 for file_name in sorted(os.listdir(args.input_idxstats_dir)): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
184 idxstats_files.append(os.path.join(args.input_idxstats_dir, file_name)) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
185 if args.list_paired: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
186 # Add the idxstats file for reverse. |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
187 idxstats_files.append(os.path.join(args.input_idxstats_dir, file_name)) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
188 for file_name in sorted(os.listdir(args.input_metrics_dir)): |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
189 metrics_files.append(os.path.join(args.input_metrics_dir, file_name)) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
190 if args.list_paired: |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
191 # Add the metrics file for reverse. |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
192 metrics_files.append(os.path.join(args.input_metrics_dir, file_name)) |
3dff2d30c608
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/vsnp commit 92f46d4bb55b582f05ac3c4b094307f114cbf98f"
iuc
parents:
diff
changeset
|
193 output_statistics(fastq_files, idxstats_files, metrics_files, args.output, args.gzipped, args.dbkey) |