annotate varscan.py @ 10:db94eadb92c1 draft default tip

"planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 1232893782204bb041dd6ed46711295cb0bfc03f"
author iuc
date Sat, 04 Dec 2021 22:23:16 +0000
parents e3f170cc4f95
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1 #!/usr/bin/env python3
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
2 from __future__ import print_function
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
3
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
4 import argparse
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
5 import io
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
6 import os
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
7 import subprocess
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
8 import sys
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
9 import tempfile
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
10 import time
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
11 from collections import namedtuple
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
12 from contextlib import ExitStack
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
13 from functools import partial
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
14 from threading import Thread
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
15
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
16 import pysam
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
17
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
18
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
19 AlleleStats = namedtuple(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
20 "AlleleStats",
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
21 [
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
22 'reads_total',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
23 'reads_fw',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
24 'reads_rv',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
25 'avg_mapqual',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
26 'avg_basequal',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
27 'avg_dist_from_center',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
28 'avg_mismatch_fraction',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
29 'avg_mismatch_qualsum',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
30 'avg_clipped_len',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
31 'avg_dist_from_3prime'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
32 ]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
33 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
34
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
35
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
36 def _get_allele_specific_pileup_column_stats(pileups, ref_fetch,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
37 ignore_md, ignore_nm,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
38 mm_runs, detect_q2_runs):
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
39 var_reads_plus = var_reads_minus = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
40 sum_mapping_qualities = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
41 sum_base_qualities = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
42 sum_dist_from_center = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
43 sum_dist_from_3prime = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
44 sum_clipped_length = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
45 sum_unclipped_length = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
46 sum_mismatch_fractions = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
47 sum_mismatch_qualities = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
48
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
49 for p in pileups:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
50 if p.alignment.is_reverse:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
51 var_reads_minus += 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
52 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
53 var_reads_plus += 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
54 sum_mapping_qualities += p.alignment.mapping_quality
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
55 sum_base_qualities += p.alignment.query_qualities[p.query_position]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
56 sum_clipped_length += p.alignment.query_alignment_length
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
57 unclipped_length = p.alignment.query_length
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
58 sum_unclipped_length += unclipped_length
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
59 # The following calculations are all in 1-based coordinates
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
60 # with respect to the physical 5'-end of the read sequence.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
61 if p.alignment.is_reverse:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
62 read_base_pos = unclipped_length - p.query_position
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
63 read_first_aln_pos = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
64 unclipped_length - p.alignment.query_alignment_end + 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
65 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
66 read_last_aln_pos = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
67 unclipped_length - p.alignment.query_alignment_start
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
68 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
69 qualities_3to5prime = p.alignment.query_alignment_qualities
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
70 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
71 read_base_pos = p.query_position + 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
72 read_first_aln_pos = p.alignment.query_alignment_start + 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
73 read_last_aln_pos = p.alignment.query_alignment_end
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
74 qualities_3to5prime = reversed(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
75 p.alignment.query_alignment_qualities
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
76 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
77
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
78 read_last_effective_aln_pos = read_last_aln_pos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
79 if detect_q2_runs:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
80 # Note: the original bam-readcount algorithm always takes
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
81 # terminal q2 runs into account when determining the
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
82 # effective 3'-ends of reads.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
83 # However, q2 runs have no special meaning since Illumina
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
84 # pipeline version 1.8 so detecting them is optional
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
85 # in this code.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
86 for qual in qualities_3to5prime:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
87 if qual != 2:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
88 break
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
89 read_last_effective_aln_pos -= 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
90
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
91 # Note: the original bam-readcount algorithm defines the
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
92 # read center as:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
93 # read_center = p.alignment.query_alignment_length / 2
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
94 # This is less accurate than the implementation here.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
95 read_center = (read_first_aln_pos + read_last_aln_pos) / 2
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
96 sum_dist_from_center += 1 - abs(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
97 read_base_pos - read_center
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
98 ) / (read_center - 1)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
99 # To calculate the distance of base positions from the 3'-ends
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
100 # of reads bam-readcount uses the formula:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
101 # sum_dist_from_3prime += abs(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
102 # read_last_effective_aln_pos - read_base_pos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
103 # ) / (unclipped_length - 1)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
104 # , which treats base positions on both sides of the effective
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
105 # 3'-end equally. Since this seems hard to justify, we cap
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
106 # the distance calculation at 0 for base positions past the
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
107 # effective 3'-end (which, in turn, should only be possible
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
108 # with detection of q2 runs).
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
109 if read_last_effective_aln_pos > read_base_pos:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
110 sum_dist_from_3prime += (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
111 read_last_effective_aln_pos - read_base_pos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
112 ) / (unclipped_length - 1)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
113
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
114 if sum_mismatch_fractions >= 0 or sum_mismatch_qualities >= 0:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
115 # sum_mismatch_fractions and sum_mismatch_qualities will be
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
116 # set to float('nan') if reference info (in form of an MD tag or
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
117 # an actual reference sequence) was not available for any previous
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
118 # read in the pileup.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
119 # In that case, there is no point to trying to calculate
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
120 # mismatch stats for other reads anymore.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
121
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
122 # The following mismatch calculations use this logic:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
123 # 1. For determining the edit distance between an aligned read and
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
124 # the reference, we follow the authoritative definition of the
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
125 # NM tag calculation in
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
126 # http://samtools.github.io/hts-specs/SAMtags.pdf
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
127 #
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
128 # For historical reasons, the result of this calculation will
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
129 # disagree more often than not with NM tag values calculated by
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
130 # other tools.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
131 # If precalculated NM tag values are present on the aligned
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
132 # reads, these can be given preference through the use_nm flag.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
133 # Doing so will mimick the behavior of bam-readcount, which
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
134 # requires and always just looks at NM tags.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
135 # 2. For determining mismatch quality sums, a mismatch is defined
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
136 # differently and in accordance with the implementation in
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
137 # bam-readcount:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
138 # - only mismatches (not inserted or deleted bases) are
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
139 # considered
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
140 # - 'N' in the reference is considered a match for any read base
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
141 # - any matching (case-insensitive) base in reference and read
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
142 # is considered a match, even if that base is not one of
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
143 # A, C, G or T.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
144 # In both 1. and 2. above a '=' in the read is always considered a
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
145 # match, irrespective of the reference base.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
146
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
147 num_mismatches = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
148 if not ignore_md:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
149 try:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
150 # see if the read has an MD tag, in which case pysam can
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
151 # calculate the reference sequence for us
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
152 ref_seq = p.alignment.get_reference_sequence().upper()
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
153 except ValueError:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
154 ignore_md = True
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
155 if not ignore_nm:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
156 try:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
157 num_mismatches = p.alignment.get_tag('NM')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
158 except KeyError:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
159 ignore_nm = True
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
160
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
161 if ignore_md:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
162 if not ref_fetch:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
163 # cannot calculate mismatch stats without ref info
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
164 sum_mismatch_qualities = float('nan')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
165 if ignore_nm:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
166 sum_mismatch_fractions = float('nan')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
167 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
168 sum_mismatch_fractions += (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
169 num_mismatches / p.alignment.query_alignment_length
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
170 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
171 continue
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
172 # Without an MD tag we need to extract the relevant part
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
173 # of the reference from the full sequence by position.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
174 ref_positions = p.alignment.get_reference_positions()
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
175 ref_seq = ref_fetch(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
176 ref_positions[0], ref_positions[-1] + 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
177 ).upper()
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
178
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
179 potential_matches = {'A', 'C', 'G', 'T'}
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
180 aligned_pairs = p.alignment.get_aligned_pairs(matches_only=True)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
181 ref_offset = aligned_pairs[0][1]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
182 last_mismatch_pos = None
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
183 mismatch_run_quals = []
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
184 for qpos, rpos in aligned_pairs:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
185 read_base = p.alignment.query_sequence[qpos].upper()
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
186 if read_base == '=':
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
187 # always treat the special read base '=' as a
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
188 # match, irrespective of the reference base
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
189 continue
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
190 ref_base = ref_seq[rpos - ref_offset]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
191 # see if we have a mismatch to use for mismatch quality sum
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
192 # calculation
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
193 if ref_base != 'N' and ref_base != read_base:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
194 if mm_runs:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
195 if (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
196 last_mismatch_pos is None
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
197 ) or (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
198 last_mismatch_pos + 1 == qpos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
199 ):
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
200 mismatch_run_quals.append(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
201 p.alignment.query_qualities[qpos]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
202 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
203 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
204 sum_mismatch_qualities += max(mismatch_run_quals)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
205 mismatch_run_quals = [
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
206 p.alignment.query_qualities[qpos]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
207 ]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
208 last_mismatch_pos = qpos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
209 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
210 sum_mismatch_qualities += (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
211 p.alignment.query_qualities[qpos]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
212 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
213 if ignore_nm:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
214 # see if we have a mismatch that increases the edit
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
215 # distance according to the SAMtags specs
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
216 if (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
217 read_base not in potential_matches
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
218 ) or (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
219 ref_base not in potential_matches
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
220 ) or (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
221 read_base != ref_base
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
222 ):
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
223 num_mismatches += 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
224
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
225 if mismatch_run_quals:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
226 sum_mismatch_qualities += max(mismatch_run_quals)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
227 if ignore_nm:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
228 # use the number of mismatches calculated above,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
229 # but add inserted and deleted bases to it
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
230 cigar_stats = p.alignment.get_cigar_stats()[0]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
231 num_mismatches += cigar_stats[1] + cigar_stats[2]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
232 sum_mismatch_fractions += (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
233 num_mismatches / p.alignment.query_alignment_length
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
234 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
235
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
236 return (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
237 var_reads_plus,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
238 var_reads_minus,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
239 sum_mapping_qualities,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
240 sum_base_qualities,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
241 sum_dist_from_center,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
242 sum_mismatch_fractions,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
243 sum_mismatch_qualities,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
244 sum_clipped_length,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
245 sum_dist_from_3prime
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
246 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
247
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
248
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
249 def get_allele_stats(reads, pos, alleles,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
250 ref=None, ignore_md=True, ignore_nm=True,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
251 mm_runs=True, detect_q2_runs=False,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
252 pileup_args=None):
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
253 chrom, start, stop = pos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
254 if pileup_args is None:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
255 pileup_args = {}
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
256 if pileup_args.get('stepper') == 'samtools':
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
257 if pileup_args.get('compute_baq', True) is not False:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
258 if 'fastafile' not in pileup_args:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
259 pileup_args['fastafile'] = ref
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
260 # be careful when passing in a custom 'fastafile' option:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
261 # providing it slows down pysam tremendously even if the option
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
262 # isn't actually required.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
263
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
264 pile = reads.pileup(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
265 chrom, start, stop,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
266 **pileup_args
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
267 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
268 # apply false-positive filtering a la varscan fpfilter
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
269 # find the variant site in the pileup columns
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
270 for pile_column in pile:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
271 if pile_column.reference_pos == start:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
272 break
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
273 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
274 # With no reads covering the genomic position
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
275 # we can only return "empty" allele stats
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
276 return [
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
277 AlleleStats(0, 0, 0, *[float('nan')] * 7)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
278 for allele in alleles
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
279 ]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
280
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
281 # extract required information
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
282 # overall read depth at the site
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
283 read_depth = pile_column.get_num_aligned()
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
284 assert read_depth > 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
285
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
286 alleles_stats = []
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
287 for allele in alleles:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
288 if '-' in allele:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
289 allele, indel_type, indel_after = allele.partition('-')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
290 indel_len = -len(indel_after)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
291 elif '+' in allele:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
292 allele, indel_type, indel_after = allele.partition('+')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
293 indel_len = len(indel_after)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
294 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
295 indel_type = None
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
296
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
297 stats_it = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
298 p for p in pile_column.pileups
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
299 # skip reads that don't support the allele we're looking for
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
300 if (p.query_position is not None)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
301 and (p.alignment.query_sequence[p.query_position] == allele)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
302 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
303 if indel_type == '-':
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
304 stats_it = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
305 p for p in stats_it if p.indel == indel_len
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
306 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
307 elif indel_type == '+':
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
308 stats_it = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
309 p for p in stats_it if (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
310 p.indel == indel_len
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
311 ) and (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
312 p.alignment.query_sequence[
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
313 p.query_position + 1:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
314 p.query_position + 1 + indel_len
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
315 ] == indel_after
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
316 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
317 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
318 allele_stats = _get_allele_specific_pileup_column_stats(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
319 stats_it,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
320 partial(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
321 pysam.FastaFile.fetch, ref, chrom
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
322 ) if ref else None,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
323 ignore_md,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
324 ignore_nm,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
325 mm_runs,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
326 detect_q2_runs
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
327 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
328
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
329 allele_reads_total = allele_stats[0] + allele_stats[1]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
330 if allele_reads_total == 0:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
331 # No stats without reads!
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
332 alleles_stats.append(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
333 AlleleStats(read_depth, 0, 0, *[float('nan')] * 7)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
334 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
335 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
336 alleles_stats.append(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
337 AlleleStats(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
338 read_depth, allele_stats[0], allele_stats[1],
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
339 *(i / allele_reads_total for i in allele_stats[2:])
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
340 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
341 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
342 return alleles_stats
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
343
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
344
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
345 class VariantCallingError (RuntimeError):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
346 """Exception class for issues with samtools and varscan subprocesses."""
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
347
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
348 def __init__(self, message=None, call='', error=''):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
349 self.message = message
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
350 self.call = call.strip()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
351 self.error = error.strip()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
352
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
353 def __str__(self):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
354 if self.message is None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
355 return ''
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
356 if self.error:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
357 msg_header = '"{0}" failed with:\n{1}\n\n'.format(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
358 self.call, self.error
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
359 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
360 else:
10
db94eadb92c1 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 1232893782204bb041dd6ed46711295cb0bfc03f"
iuc
parents: 9
diff changeset
361 msg_header = '{0} failed.\nNo further information about this error is available.\n\n'.format(
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
362 self.call
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
363 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
364 return msg_header + self.message
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
365
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
366
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
367 class VarScanCaller (object):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
368 def __init__(self, ref_genome, bam_input_files,
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
369 max_depth=None, count_orphans=False, detect_overlaps=True,
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
370 min_mapqual=None, min_basequal=None,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
371 threads=1, verbose=False, quiet=True
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
372 ):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
373 self.ref_genome = ref_genome
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
374 self.bam_input_files = bam_input_files
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
375 self.max_depth = max_depth
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
376 self.count_orphans = count_orphans
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
377 self.detect_overlaps = detect_overlaps
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
378 self.min_mapqual = min_mapqual
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
379 self.min_basequal = min_basequal
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
380 self.threads = threads
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
381 self.verbose = verbose
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
382 self.quiet = quiet
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
383
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
384 with pysam.FastaFile(ref_genome) as ref_fa:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
385 self.ref_contigs = ref_fa.references
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
386 self.ref_lengths = ref_fa.lengths
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
387
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
388 self.pileup_engine = ['samtools', 'mpileup']
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
389 self.varcall_engine = ['varscan', 'somatic']
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
390 self.requires_stdout_redirect = False
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
391 self.TemporaryContigVCF = partial(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
392 tempfile.NamedTemporaryFile,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
393 mode='wb', suffix='', delete=False, dir=os.getcwd()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
394 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
395 self.tmpfiles = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
396
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
397 def _get_pysam_pileup_args(self):
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
398 # Compute the pileup args dynamically to account for possibly updated
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
399 # instance attributes.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
400
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
401 # fixed default parameters
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
402 # Note on the fixed default for 'ignore_overlaps':
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
403 # In order to use the exact same pileup parameters during variant
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
404 # calling and postprocessing, we would have to compute the setting
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
405 # dynamically like so:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
406 # if not self.detect_overlaps:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
407 # param_dict['ignore_overlaps'] = False
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
408 # However, samtools/pysam implement overlap correction by manipulating
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
409 # (setting to zero) the lower qualities of bases that are part of an
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
410 # overlap (see
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
411 # https://sourceforge.net/p/samtools/mailman/message/32793789/). This
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
412 # manipulation has such a big undesirable effect on base quality stats
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
413 # calculated during postprocessing that calculating the stats on a
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
414 # slightly different pileup seems like the lesser evil.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
415
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
416 param_dict = {
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
417 'ignore_overlaps': False,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
418 'compute_baq': False,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
419 'stepper': 'samtools',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
420 }
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
421 # user-controllable parameters
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
422 if self.count_orphans:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
423 param_dict['ignore_orphans'] = False
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
424 if self.max_depth is not None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
425 param_dict['max_depth'] = self.max_depth
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
426 if self.min_mapqual is not None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
427 param_dict['min_mapping_quality'] = self.min_mapqual
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
428 if self.min_basequal is not None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
429 param_dict['min_base_quality'] = self.min_basequal
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
430 return param_dict
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
431
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
432 def varcall_parallel(self, normal_purity=None, tumor_purity=None,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
433 min_coverage=None,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
434 min_var_count=None,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
435 min_var_freq=None, min_hom_freq=None,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
436 p_value=None, somatic_p_value=None,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
437 threads=None, verbose=None, quiet=None
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
438 ):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
439 if not threads:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
440 threads = self.threads
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
441 if verbose is None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
442 verbose = self.verbose
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
443 if quiet is None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
444 quiet = self.quiet
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
445 # mapping of method parameters to varcall engine command line options
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
446 varcall_engine_option_mapping = [
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
447 ('--normal-purity', normal_purity),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
448 ('--tumor-purity', tumor_purity),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
449 ('--min-coverage', min_coverage),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
450 ('--min-reads2', min_var_count),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
451 ('--min-var-freq', min_var_freq),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
452 ('--min-freq-for-hom', min_hom_freq),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
453 ('--p-value', p_value),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
454 ('--somatic-p-value', somatic_p_value),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
455 ('--min-avg-qual', self.min_basequal)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
456 ]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
457 varcall_engine_options = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
458 for option, value in varcall_engine_option_mapping:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
459 if value is not None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
460 varcall_engine_options += [option, str(value)]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
461 pileup_engine_options = ['-B']
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
462 if self.count_orphans:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
463 pileup_engine_options += ['-A']
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
464 if not self.detect_overlaps:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
465 pileup_engine_options += ['-x']
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
466 if self.max_depth is not None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
467 pileup_engine_options += ['-d', str(self.max_depth)]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
468 if self.min_mapqual is not None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
469 pileup_engine_options += ['-q', str(self.min_mapqual)]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
470 if self.min_basequal is not None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
471 pileup_engine_options += ['-Q', str(self.min_basequal)]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
472
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
473 # Create a tuple of calls to samtools mpileup and varscan for
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
474 # each contig. The contig name is stored as the third element of
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
475 # that tuple.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
476 # The calls are stored in the reverse order of the contig list so
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
477 # that they can be popped off later in the original order
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
478 calls = [(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
479 self.pileup_engine + pileup_engine_options + [
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
480 '-r', contig + ':',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
481 '-f', self.ref_genome
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
482 ] + self.bam_input_files,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
483 self.varcall_engine + [
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
484 '-', '{out}', '--output-vcf', '1', '--mpileup', '1'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
485 ] + varcall_engine_options,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
486 contig
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
487 ) for contig in self.ref_contigs[::-1]]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
488
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
489 if verbose:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
490 print('Starting variant calling ..')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
491
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
492 # launch subprocesses and monitor their status
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
493 subprocesses = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
494 error_table = {}
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
495 tmp_io_started = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
496 tmp_io_finished = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
497 self.tmpfiles = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
498
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
499 def enqueue_stderr_output(out, stderr_buffer):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
500 for line in iter(out.readline, b''):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
501 # Eventually we are going to print the contents of
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
502 # the stderr_buffer to sys.stderr so we can
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
503 # decode things here using its encoding.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
504 # We do a 'backslashreplace' just to be on the safe side.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
505 stderr_buffer.write(line.decode(sys.stderr.encoding,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
506 'backslashreplace'))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
507 out.close()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
508
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
509 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
510 while subprocesses or calls:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
511 while calls and len(subprocesses) < threads:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
512 # There are still calls waiting for execution and we
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
513 # have unoccupied threads so we launch a new combined
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
514 # call to samtools mpileup and the variant caller.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
515
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
516 # pop the call arguments from our call stack
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
517 call = calls.pop()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
518 # get the name of the contig that this call is going
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
519 # to work on
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
520 contig = call[2]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
521 # Based on the contig name, generate a readable and
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
522 # file system-compatible prefix and use it to create
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
523 # a named temporary file, to which the call output
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
524 # will be redirected.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
525 # At the moment we create the output file we add it to
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
526 # the list of all temporary output files so that we can
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
527 # remove it eventually during cleanup.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
528 call_out = self.TemporaryContigVCF(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
529 prefix=''.join(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
530 c if c.isalnum() else '_' for c in contig
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
531 ) + '_',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
532 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
533 # maintain a list of variant call outputs
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
534 # in the order the subprocesses got launched
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
535 tmp_io_started.append(call_out.name)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
536 if self.requires_stdout_redirect:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
537 # redirect stdout to the temporary file just created
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
538 stdout_p2 = call_out
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
539 stderr_p2 = subprocess.PIPE
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
540 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
541 # variant caller wants to write output to file directly
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
542 stdout_p2 = subprocess.PIPE
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
543 stderr_p2 = subprocess.STDOUT
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
544 call[1][call[1].index('{out}')] = call_out.name
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
545 call_out.close()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
546 # for reporting purposes, join the arguments for the
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
547 # samtools and the variant caller calls into readable
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
548 # strings
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
549 c_str = (' '.join(call[0]), ' '.join(call[1]))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
550 error_table[c_str] = [io.StringIO(), io.StringIO()]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
551 # start the subprocesses
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
552 p1 = subprocess.Popen(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
553 call[0],
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
554 stdout=subprocess.PIPE, stderr=subprocess.PIPE
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
555 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
556 p2 = subprocess.Popen(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
557 call[1],
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
558 stdin=p1.stdout,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
559 stdout=stdout_p2,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
560 stderr=stderr_p2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
561 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
562 # subprocess bookkeeping
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
563 subprocesses.append((c_str, p1, p2, call_out, contig))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
564 # make sure our newly launched call does not block
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
565 # because its buffers fill up
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
566 p1.stdout.close()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
567 t1 = Thread(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
568 target=enqueue_stderr_output,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
569 args=(p1.stderr, error_table[c_str][0])
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
570 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
571 t2 = Thread(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
572 target=enqueue_stderr_output,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
573 args=(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
574 p2.stderr
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
575 if self.requires_stdout_redirect else
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
576 p2.stdout,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
577 error_table[c_str][1]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
578 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
579 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
580 t1.daemon = t2.daemon = True
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
581 t1.start()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
582 t2.start()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
583
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
584 if verbose:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
585 print(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
586 'Calling variants for contig: {0}'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
587 .format(call[2])
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
588 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
589
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
590 # monitor all running calls to see if any of them are done
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
591 for call, p1, p2, ofo, contig in subprocesses:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
592 p1_stat = p1.poll()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
593 p2_stat = p2.poll()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
594 if p1_stat is not None or p2_stat is not None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
595 # There is an outcome for this process!
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
596 # Lets see what it is
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
597 if p1_stat or p2_stat:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
598 print()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
599 print(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
600 error_table[call][0].getvalue(),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
601 error_table[call][1].getvalue(),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
602 file=sys.stderr
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
603 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
604 raise VariantCallingError(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
605 'Variant Calling for contig {0} failed.'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
606 .format(contig),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
607 call='{0} | {1}'.format(call[0], call[1])
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
608 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
609 if p1_stat == 0 and p2_stat is None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
610 # VarScan is not handling the no output from
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
611 # samtools mpileup situation correctly so maybe
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
612 # that's the issue here
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
613 last_words = error_table[call][1].getvalue(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
614 ).splitlines()[-4:]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
615 if len(last_words) < 4 or any(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
616 not msg.startswith('Input stream not ready')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
617 for msg in last_words
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
618 ):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
619 break
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
620 # lets give this process a bit more time
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
621 # VarScan is waiting for input it will never
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
622 # get, stop it.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
623 p2.terminate()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
624 subprocesses.remove((call, p1, p2, ofo, contig))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
625 ofo.close()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
626 break
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
627 if p2_stat == 0:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
628 # Things went fine.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
629 # maintain a list of variant call outputs
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
630 # that finished successfully (in the order
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
631 # they finished)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
632 tmp_io_finished.append(ofo.name)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
633 if verbose:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
634 print()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
635 print('Contig {0} finished.'.format(contig))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
636 if not quiet:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
637 print()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
638 print(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
639 'stderr output from samtools mpileup/'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
640 'bcftools:'.upper(),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
641 file=sys.stderr
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
642 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
643 print(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
644 error_table[call][0].getvalue(),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
645 error_table[call][1].getvalue(),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
646 file=sys.stderr
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
647 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
648 # Discard the collected stderr output from
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
649 # the call, remove the call from the list of
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
650 # running calls and close its output file.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
651 del error_table[call]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
652 subprocesses.remove((call, p1, p2, ofo, contig))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
653 # Closing the output file is important or we
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
654 # may hit the file system limit for open files
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
655 # if there are lots of contigs.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
656 ofo.close()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
657 break
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
658 # wait a bit in between monitoring cycles
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
659 time.sleep(2)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
660 finally:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
661 for call, p1, p2, ofo, contig in subprocesses:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
662 # make sure we do not leave running subprocesses behind
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
663 for proc in (p1, p2):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
664 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
665 proc.terminate()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
666 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
667 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
668 # close currently open files
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
669 ofo.close()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
670 # store the files with finished content in the order that
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
671 # the corresponding jobs were launched
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
672 self.tmpfiles = [f for f in tmp_io_started if f in tmp_io_finished]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
673 # Make sure remaining buffered stderr output of
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
674 # subprocesses does not get lost.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
675 # Currently, we don't screen this output for real errors,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
676 # but simply rewrite everything.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
677 if not quiet and error_table:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
678 print()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
679 print(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
680 'stderr output from samtools mpileup/bcftools:'.upper(),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
681 file=sys.stderr
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
682 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
683 for call, errors in error_table.items():
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
684 print(' | '.join(call), ':', file=sys.stderr)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
685 print('-' * 20, file=sys.stderr)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
686 print('samtools mpileup output:', file=sys.stderr)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
687 print(errors[0].getvalue(), file=sys.stderr)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
688 print('varscan somatic output:', file=sys.stderr)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
689 print(errors[1].getvalue(), file=sys.stderr)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
690
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
691 def _add_ref_contigs_to_header(self, header):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
692 for chrom, length in zip(self.ref_contigs, self.ref_lengths):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
693 header.add_meta(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
694 'contig',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
695 items=[('ID', chrom), ('length', length)]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
696 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
697
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
698 def _add_filters_to_header(self, header):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
699 varscan_fpfilters = {
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
700 'VarCount': 'Fewer than {min_var_count2} variant-supporting reads',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
701 'VarFreq': 'Variant allele frequency below {min_var_freq2}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
702 'VarAvgRL':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
703 'Average clipped length of variant-supporting reads < '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
704 '{min_var_len}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
705 'VarReadPos': 'Relative average read position < {min_var_readpos}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
706 'VarDist3':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
707 'Average distance to effective 3\' end < {min_var_dist3}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
708 'VarMMQS':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
709 'Average mismatch quality sum for variant reads > '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
710 '{max_var_mmqs}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
711 'VarMapQual':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
712 'Average mapping quality of variant reads < {min_var_mapqual}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
713 'VarBaseQual':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
714 'Average base quality of variant reads < {min_var_basequal}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
715 'Strand':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
716 'Strand representation of variant reads < {min_strandedness}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
717 'RefAvgRL':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
718 'Average clipped length of ref-supporting reads < '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
719 '{min_ref_len}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
720 'RefReadPos':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
721 'Relative average read position < {min_ref_readpos}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
722 'RefDist3':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
723 'Average distance to effective 3\' end < {min_ref_dist3}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
724 'RefMapQual':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
725 'Average mapping quality of reference reads < '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
726 '{min_ref_mapqual}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
727 'RefBaseQual':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
728 'Average base quality of ref-supporting reads < '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
729 '{min_ref_basequal}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
730 'RefMMQS':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
731 'Average mismatch quality sum for ref-supporting reads > '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
732 '{max_ref_mmqs}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
733 'MMQSdiff':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
734 'Mismatch quality sum difference (var - ref) > '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
735 '{max_mmqs_diff}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
736 'MinMMQSdiff':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
737 'Mismatch quality sum difference (var - ref) < '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
738 '{max_mmqs_diff}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
739 'MapQualDiff':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
740 'Mapping quality difference (ref - var) > {max_mapqual_diff}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
741 'MaxBAQdiff':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
742 'Average base quality difference (ref - var) > '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
743 '{max_basequal_diff}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
744 'ReadLenDiff':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
745 'Average supporting read length difference (ref - var) > '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
746 '{max_relative_len_diff}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
747 }
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
748 for filter_id, description in varscan_fpfilters.items():
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
749 header.filters.add(filter_id, None, None, description)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
750
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
751 def _add_indel_info_flag_to_header(self, header):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
752 header.info.add(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
753 'INDEL', 0, 'Flag', 'Indicates that the variant is an INDEL'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
754 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
755
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
756 def _standardize_format_fields(self, header):
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
757 """Add standard FORMAT key declarations to a VCF header."""
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
758
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
759 format_field_specs = [
8
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
760 # pysam will not add quotes around single-word descriptions,
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
761 # which is a violation of the VCF specification.
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
762 # To work around this we are using two words as the
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
763 # GT format description (instead of the commonly used "Genotype").
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
764 # This could be changed once pysam learns to quote correctly.
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
765 ('GT', '1', 'String', 'Genotype code'),
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
766 ('GQ', '1', 'Integer', 'Genotype quality'),
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
767 ('DP', '1', 'Integer', 'Read depth'),
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
768 ('AD', 'R', 'Integer', 'Read depth for each allele'),
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
769 ('ADF', 'R', 'Integer',
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
770 'Read depth for each allele on the forward strand'),
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
771 ('ADR', 'R', 'Integer',
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
772 'Read depth for each allele on the reverse strand')
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
773 ]
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
774 # Existing FORMAT declarations cannot be overwritten.
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
775 # The only viable strategy is to mark them as removed,
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
776 # then merge the header with another one containing the
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
777 # correct declarations. This is what is implemented below.
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
778 temp_header = pysam.VariantHeader()
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
779 for spec in format_field_specs:
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
780 temp_header.formats.add(*spec)
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
781 if spec[0] in header.formats:
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
782 header.formats.remove_header(spec[0])
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
783 header.merge(temp_header)
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
784
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
785 def _compile_common_header(self, varcall_template, no_filters=False):
8
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
786 # read the header produced by VarScan for use as a template
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
787 with pysam.VariantFile(varcall_template, 'r') as original_data:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
788 varscan_header = original_data.header
7
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
789 # don't propagate non-standard and redundant FORMAT keys written
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
790 # by VarScan
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
791 varscan_header.formats.remove_header('AD')
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
792 varscan_header.formats.remove_header('FREQ')
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
793 varscan_header.formats.remove_header('RD')
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
794 varscan_header.formats.remove_header('DP4')
8
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
795 # build a new header containing information not written by VarScan
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
796 common_header = pysam.VariantHeader()
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
797 # copy over sample info from the VarScan template
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
798 for sample in varscan_header.samples:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
799 common_header.samples.add(sample)
8
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
800 # add reference information
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
801 common_header.add_meta('reference', value=self.ref_genome)
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
802 # change the source information
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
803 common_header.add_meta('source', value='varscan.py')
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
804 # add contig information
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
805 self._add_ref_contigs_to_header(common_header)
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
806 # declare an INDEL flag for record INFO fields
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
807 self._add_indel_info_flag_to_header(common_header)
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
808 # merge in remaining information from the VarScan template
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
809 common_header.merge(varscan_header)
8
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
810 # add additional FILTER declarations
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
811 if not no_filters:
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
812 # add filter info
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
813 self._add_filters_to_header(common_header)
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
814 # generate standard FORMAT field declarations
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
815 # including a correct AD declaration to prevent VarScan's
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
816 # non-standard one from getting propagated
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
817 self._standardize_format_fields(common_header)
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
818 return common_header
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
819
7
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
820 def _fix_record_gt_fields(self, record):
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
821 """Migrate non-standard genotype fields to standard ones."""
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
822
7
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
823 # The key issue to consider here is that we need to modify
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
824 # genotype field values on a per-sample basis, but htslib
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
825 # reserves memory for the values of all samples upon the first
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
826 # modification of the field in the variant record.
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
827 # => We need to calculate all values first, then fill each
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
828 # genotype field starting with the sample with the largest value.
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
829 new_gt_fields = {'AD': [], 'ADF': [], 'ADR': []}
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
830 # store the current genotype field contents for each sample
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
831 per_sample_gts = record.samples.values()
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
832 # calculate and store the new genotype field values
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
833 for gt_field in per_sample_gts:
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
834 # generate a standard AD field by combining VarScan's
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
835 # RD and non-standard AD fields
7
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
836 new_gt_fields['AD'].append((gt_field['RD'], gt_field['AD'][0]))
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
837 # split VarScan's DP4 field into the standard fields
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
838 # ADF and ADR
7
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
839 new_gt_fields['ADF'].append(
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
840 (int(gt_field['DP4'][0]), int(gt_field['DP4'][2]))
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
841 )
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
842 new_gt_fields['ADR'].append(
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
843 (int(gt_field['DP4'][1]), int(gt_field['DP4'][3]))
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
844 )
7
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
845 # Modify the record's genotype fields.
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
846 # For each field, modify the sample containing the largest
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
847 # value for the field first.
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
848 # Without this precaution we could trigger:
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
849 # "bcf_update_format: Assertion `!fmt->p_free' failed."
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
850 # in vcf.c of htslib resulting in a core dump.
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
851 for field in sorted(new_gt_fields):
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
852 for new_field, sample_fields in sorted(
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
853 zip(new_gt_fields[field], per_sample_gts),
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
854 key=lambda x: max(x[0]),
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
855 reverse=True
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
856 ):
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
857 sample_fields[field] = new_field
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
858 # remove redundant fields
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
859 # FREQ is easy to calculate from AD
7
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
860 del record.format['FREQ']
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
861 del record.format['RD']
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
862 del record.format['DP4']
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
863
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
864 def _postprocess_variant_records(self, invcf,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
865 min_var_count2, min_var_count2_lc,
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
866 min_var_freq2, min_var_count2_depth,
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
867 min_ref_readpos, min_var_readpos,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
868 min_ref_dist3, min_var_dist3,
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
869 detect_q2_runs,
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
870 min_ref_len, min_var_len,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
871 max_relative_len_diff,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
872 min_strandedness, min_strand_reads,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
873 min_ref_basequal, min_var_basequal,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
874 max_basequal_diff,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
875 min_ref_mapqual, min_var_mapqual,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
876 max_mapqual_diff,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
877 max_ref_mmqs, max_var_mmqs,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
878 min_mmqs_diff, max_mmqs_diff,
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
879 ignore_md,
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
880 **args):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
881 # set FILTER field according to Varscan criteria
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
882 # multiple FILTER entries must be separated by semicolons
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
883 # No filters applied should be indicated with MISSING
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
884
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
885 # since posterior filters are always applied to just one sample,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
886 # a better place to store the info is in the FT genotype field:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
887 # can be PASS, '.' to indicate that filters have not been applied,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
888 # or a semicolon-separated list of filters that failed
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
889 # unfortunately, gemini does not support this field
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
890
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
891 with ExitStack() as io_stack:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
892 normal_reads, tumor_reads = (
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
893 io_stack.enter_context(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
894 pysam.Samfile(fn, 'rb')) for fn in self.bam_input_files
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
895 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
896 refseq = io_stack.enter_context(pysam.FastaFile(self.ref_genome))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
897 pileup_args = self._get_pysam_pileup_args()
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
898 _get_stats = get_allele_stats
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
899 for record in invcf:
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
900 is_indel = False
8
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
901 if record.alleles[0] == 'N':
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
902 # It makes no sense to call SNPs against an unknown
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
903 # reference base
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
904 continue
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
905 if len(record.alleles[0]) > 1:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
906 # a deletion
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
907 is_indel = True
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
908 alleles = [
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
909 record.alleles[1], record.alleles[0].replace(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
910 record.alleles[1], record.alleles[1] + '-', 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
911 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
912 ]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
913 elif len(record.alleles[1]) > 1:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
914 # an insertion
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
915 is_indel = True
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
916 alleles = [
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
917 record.alleles[0],
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
918 record.alleles[1].replace(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
919 record.alleles[0], record.alleles[0] + '+', 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
920 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
921 ]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
922 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
923 # a regular SNV
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
924 alleles = record.alleles[:2]
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
925 # get pileup for genomic region affected by this variant
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
926 if record.info['SS'] == '2':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
927 # a somatic variant => generate pileup from tumor data
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
928 reads_of_interest = tumor_reads
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
929 calculate_ref_stats = record.samples['TUMOR']['RD'] > 0
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
930 elif record.info['SS'] in ['1', '3']:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
931 # a germline or LOH variant => pileup from normal data
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
932 reads_of_interest = normal_reads
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
933 calculate_ref_stats = record.samples['NORMAL']['RD'] > 0
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
934 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
935 # TO DO: figure out if there is anything interesting to do
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
936 # for SS status codes 0 (reference) and 5 (unknown)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
937 yield record
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
938 continue
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
939
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
940 # no multiallelic sites in varscan
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
941 assert len(record.alleles) == 2
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
942
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
943 if calculate_ref_stats:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
944 ref_stats, alt_stats = _get_stats(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
945 reads_of_interest,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
946 (record.chrom, record.start, record.stop),
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
947 alleles,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
948 refseq,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
949 ignore_md=ignore_md,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
950 ignore_nm=False,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
951 mm_runs=True,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
952 detect_q2_runs=detect_q2_runs,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
953 pileup_args=pileup_args
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
954 )
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
955 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
956 ref_stats = None
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
957 alt_stats = _get_stats(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
958 reads_of_interest,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
959 (record.chrom, record.start, record.stop),
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
960 alleles[1:2],
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
961 refseq,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
962 ignore_md=ignore_md,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
963 ignore_nm=False,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
964 mm_runs=True,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
965 detect_q2_runs=detect_q2_runs,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
966 pileup_args=pileup_args
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
967 )[0]
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
968 ref_count = 0
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
969 if ref_stats:
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
970 ref_count = ref_stats.reads_fw + ref_stats.reads_rv
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
971 if ref_stats.avg_basequal < min_ref_basequal:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
972 record.filter.add('RefBaseQual')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
973 if ref_count >= 2:
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
974 if ref_stats.avg_mapqual < min_ref_mapqual:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
975 record.filter.add('RefMapQual')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
976 if ref_stats.avg_dist_from_center < min_ref_readpos:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
977 record.filter.add('RefReadPos')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
978 # ref_stats.avg_mismatch_fraction
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
979 # is not a filter criterion in VarScan fpfilter
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
980 if ref_stats.avg_mismatch_qualsum > max_ref_mmqs:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
981 record.filter.add('RefMMQS')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
982 if not is_indel and (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
983 ref_stats.avg_clipped_len < min_ref_len
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
984 ):
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
985 # VarScan fpfilter does not apply this filter
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
986 # for indels, so we do not do it either.
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
987 record.filter.add('RefAvgRL')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
988 if ref_stats.avg_dist_from_3prime < min_ref_dist3:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
989 record.filter.add('RefDist3')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
990 if alt_stats:
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
991 alt_count = alt_stats.reads_fw + alt_stats.reads_rv
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
992 if alt_count < min_var_count2:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
993 if (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
994 (alt_count + ref_count) >= min_var_count2_depth
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
995 ) or (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
996 alt_count < min_var_count2_lc
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
997 ):
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
998 record.filter.add('VarCount')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
999 if alt_count / alt_stats.reads_total < min_var_freq2:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1000 record.filter.add('VarFreq')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1001 if not is_indel and (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1002 alt_stats.avg_basequal < min_var_basequal
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1003 ):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1004 record.filter.add('VarBaseQual')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1005 if alt_count >= min_strand_reads:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1006 if (
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1007 alt_stats.reads_fw / alt_count < min_strandedness
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1008 ) or (
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1009 alt_stats.reads_rv / alt_count < min_strandedness
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1010 ):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1011 record.filter.add('Strand')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1012 if alt_count >= 2:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1013 if alt_stats.avg_mapqual < min_var_mapqual:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1014 record.filter.add('VarMapQual')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1015 if alt_stats.avg_dist_from_center < min_var_readpos:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1016 record.filter.add('VarReadPos')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1017 # alt_stats.avg_mismatch_fraction
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1018 # is not a filter criterion in VarScan fpfilter
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1019 if alt_stats.avg_mismatch_qualsum > max_var_mmqs:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1020 record.filter.add('VarMMQS')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1021 if not is_indel and (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1022 alt_stats.avg_clipped_len < min_var_len
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1023 ):
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1024 # VarScan fpfilter does not apply this filter
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1025 # for indels, so we do not do it either.
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1026 record.filter.add('VarAvgRL')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1027 if alt_stats.avg_dist_from_3prime < min_var_dist3:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1028 record.filter.add('VarDist3')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1029 if ref_count >= 2 and alt_count >= 2:
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1030 if (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1031 ref_stats.avg_mapqual - alt_stats.avg_mapqual
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1032 ) > max_mapqual_diff:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1033 record.filter.add('MapQualDiff')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1034 if (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1035 ref_stats.avg_basequal - alt_stats.avg_basequal
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1036 ) > max_basequal_diff:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1037 record.filter.add('MaxBAQdiff')
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1038 mmqs_diff = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1039 alt_stats.avg_mismatch_qualsum
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1040 - ref_stats.avg_mismatch_qualsum
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1041 )
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1042 if mmqs_diff < min_mmqs_diff:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1043 record.filter.add('MinMMQSdiff')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1044 if mmqs_diff > max_mmqs_diff:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1045 record.filter.add('MMQSdiff')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1046 if (
10
db94eadb92c1 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 1232893782204bb041dd6ed46711295cb0bfc03f"
iuc
parents: 9
diff changeset
1047 1
db94eadb92c1 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 1232893782204bb041dd6ed46711295cb0bfc03f"
iuc
parents: 9
diff changeset
1048 - alt_stats.avg_clipped_len
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1049 / ref_stats.avg_clipped_len
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1050 ) > max_relative_len_diff:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1051 record.filter.add('ReadLenDiff')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1052 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1053 # No variant-supporting reads for this record!
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1054 # This can happen in rare cases because of
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1055 # samtools mpileup issues, but indicates a
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1056 # rather unreliable variant call.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1057 record.filter.add('VarCount')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1058 record.filter.add('VarFreq')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1059 yield record
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1060
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1061 def _indel_flagged_records(self, vcf):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1062 for record in vcf:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1063 record.info['INDEL'] = True
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1064 yield record
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1065
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1066 def _merge_generator(self, vcf1, vcf2):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1067 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1068 record1 = next(vcf1)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1069 except StopIteration:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1070 for record2 in vcf2:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1071 yield record2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1072 return
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1073 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1074 record2 = next(vcf2)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1075 except StopIteration:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1076 yield record1
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1077 for record1 in vcf1:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1078 yield record1
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1079 return
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1080 while True:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1081 if (record1.start, record1.stop) < (record2.start, record2.stop):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1082 yield record1
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1083 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1084 record1 = next(vcf1)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1085 except StopIteration:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1086 yield record2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1087 for record2 in vcf2:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1088 yield record2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1089 return
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1090 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1091 yield record2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1092 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1093 record2 = next(vcf2)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1094 except StopIteration:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1095 yield record1
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1096 for record1 in vcf1:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1097 yield record1
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1098 return
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1099
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1100 def merge_and_postprocess(self, snps_out, indels_out=None,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1101 no_filters=False, **filter_args):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1102 temporary_data = self.tmpfiles
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1103 self.tmpfiles = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1104 temporary_snp_files = [f + '.snp.vcf' for f in temporary_data]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1105 temporary_indel_files = [f + '.indel.vcf' for f in temporary_data]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1106
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1107 for f in temporary_data:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1108 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1109 os.remove(f)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1110 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1111 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1112
8
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
1113 def filter_minimal(data, **kwargs):
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
1114 for record in data:
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
1115 if record.alleles[0] != 'N' or len(record.alleles[1]) > 1:
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
1116 # Yield everything except SNPs called against an unknown
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
1117 # reference base
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
1118 yield record
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1119
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1120 if no_filters:
8
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
1121 apply_filters = filter_minimal
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1122 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1123 apply_filters = self._postprocess_variant_records
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1124
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1125 output_header = self._compile_common_header(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1126 temporary_snp_files[0],
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1127 no_filters
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1128 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1129 if indels_out is None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1130 with open(snps_out, 'w') as o:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1131 o.write(str(output_header).format(**filter_args))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1132 for snp_f, indel_f in zip(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1133 temporary_snp_files, temporary_indel_files
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1134 ):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1135 with pysam.VariantFile(snp_f, 'r') as snp_invcf:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1136 # fix the input header on the fly
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1137 # to avoid Warnings from htslib about missing contig
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1138 # info
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1139 self._add_ref_contigs_to_header(snp_invcf.header)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1140 self._add_filters_to_header(snp_invcf.header)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1141 self._add_indel_info_flag_to_header(snp_invcf.header)
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
1142 self._standardize_format_fields(snp_invcf.header)
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1143 with pysam.VariantFile(indel_f, 'r') as indel_invcf:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1144 # fix the input header on the fly
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1145 # to avoid Warnings from htslib about missing
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1146 # contig info
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1147 self._add_ref_contigs_to_header(indel_invcf.header)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1148 self._add_filters_to_header(indel_invcf.header)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1149 self._add_indel_info_flag_to_header(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1150 indel_invcf.header
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1151 )
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
1152 self._standardize_format_fields(indel_invcf.header)
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1153 for record in apply_filters(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1154 self._merge_generator(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1155 snp_invcf,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1156 self._indel_flagged_records(indel_invcf)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1157 ),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1158 **filter_args
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1159 ):
7
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
1160 self._fix_record_gt_fields(record)
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1161 o.write(str(record))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1162 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1163 os.remove(snp_f)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1164 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1165 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1166 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1167 os.remove(indel_f)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1168 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1169 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1170
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1171 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1172 with open(snps_out, 'w') as o:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1173 o.write(str(output_header).format(**filter_args))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1174 for f in temporary_snp_files:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1175 with pysam.VariantFile(f, 'r') as invcf:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1176 # fix the input header on the fly
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1177 # to avoid Warnings from htslib about missing
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1178 # contig info and errors because of undeclared
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1179 # filters
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1180 self._add_ref_contigs_to_header(invcf.header)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1181 self._add_filters_to_header(invcf.header)
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
1182 self._standardize_format_fields(invcf.header)
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1183 for record in apply_filters(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1184 invcf, **filter_args
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1185 ):
7
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
1186 self._fix_record_gt_fields(record)
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1187 o.write(str(record))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1188 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1189 os.remove(f)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1190 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1191 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1192 with open(indels_out, 'w') as o:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1193 o.write(str(output_header))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1194 for f in temporary_indel_files:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1195 with pysam.VariantFile(f, 'r') as invcf:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1196 # fix the input header on the fly
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1197 # to avoid Warnings from htslib about missing
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1198 # contig info and errors because of undeclared
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1199 # filters
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1200 self._add_ref_contigs_to_header(invcf.header)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1201 self._add_filters_to_header(invcf.header)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1202 self._add_indel_info_flag_to_header(invcf.header)
6
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
1203 self._standardize_format_fields(invcf.header)
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1204 for record in apply_filters(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1205 self._indel_flagged_records(invcf), **filter_args
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1206 ):
7
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
1207 self._fix_record_gt_fields(record)
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1208 o.write(str(record))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1209 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1210 os.remove(f)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1211 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1212 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1213
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1214
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1215 def varscan_call(ref_genome, normal, tumor, output_path, **args):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1216 """Preparse arguments and orchestrate calling and postprocessing."""
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1217
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1218 if args.pop('split_output'):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1219 if '%T' in output_path:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1220 out = (
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1221 output_path.replace('%T', 'snp'),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1222 output_path.replace('%T', 'indel')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1223 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1224 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1225 out = (
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1226 output_path + '.snp',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1227 output_path + '.indel'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1228 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1229 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1230 out = (output_path, None)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1231
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1232 instance_args = {
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1233 k: args.pop(k) for k in [
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1234 'max_depth',
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1235 'count_orphans',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1236 'detect_overlaps',
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1237 'min_mapqual',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1238 'min_basequal',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1239 'threads',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1240 'verbose',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1241 'quiet'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1242 ]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1243 }
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1244 varscan_somatic_args = {
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1245 k: args.pop(k) for k in [
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1246 'normal_purity',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1247 'tumor_purity',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1248 'min_coverage',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1249 'min_var_count',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1250 'min_var_freq',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1251 'min_hom_freq',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1252 'somatic_p_value',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1253 'p_value'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1254 ]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1255 }
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1256
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1257 v = VarScanCaller(ref_genome, [normal, tumor], **instance_args)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1258 v.varcall_parallel(**varscan_somatic_args)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1259 v.merge_and_postprocess(*out, **args)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1260
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1261
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1262 if __name__ == '__main__':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1263 p = argparse.ArgumentParser()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1264 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1265 'ref_genome',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1266 metavar='reference_genome',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1267 help='the reference genome (in fasta format)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1268 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1269 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1270 '--normal',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1271 metavar='BAM_file', required=True,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1272 help='the BAM input file of aligned reads from the normal sample'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1273 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1274 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1275 '--tumor',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1276 metavar='BAM_file', required=True,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1277 help='the BAM input file of aligned reads from the tumor sample'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1278 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1279 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1280 '-o', '--ofile', required=True,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1281 metavar='OFILE', dest='output_path',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1282 help='Name of the variant output file. With --split-output, the name '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1283 'may use the %%T replacement token or will be used as the '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1284 'basename for the two output files to be generated (see '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1285 '-s|--split-output below).'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1286 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1287 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1288 '-s', '--split-output',
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1289 dest='split_output', action='store_true',
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1290 help='indicate that separate output files for SNPs and indels '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1291 'should be generated (original VarScan behavior). If specified, '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1292 '%%T in the --ofile file name will be replaced with "snp" and '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1293 '"indel" to generate the names of the SNP and indel output '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1294 'files, respectively. If %%T is not found in the file name, it '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1295 'will get interpreted as a basename to which ".snp"/".indel" '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1296 'will be appended.'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1297 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1298 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1299 '-t', '--threads',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1300 type=int, default=1,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1301 help='level of parallelism'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1302 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1303 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1304 '-v', '--verbose',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1305 action='store_true',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1306 help='be verbose about progress'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1307 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1308 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1309 '-q', '--quiet',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1310 action='store_true',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1311 help='suppress output from wrapped tools'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1312 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1313 call_group = p.add_argument_group('Variant calling parameters')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1314 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1315 '--normal-purity',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1316 dest='normal_purity', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1317 default=1.0,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1318 help='Estimated purity of the normal sample (default: 1.0)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1319 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1320 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1321 '--tumor-purity',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1322 dest='tumor_purity', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1323 default=1.0,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1324 help='Estimated purity of the tumor sample (default: 1.0)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1325 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1326 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1327 '--max-pileup-depth',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1328 dest='max_depth', type=int, default=8000,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1329 help='Maximum depth of generated pileups (samtools mpileup -d option; '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1330 'default: 8000)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1331 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1332 call_group.add_argument(
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1333 '--count-orphans',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1334 dest='count_orphans', action='store_true',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1335 help='Use anomalous read pairs in variant calling '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1336 '(samtools mpileup -A option; default: ignore anomalous pairs)'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1337 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1338 call_group.add_argument(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1339 '--no-detect-overlaps',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1340 dest='detect_overlaps', action='store_false',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1341 help='Disable automatic read-pair overlap detection by samtools '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1342 'mpileup. Overlap detection tries to avoid counting duplicated '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1343 'bases twice during variant calling. '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1344 '(samtools mpileup -x option; default: use overlap detection)'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1345 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1346 call_group.add_argument(
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1347 '--min-basequal',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1348 dest='min_basequal', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1349 default=13,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1350 help='Minimum base quality at the variant position to use a read '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1351 '(default: 13)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1352 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1353 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1354 '--min-mapqual',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1355 dest='min_mapqual', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1356 default=0,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1357 help='Minimum mapping quality required to use a read '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1358 '(default: 0)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1359 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1360 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1361 '--min-coverage',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1362 dest='min_coverage', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1363 default=8,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1364 help='Minimum site coverage required in the normal and in the tumor '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1365 'sample to call a variant (default: 8)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1366 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1367 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1368 '--min-var-count',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1369 dest='min_var_count', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1370 default=2,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1371 help='Minimum number of variant-supporting reads required to call a '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1372 'variant (default: 2)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1373 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1374 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1375 '--min-var-freq',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1376 dest='min_var_freq', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1377 default=0.1,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1378 help='Minimum variant allele frequency for calling (default: 0.1)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1379 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1380 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1381 '--min-hom-freq',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1382 dest='min_hom_freq', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1383 default=0.75,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1384 help='Minimum variant allele frequency for homozygous call '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1385 '(default: 0.75)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1386 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1387 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1388 '--p-value',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1389 dest='p_value', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1390 default=0.99,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1391 help='P-value threshold for heterozygous call (default: 0.99)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1392 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1393 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1394 '--somatic-p-value',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1395 dest='somatic_p_value', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1396 default=0.05,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1397 help='P-value threshold for somatic call (default: 0.05)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1398 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1399 filter_group = p.add_argument_group('Posterior variant filter parameters')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1400 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1401 '--no-filters',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1402 dest='no_filters', action='store_true',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1403 help='Disable all posterior variant filters. '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1404 'If specified, all following options will be ignored'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1405 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1406 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1407 '--min-var-count2',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1408 dest='min_var_count2', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1409 default=4,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1410 help='Minimum number of variant-supporting reads (default: 4)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1411 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1412 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1413 '--min-var-count2-lc',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1414 dest='min_var_count2_lc', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1415 default=2,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1416 help='Minimum number of variant-supporting reads when depth below '
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1417 '--min-var-count2-depth (default: 2)'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1418 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1419 filter_group.add_argument(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1420 '--min-var-count2-depth',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1421 dest='min_var_count2_depth', type=int,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1422 default=10,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1423 help='Combined depth of ref- and variant-supporting reads required to '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1424 'apply the --min-var-count filter instead of --min-var-count-lc '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1425 '(default: 10)'
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1426 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1427 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1428 '--min-var-freq2',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1429 dest='min_var_freq2', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1430 default=0.05,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1431 help='Minimum variant allele frequency (default: 0.05)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1432 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1433 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1434 '--min-ref-readpos',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1435 dest='min_ref_readpos', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1436 default=0.1,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1437 help='Minimum average relative distance of site from the ends of '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1438 'ref-supporting reads (default: 0.1)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1439 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1440 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1441 '--min-var-readpos',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1442 dest='min_var_readpos', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1443 default=0.1,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1444 help='Minimum average relative distance of site from the ends of '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1445 'variant-supporting reads (default: 0.1)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1446 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1447 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1448 '--min-ref-dist3',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1449 dest='min_ref_dist3', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1450 default=0.1,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1451 help='Minimum average relative distance of site from the effective '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1452 '3\'end of ref-supporting reads (default: 0.1)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1453 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1454 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1455 '--min-var-dist3',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1456 dest='min_var_dist3', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1457 default=0.1,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1458 help='Minimum average relative distance of site from the effective '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1459 '3\'end of variant-supporting reads (default: 0.1)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1460 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1461 filter_group.add_argument(
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1462 '--detect-q2-runs',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1463 dest='detect_q2_runs', action='store_true',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1464 help='Look for 3\'-terminal q2 runs and take their lengths into '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1465 'account for determining the effective 3\'end of reads '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1466 '(default: off)'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1467 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1468 filter_group.add_argument(
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1469 '--min-ref-len',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1470 dest='min_ref_len', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1471 default=90,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1472 help='Minimum average trimmed length of reads supporting the ref '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1473 'allele (default: 90)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1474 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1475 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1476 '--min-var-len',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1477 dest='min_var_len', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1478 default=90,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1479 help='Minimum average trimmed length of reads supporting the variant '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1480 'allele (default: 90)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1481 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1482 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1483 '--max-len-diff',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1484 dest='max_relative_len_diff', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1485 default=0.25,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1486 help='Maximum average relative read length difference (ref - var; '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1487 'default: 0.25)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1488 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1489 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1490 '--min-strandedness',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1491 dest='min_strandedness', type=float,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1492 default=0.01,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1493 help='Minimum fraction of variant reads from each strand '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1494 '(default: 0.01)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1495 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1496 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1497 '--min-strand-reads',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1498 dest='min_strand_reads', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1499 default=5,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1500 help='Minimum allele depth required to run --min-strandedness filter '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1501 '(default: 5)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1502 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1503 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1504 '--min-ref-basequal',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1505 dest='min_ref_basequal', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1506 default=15,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1507 help='Minimum average base quality for the ref allele (default: 15)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1508 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1509 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1510 '--min-var-basequal',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1511 dest='min_var_basequal', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1512 default=15,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1513 help='Minimum average base quality for the variant allele '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1514 '(default: 15)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1515 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1516 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1517 '--max-basequal-diff',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1518 dest='max_basequal_diff', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1519 default=50,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1520 help='Maximum average base quality diff (ref - var; default: 50)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1521 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1522 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1523 '--min-ref-mapqual',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1524 dest='min_ref_mapqual', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1525 default=15,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1526 help='Minimum average mapping quality of reads supporting the ref '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1527 'allele (default: 15)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1528 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1529 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1530 '--min-var-mapqual',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1531 dest='min_var_mapqual', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1532 default=15,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1533 help='Minimum average mapping quality of reads supporting the variant '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1534 'allele (default: 15)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1535 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1536 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1537 '--max-mapqual-diff',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1538 dest='max_mapqual_diff', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1539 default=50,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1540 help='Maximum average mapping quality difference (ref - var; '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1541 'default: 50)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1542 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1543 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1544 '--max-ref-mmqs',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1545 dest='max_ref_mmqs', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1546 default=100,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1547 help='Maximum mismatch quality sum of reads supporting the ref '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1548 'allele (default: 100)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1549 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1550 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1551 '--max-var-mmqs',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1552 dest='max_var_mmqs', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1553 default=100,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1554 help='Maximum mismatch quality sum of reads supporting the variant '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1555 'allele (default: 100)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1556 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1557 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1558 '--min-mmqs-diff',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1559 dest='min_mmqs_diff', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1560 default=0,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1561 help='Minimum mismatch quality sum difference (var - ref; default: 0)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1562 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1563 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1564 '--max-mmqs-diff',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1565 dest='max_mmqs_diff', type=int,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1566 default=50,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1567 help='Maximum mismatch quality sum difference (var - ref; default: 50)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1568 )
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1569 filter_group.add_argument(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1570 '--ignore-md',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1571 dest='ignore_md', action='store_true',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1572 help='Do not rely on read MD tag, even if it is present on the mapped '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1573 'reads, and recalculate mismatch quality stats from ref '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1574 'alignments instead.'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1575 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1576
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1577 args = vars(p.parse_args())
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1578 varscan_call(**args)