annotate varscan.py @ 9:4e97191a1ff7 draft

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