annotate varscan.py @ 9:e3f170cc4f95 draft

"planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
author iuc
date Fri, 16 Aug 2019 15:50:25 -0400
parents 45288fb1f3f5
children db94eadb92c1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1 #!/usr/bin/env python3
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
2 from __future__ import print_function
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
3
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
4 import argparse
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
5 import io
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
6 import os
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
7 import subprocess
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
8 import sys
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
9 import tempfile
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
10 import time
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
11 from collections import namedtuple
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
12 from contextlib import ExitStack
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
13 from functools import partial
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
14 from threading import Thread
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
15
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
16 import pysam
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
17
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
18
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
19 AlleleStats = namedtuple(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
20 "AlleleStats",
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
21 [
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
22 'reads_total',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
23 'reads_fw',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
24 'reads_rv',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
25 'avg_mapqual',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
26 'avg_basequal',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
27 'avg_dist_from_center',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
28 'avg_mismatch_fraction',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
29 'avg_mismatch_qualsum',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
30 'avg_clipped_len',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
31 'avg_dist_from_3prime'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
32 ]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
33 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
34
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
35
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
36 def _get_allele_specific_pileup_column_stats(pileups, ref_fetch,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
37 ignore_md, ignore_nm,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
38 mm_runs, detect_q2_runs):
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
39 var_reads_plus = var_reads_minus = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
40 sum_mapping_qualities = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
41 sum_base_qualities = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
42 sum_dist_from_center = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
43 sum_dist_from_3prime = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
44 sum_clipped_length = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
45 sum_unclipped_length = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
46 sum_mismatch_fractions = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
47 sum_mismatch_qualities = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
48
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
49 for p in pileups:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
50 if p.alignment.is_reverse:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
51 var_reads_minus += 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
52 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
53 var_reads_plus += 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
54 sum_mapping_qualities += p.alignment.mapping_quality
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
55 sum_base_qualities += p.alignment.query_qualities[p.query_position]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
56 sum_clipped_length += p.alignment.query_alignment_length
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
57 unclipped_length = p.alignment.query_length
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
58 sum_unclipped_length += unclipped_length
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
59 # The following calculations are all in 1-based coordinates
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
60 # with respect to the physical 5'-end of the read sequence.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
61 if p.alignment.is_reverse:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
62 read_base_pos = unclipped_length - p.query_position
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
63 read_first_aln_pos = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
64 unclipped_length - p.alignment.query_alignment_end + 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
65 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
66 read_last_aln_pos = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
67 unclipped_length - p.alignment.query_alignment_start
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
68 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
69 qualities_3to5prime = p.alignment.query_alignment_qualities
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
70 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
71 read_base_pos = p.query_position + 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
72 read_first_aln_pos = p.alignment.query_alignment_start + 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
73 read_last_aln_pos = p.alignment.query_alignment_end
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
74 qualities_3to5prime = reversed(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
75 p.alignment.query_alignment_qualities
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
76 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
77
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
78 read_last_effective_aln_pos = read_last_aln_pos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
79 if detect_q2_runs:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
80 # Note: the original bam-readcount algorithm always takes
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
81 # terminal q2 runs into account when determining the
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
82 # effective 3'-ends of reads.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
83 # However, q2 runs have no special meaning since Illumina
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
84 # pipeline version 1.8 so detecting them is optional
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
85 # in this code.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
86 for qual in qualities_3to5prime:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
87 if qual != 2:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
88 break
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
89 read_last_effective_aln_pos -= 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
90
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
91 # Note: the original bam-readcount algorithm defines the
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
92 # read center as:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
93 # read_center = p.alignment.query_alignment_length / 2
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
94 # This is less accurate than the implementation here.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
95 read_center = (read_first_aln_pos + read_last_aln_pos) / 2
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
96 sum_dist_from_center += 1 - abs(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
97 read_base_pos - read_center
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
98 ) / (read_center - 1)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
99 # To calculate the distance of base positions from the 3'-ends
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
100 # of reads bam-readcount uses the formula:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
101 # sum_dist_from_3prime += abs(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
102 # read_last_effective_aln_pos - read_base_pos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
103 # ) / (unclipped_length - 1)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
104 # , which treats base positions on both sides of the effective
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
105 # 3'-end equally. Since this seems hard to justify, we cap
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
106 # the distance calculation at 0 for base positions past the
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
107 # effective 3'-end (which, in turn, should only be possible
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
108 # with detection of q2 runs).
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
109 if read_last_effective_aln_pos > read_base_pos:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
110 sum_dist_from_3prime += (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
111 read_last_effective_aln_pos - read_base_pos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
112 ) / (unclipped_length - 1)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
113
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
114 if sum_mismatch_fractions >= 0 or sum_mismatch_qualities >= 0:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
115 # sum_mismatch_fractions and sum_mismatch_qualities will be
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
116 # set to float('nan') if reference info (in form of an MD tag or
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
117 # an actual reference sequence) was not available for any previous
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
118 # read in the pileup.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
119 # In that case, there is no point to trying to calculate
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
120 # mismatch stats for other reads anymore.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
121
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
122 # The following mismatch calculations use this logic:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
123 # 1. For determining the edit distance between an aligned read and
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
124 # the reference, we follow the authoritative definition of the
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
125 # NM tag calculation in
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
126 # http://samtools.github.io/hts-specs/SAMtags.pdf
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
127 #
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
128 # For historical reasons, the result of this calculation will
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
129 # disagree more often than not with NM tag values calculated by
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
130 # other tools.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
131 # If precalculated NM tag values are present on the aligned
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
132 # reads, these can be given preference through the use_nm flag.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
133 # Doing so will mimick the behavior of bam-readcount, which
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
134 # requires and always just looks at NM tags.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
135 # 2. For determining mismatch quality sums, a mismatch is defined
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
136 # differently and in accordance with the implementation in
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
137 # bam-readcount:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
138 # - only mismatches (not inserted or deleted bases) are
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
139 # considered
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
140 # - 'N' in the reference is considered a match for any read base
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
141 # - any matching (case-insensitive) base in reference and read
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
142 # is considered a match, even if that base is not one of
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
143 # A, C, G or T.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
144 # In both 1. and 2. above a '=' in the read is always considered a
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
145 # match, irrespective of the reference base.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
146
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
147 num_mismatches = 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
148 if not ignore_md:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
149 try:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
150 # see if the read has an MD tag, in which case pysam can
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
151 # calculate the reference sequence for us
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
152 ref_seq = p.alignment.get_reference_sequence().upper()
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
153 except ValueError:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
154 ignore_md = True
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
155 if not ignore_nm:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
156 try:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
157 num_mismatches = p.alignment.get_tag('NM')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
158 except KeyError:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
159 ignore_nm = True
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
160
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
161 if ignore_md:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
162 if not ref_fetch:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
163 # cannot calculate mismatch stats without ref info
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
164 sum_mismatch_qualities = float('nan')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
165 if ignore_nm:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
166 sum_mismatch_fractions = float('nan')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
167 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
168 sum_mismatch_fractions += (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
169 num_mismatches / p.alignment.query_alignment_length
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
170 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
171 continue
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
172 # Without an MD tag we need to extract the relevant part
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
173 # of the reference from the full sequence by position.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
174 ref_positions = p.alignment.get_reference_positions()
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
175 ref_seq = ref_fetch(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
176 ref_positions[0], ref_positions[-1] + 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
177 ).upper()
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
178
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
179 potential_matches = {'A', 'C', 'G', 'T'}
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
180 aligned_pairs = p.alignment.get_aligned_pairs(matches_only=True)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
181 ref_offset = aligned_pairs[0][1]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
182 last_mismatch_pos = None
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
183 mismatch_run_quals = []
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
184 for qpos, rpos in aligned_pairs:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
185 read_base = p.alignment.query_sequence[qpos].upper()
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
186 if read_base == '=':
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
187 # always treat the special read base '=' as a
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
188 # match, irrespective of the reference base
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
189 continue
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
190 ref_base = ref_seq[rpos - ref_offset]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
191 # see if we have a mismatch to use for mismatch quality sum
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
192 # calculation
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
193 if ref_base != 'N' and ref_base != read_base:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
194 if mm_runs:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
195 if (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
196 last_mismatch_pos is None
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
197 ) or (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
198 last_mismatch_pos + 1 == qpos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
199 ):
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
200 mismatch_run_quals.append(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
201 p.alignment.query_qualities[qpos]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
202 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
203 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
204 sum_mismatch_qualities += max(mismatch_run_quals)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
205 mismatch_run_quals = [
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
206 p.alignment.query_qualities[qpos]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
207 ]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
208 last_mismatch_pos = qpos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
209 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
210 sum_mismatch_qualities += (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
211 p.alignment.query_qualities[qpos]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
212 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
213 if ignore_nm:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
214 # see if we have a mismatch that increases the edit
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
215 # distance according to the SAMtags specs
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
216 if (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
217 read_base not in potential_matches
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
218 ) or (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
219 ref_base not in potential_matches
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
220 ) or (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
221 read_base != ref_base
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
222 ):
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
223 num_mismatches += 1
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
224
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
225 if mismatch_run_quals:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
226 sum_mismatch_qualities += max(mismatch_run_quals)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
227 if ignore_nm:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
228 # use the number of mismatches calculated above,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
229 # but add inserted and deleted bases to it
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
230 cigar_stats = p.alignment.get_cigar_stats()[0]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
231 num_mismatches += cigar_stats[1] + cigar_stats[2]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
232 sum_mismatch_fractions += (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
233 num_mismatches / p.alignment.query_alignment_length
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
234 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
235
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
236 return (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
237 var_reads_plus,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
238 var_reads_minus,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
239 sum_mapping_qualities,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
240 sum_base_qualities,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
241 sum_dist_from_center,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
242 sum_mismatch_fractions,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
243 sum_mismatch_qualities,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
244 sum_clipped_length,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
245 sum_dist_from_3prime
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
246 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
247
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
248
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
249 def get_allele_stats(reads, pos, alleles,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
250 ref=None, ignore_md=True, ignore_nm=True,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
251 mm_runs=True, detect_q2_runs=False,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
252 pileup_args=None):
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
253 chrom, start, stop = pos
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
254 if pileup_args is None:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
255 pileup_args = {}
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
256 if pileup_args.get('stepper') == 'samtools':
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
257 if pileup_args.get('compute_baq', True) is not False:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
258 if 'fastafile' not in pileup_args:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
259 pileup_args['fastafile'] = ref
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
260 # be careful when passing in a custom 'fastafile' option:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
261 # providing it slows down pysam tremendously even if the option
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
262 # isn't actually required.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
263
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
264 pile = reads.pileup(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
265 chrom, start, stop,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
266 **pileup_args
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
267 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
268 # apply false-positive filtering a la varscan fpfilter
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
269 # find the variant site in the pileup columns
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
270 for pile_column in pile:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
271 if pile_column.reference_pos == start:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
272 break
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
273 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
274 # With no reads covering the genomic position
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
275 # we can only return "empty" allele stats
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
276 return [
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
277 AlleleStats(0, 0, 0, *[float('nan')] * 7)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
278 for allele in alleles
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
279 ]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
280
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
281 # extract required information
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
282 # overall read depth at the site
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
283 read_depth = pile_column.get_num_aligned()
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
284 assert read_depth > 0
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
285
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
286 alleles_stats = []
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
287 for allele in alleles:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
288 if '-' in allele:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
289 allele, indel_type, indel_after = allele.partition('-')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
290 indel_len = -len(indel_after)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
291 elif '+' in allele:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
292 allele, indel_type, indel_after = allele.partition('+')
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
293 indel_len = len(indel_after)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
294 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
295 indel_type = None
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
296
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
297 stats_it = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
298 p for p in pile_column.pileups
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
299 # skip reads that don't support the allele we're looking for
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
300 if (p.query_position is not None)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
301 and (p.alignment.query_sequence[p.query_position] == allele)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
302 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
303 if indel_type == '-':
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
304 stats_it = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
305 p for p in stats_it if p.indel == indel_len
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
306 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
307 elif indel_type == '+':
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
308 stats_it = (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
309 p for p in stats_it if (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
310 p.indel == indel_len
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
311 ) and (
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
312 p.alignment.query_sequence[
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
313 p.query_position + 1:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
314 p.query_position + 1 + indel_len
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
315 ] == indel_after
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
316 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
317 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
318 allele_stats = _get_allele_specific_pileup_column_stats(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
319 stats_it,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
320 partial(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
321 pysam.FastaFile.fetch, ref, chrom
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
322 ) if ref else None,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
323 ignore_md,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
324 ignore_nm,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
325 mm_runs,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
326 detect_q2_runs
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
327 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
328
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
329 allele_reads_total = allele_stats[0] + allele_stats[1]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
330 if allele_reads_total == 0:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
331 # No stats without reads!
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
332 alleles_stats.append(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
333 AlleleStats(read_depth, 0, 0, *[float('nan')] * 7)
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
334 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
335 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
336 alleles_stats.append(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
337 AlleleStats(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
338 read_depth, allele_stats[0], allele_stats[1],
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
339 *(i / allele_reads_total for i in allele_stats[2:])
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
340 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
341 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
342 return alleles_stats
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
343
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
344
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
345 class VariantCallingError (RuntimeError):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
346 """Exception class for issues with samtools and varscan subprocesses."""
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
347
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
348 def __init__(self, message=None, call='', error=''):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
349 self.message = message
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
350 self.call = call.strip()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
351 self.error = error.strip()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
352
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
353 def __str__(self):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
354 if self.message is None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
355 return ''
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
356 if self.error:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
357 msg_header = '"{0}" failed with:\n{1}\n\n'.format(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
358 self.call, self.error
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
359 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
360 else:
d062703d6f13 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'
d062703d6f13 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(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
363 self.call
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
364 )
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
366
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
367
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
368 class VarScanCaller (object):
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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,
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
373 ):
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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
e3f170cc4f95 "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
e3f170cc4f95 "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
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
381 self.threads = threads
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
382 self.verbose = verbose
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
383 self.quiet = quiet
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
384
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
388
d062703d6f13 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']
d062703d6f13 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']
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
392 self.TemporaryContigVCF = partial(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
393 tempfile.NamedTemporaryFile,
d062703d6f13 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()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
395 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
396 self.tmpfiles = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
397
d062703d6f13 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
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
400 # instance attributes.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
401
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
402 # fixed default parameters
e3f170cc4f95 "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':
e3f170cc4f95 "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
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
406 # dynamically like so:
e3f170cc4f95 "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:
e3f170cc4f95 "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
e3f170cc4f95 "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
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
411 # overlap (see
e3f170cc4f95 "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
e3f170cc4f95 "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
e3f170cc4f95 "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
e3f170cc4f95 "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.
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
416
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
417 param_dict = {
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
418 'ignore_overlaps': False,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
419 'compute_baq': False,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
420 'stepper': 'samtools',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
421 }
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
422 # user-controllable parameters
e3f170cc4f95 "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:
e3f170cc4f95 "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
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
431 return param_dict
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
432
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
434 min_coverage=None,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
435 min_var_count=None,
d062703d6f13 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,
d062703d6f13 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,
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
439 ):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
440 if not threads:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
441 threads = self.threads
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
442 if verbose is None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
443 verbose = self.verbose
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
444 if quiet is None:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
445 quiet = self.quiet
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
447 varcall_engine_option_mapping = [
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
448 ('--normal-purity', normal_purity),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
449 ('--tumor-purity', tumor_purity),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
450 ('--min-coverage', min_coverage),
d062703d6f13 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),
d062703d6f13 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),
d062703d6f13 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),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
454 ('--p-value', p_value),
d062703d6f13 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),
d062703d6f13 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)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
457 ]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
458 varcall_engine_options = []
d062703d6f13 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:
d062703d6f13 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:
d062703d6f13 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)]
d062703d6f13 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
e3f170cc4f95 "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:
e3f170cc4f95 "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']
e3f170cc4f95 "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:
e3f170cc4f95 "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
d062703d6f13 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:
d062703d6f13 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)]
d062703d6f13 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:
d062703d6f13 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)]
d062703d6f13 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:
d062703d6f13 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)]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
473
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
476 # that tuple.
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
479 calls = [(
d062703d6f13 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 + [
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
481 '-r', contig + ':',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
482 '-f', self.ref_genome
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
483 ] + self.bam_input_files,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
484 self.varcall_engine + [
d062703d6f13 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'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
486 ] + varcall_engine_options,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
487 contig
d062703d6f13 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]]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
489
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
490 if verbose:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
491 print('Starting variant calling ..')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
492
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
494 subprocesses = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
495 error_table = {}
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
496 tmp_io_started = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
497 tmp_io_finished = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
498 self.tmpfiles = []
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
499
d062703d6f13 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):
d062703d6f13 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''):
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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.
d062703d6f13 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.
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
507 'backslashreplace'))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
508 out.close()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
509
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
510 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
511 while subprocesses or calls:
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
516
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
518 call = calls.pop()
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
520 # to work on
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
521 contig = call[2]
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
525 # will be redirected.
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
529 call_out = self.TemporaryContigVCF(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
530 prefix=''.join(
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
532 ) + '_',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
533 )
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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)
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
539 stdout_p2 = call_out
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
540 stderr_p2 = subprocess.PIPE
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
541 else:
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
543 stdout_p2 = subprocess.PIPE
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
544 stderr_p2 = subprocess.STDOUT
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
546 call_out.close()
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
549 # strings
d062703d6f13 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]))
d062703d6f13 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()]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
552 # start the subprocesses
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
553 p1 = subprocess.Popen(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
554 call[0],
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
556 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
557 p2 = subprocess.Popen(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
558 call[1],
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
559 stdin=p1.stdout,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
560 stdout=stdout_p2,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
561 stderr=stderr_p2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
562 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
563 # subprocess bookkeeping
d062703d6f13 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))
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
567 p1.stdout.close()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
568 t1 = Thread(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
569 target=enqueue_stderr_output,
d062703d6f13 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])
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
571 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
572 t2 = Thread(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
573 target=enqueue_stderr_output,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
574 args=(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
575 p2.stderr
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
577 p2.stdout,
d062703d6f13 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]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
579 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
580 )
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
582 t1.start()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
583 t2.start()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
584
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
585 if verbose:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
586 print(
d062703d6f13 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}'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
588 .format(call[2])
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
589 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
590
d062703d6f13 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
d062703d6f13 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:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
593 p1_stat = p1.poll()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
594 p2_stat = p2.poll()
d062703d6f13 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:
d062703d6f13 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!
d062703d6f13 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
d062703d6f13 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:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
599 print()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
600 print(
d062703d6f13 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(),
d062703d6f13 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(),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
603 file=sys.stderr
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
604 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
605 raise VariantCallingError(
d062703d6f13 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.'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
607 .format(contig),
d062703d6f13 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])
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
609 )
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
615 ).splitlines()[-4:]
d062703d6f13 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(
d062703d6f13 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')
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
619 ):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
620 break
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
623 # get, stop it.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
624 p2.terminate()
d062703d6f13 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))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
626 ofo.close()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
627 break
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
628 if p2_stat == 0:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
629 # Things went fine.
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
632 # they finished)
d062703d6f13 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)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
634 if verbose:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
635 print()
d062703d6f13 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))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
637 if not quiet:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
638 print()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
639 print(
d062703d6f13 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/'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
641 'bcftools:'.upper(),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
642 file=sys.stderr
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
643 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
644 print(
d062703d6f13 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(),
d062703d6f13 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(),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
647 file=sys.stderr
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
648 )
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
652 del error_table[call]
d062703d6f13 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))
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
657 ofo.close()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
658 break
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
660 time.sleep(2)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
661 finally:
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 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):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
665 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
666 proc.terminate()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
667 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
668 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
669 # close currently open files
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
670 ofo.close()
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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]
d062703d6f13 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
d062703d6f13 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.
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
677 # but simply rewrite everything.
d062703d6f13 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:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
679 print()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
680 print(
d062703d6f13 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(),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
682 file=sys.stderr
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
683 )
d062703d6f13 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():
d062703d6f13 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)
d062703d6f13 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)
d062703d6f13 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)
d062703d6f13 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)
d062703d6f13 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)
d062703d6f13 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)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
691
d062703d6f13 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):
d062703d6f13 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):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
694 header.add_meta(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
695 'contig',
d062703d6f13 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)]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
697 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
698
d062703d6f13 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):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
700 varscan_fpfilters = {
d062703d6f13 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',
d062703d6f13 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}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
703 'VarAvgRL':
d062703d6f13 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 < '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
705 '{min_var_len}',
d062703d6f13 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}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
707 'VarDist3':
d062703d6f13 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}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
709 'VarMMQS':
d062703d6f13 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 > '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
711 '{max_var_mmqs}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
712 'VarMapQual':
d062703d6f13 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}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
714 'VarBaseQual':
d062703d6f13 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}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
716 'Strand':
d062703d6f13 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}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
718 'RefAvgRL':
d062703d6f13 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 < '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
720 '{min_ref_len}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
721 'RefReadPos':
d062703d6f13 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}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
723 'RefDist3':
d062703d6f13 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}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
725 'RefMapQual':
d062703d6f13 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 < '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
727 '{min_ref_mapqual}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
728 'RefBaseQual':
d062703d6f13 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 < '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
730 '{min_ref_basequal}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
731 'RefMMQS':
d062703d6f13 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 > '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
733 '{max_ref_mmqs}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
734 'MMQSdiff':
d062703d6f13 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) > '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
736 '{max_mmqs_diff}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
737 'MinMMQSdiff':
d062703d6f13 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) < '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
739 '{max_mmqs_diff}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
740 'MapQualDiff':
d062703d6f13 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}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
742 'MaxBAQdiff':
d062703d6f13 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) > '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
744 '{max_basequal_diff}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
745 'ReadLenDiff':
d062703d6f13 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) > '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
747 '{max_relative_len_diff}',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
748 }
d062703d6f13 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():
d062703d6f13 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)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
751
d062703d6f13 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):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
753 header.info.add(
d062703d6f13 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'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
755 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
756
6
ab2f908f0b08 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):
ab2f908f0b08 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."""
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
759
ab2f908f0b08 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
45288fb1f3f5 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,
45288fb1f3f5 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.
45288fb1f3f5 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
45288fb1f3f5 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").
45288fb1f3f5 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.
45288fb1f3f5 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
ab2f908f0b08 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'),
ab2f908f0b08 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'),
ab2f908f0b08 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'),
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
770 ('ADF', 'R', 'Integer',
ab2f908f0b08 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'),
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
772 ('ADR', 'R', 'Integer',
ab2f908f0b08 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')
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
774 ]
ab2f908f0b08 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.
ab2f908f0b08 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,
ab2f908f0b08 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
ab2f908f0b08 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.
ab2f908f0b08 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()
ab2f908f0b08 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:
ab2f908f0b08 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)
ab2f908f0b08 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:
ab2f908f0b08 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])
ab2f908f0b08 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)
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
785
2
d062703d6f13 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
45288fb1f3f5 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
d062703d6f13 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:
d062703d6f13 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
7c5e867820cf 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
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
791 # by VarScan
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
792 varscan_header.formats.remove_header('AD')
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
793 varscan_header.formats.remove_header('FREQ')
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
794 varscan_header.formats.remove_header('RD')
7c5e867820cf 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
45288fb1f3f5 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
45288fb1f3f5 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()
45288fb1f3f5 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
d062703d6f13 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:
d062703d6f13 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
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
801 # add reference information
45288fb1f3f5 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)
45288fb1f3f5 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
45288fb1f3f5 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')
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
805 # add contig information
45288fb1f3f5 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)
45288fb1f3f5 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
45288fb1f3f5 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)
45288fb1f3f5 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
d062703d6f13 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
45288fb1f3f5 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
45288fb1f3f5 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:
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
813 # add filter info
45288fb1f3f5 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)
45288fb1f3f5 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
45288fb1f3f5 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
45288fb1f3f5 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
45288fb1f3f5 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
819 return common_header
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
820
7
7c5e867820cf 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
ab2f908f0b08 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."""
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
823
7
7c5e867820cf 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
7c5e867820cf 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
7c5e867820cf 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
7c5e867820cf 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.
7c5e867820cf 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
7c5e867820cf 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.
7c5e867820cf 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': []}
7c5e867820cf 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
7c5e867820cf 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()
7c5e867820cf 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
7c5e867820cf 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
ab2f908f0b08 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
ab2f908f0b08 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
7c5e867820cf 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
ab2f908f0b08 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
ab2f908f0b08 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
7c5e867820cf 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(
7c5e867820cf 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]))
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
842 )
7c5e867820cf 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(
7c5e867820cf 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
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
845 )
7
7c5e867820cf 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.
7c5e867820cf 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
7c5e867820cf 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.
7c5e867820cf 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:
7c5e867820cf 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."
7c5e867820cf 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.
7c5e867820cf 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):
7c5e867820cf 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(
7c5e867820cf 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),
7c5e867820cf 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]),
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
856 reverse=True
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
857 ):
7c5e867820cf 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
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
859 # remove redundant fields
ab2f908f0b08 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
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
861 del record.format['FREQ']
7c5e867820cf planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit f5e4d8903b6d69b0507f6a8fc4c2533fc7a15dfa
iuc
parents: 6
diff changeset
862 del record.format['RD']
7c5e867820cf 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
ab2f908f0b08 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 4b7660df2384d8c8c6b5a6f02a00d13211e6ff6c
iuc
parents: 2
diff changeset
864
2
d062703d6f13 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,
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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,
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
872 max_relative_len_diff,
d062703d6f13 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,
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
875 max_basequal_diff,
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
877 max_mapqual_diff,
d062703d6f13 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,
d062703d6f13 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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
880 ignore_md,
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
881 **args):
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
885
d062703d6f13 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,
d062703d6f13 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:
d062703d6f13 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,
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
891
d062703d6f13 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:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
893 normal_reads, tumor_reads = (
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
894 io_stack.enter_context(
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
896 )
d062703d6f13 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))
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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
45288fb1f3f5 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':
45288fb1f3f5 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
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
904 # reference base
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
905 continue
9
e3f170cc4f95 "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:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
907 # a deletion
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
908 is_indel = True
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
909 alleles = [
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
910 record.alleles[1], record.alleles[0].replace(
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
912 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
913 ]
e3f170cc4f95 "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:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
915 # an insertion
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
916 is_indel = True
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
917 alleles = [
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
918 record.alleles[0],
e3f170cc4f95 "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(
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
921 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
922 ]
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
923 else:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
924 # a regular SNV
e3f170cc4f95 "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
d062703d6f13 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
d062703d6f13 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':
d062703d6f13 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
e3f170cc4f95 "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
e3f170cc4f95 "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
d062703d6f13 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']:
d062703d6f13 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
e3f170cc4f95 "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
e3f170cc4f95 "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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
935 else:
d062703d6f13 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
d062703d6f13 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)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
938 yield record
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
939 continue
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
940
d062703d6f13 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
d062703d6f13 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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
943
e3f170cc4f95 "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:
e3f170cc4f95 "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(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
946 reads_of_interest,
e3f170cc4f95 "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),
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
948 alleles,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
949 refseq,
e3f170cc4f95 "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,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
951 ignore_nm=False,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
952 mm_runs=True,
e3f170cc4f95 "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,
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
955 )
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
956 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
957 ref_stats = None
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
958 alt_stats = _get_stats(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
959 reads_of_interest,
e3f170cc4f95 "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),
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
961 alleles[1:2],
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
962 refseq,
e3f170cc4f95 "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,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
964 ignore_nm=False,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
965 mm_runs=True,
e3f170cc4f95 "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,
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
968 )[0]
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
969 ref_count = 0
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
970 if ref_stats:
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
971 ref_count = ref_stats.reads_fw + ref_stats.reads_rv
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
972 if ref_stats.avg_basequal < min_ref_basequal:
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
973 record.filter.add('RefBaseQual')
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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 (
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
985 ):
2
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
990 record.filter.add('RefDist3')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
991 if alt_stats:
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
992 alt_count = alt_stats.reads_fw + alt_stats.reads_rv
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
993 if alt_count < min_var_count2:
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
994 if (
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
996 ) or (
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
998 ):
e3f170cc4f95 "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')
e3f170cc4f95 "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:
e3f170cc4f95 "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')
e3f170cc4f95 "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 (
e3f170cc4f95 "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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1004 ):
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1007 if (
9
e3f170cc4f95 "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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1009 ) or (
9
e3f170cc4f95 "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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1011 ):
d062703d6f13 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
e3f170cc4f95 "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:
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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 (
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1024 ):
2
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1029 record.filter.add('VarDist3')
d062703d6f13 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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1031 if (
e3f170cc4f95 "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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1035 if (
e3f170cc4f95 "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
e3f170cc4f95 "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
d062703d6f13 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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1039 mmqs_diff = (
e3f170cc4f95 "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
e3f170cc4f95 "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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1042 )
2
d062703d6f13 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:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1044 record.filter.add('MinMMQSdiff')
d062703d6f13 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:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1046 record.filter.add('MMQSdiff')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1047 if (
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1048 1 -
e3f170cc4f95 "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
e3f170cc4f95 "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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1051 ) > max_relative_len_diff:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1052 record.filter.add('ReadLenDiff')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1053 else:
d062703d6f13 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!
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1057 # rather unreliable variant call.
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1058 record.filter.add('VarCount')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1059 record.filter.add('VarFreq')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1060 yield record
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1061
d062703d6f13 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):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1063 for record in vcf:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1064 record.info['INDEL'] = True
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1065 yield record
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1066
d062703d6f13 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):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1068 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1069 record1 = next(vcf1)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1070 except StopIteration:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1071 for record2 in vcf2:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1072 yield record2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1073 return
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1074 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1075 record2 = next(vcf2)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1076 except StopIteration:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1077 yield record1
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1078 for record1 in vcf1:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1079 yield record1
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1080 return
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1081 while True:
d062703d6f13 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):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1083 yield record1
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1084 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1085 record1 = next(vcf1)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1086 except StopIteration:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1087 yield record2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1088 for record2 in vcf2:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1089 yield record2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1090 return
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1091 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1092 yield record2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1093 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1094 record2 = next(vcf2)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1095 except StopIteration:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1096 yield record1
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1097 for record1 in vcf1:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1098 yield record1
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1099 return
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1100
d062703d6f13 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,
d062703d6f13 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):
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1103 temporary_data = self.tmpfiles
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1104 self.tmpfiles = []
d062703d6f13 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]
d062703d6f13 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]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1107
d062703d6f13 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:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1109 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1110 os.remove(f)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1111 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1112 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1113
8
45288fb1f3f5 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):
45288fb1f3f5 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:
45288fb1f3f5 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:
45288fb1f3f5 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
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
1118 # reference base
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
1119 yield record
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1120
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1121 if no_filters:
8
45288fb1f3f5 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit bd1034af3217cd9fc654d7187bf674a89465755b
iuc
parents: 7
diff changeset
1122 apply_filters = filter_minimal
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1123 else:
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1125
d062703d6f13 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(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1127 temporary_snp_files[0],
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1128 no_filters
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1129 )
d062703d6f13 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:
d062703d6f13 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:
d062703d6f13 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))
d062703d6f13 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(
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1135 ):
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1139 # info
d062703d6f13 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)
d062703d6f13 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)
d062703d6f13 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
ab2f908f0b08 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
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1147 # contig info
d062703d6f13 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)
d062703d6f13 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)
d062703d6f13 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(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1151 indel_invcf.header
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1152 )
6
ab2f908f0b08 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
d062703d6f13 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(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1155 self._merge_generator(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1156 snp_invcf,
d062703d6f13 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)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1158 ),
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1159 **filter_args
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1160 ):
7
7c5e867820cf 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1162 o.write(str(record))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1163 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1164 os.remove(snp_f)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1165 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1166 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1167 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1168 os.remove(indel_f)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1169 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1170 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1171
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1172 else:
d062703d6f13 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:
d062703d6f13 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))
d062703d6f13 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:
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1180 # filters
d062703d6f13 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)
d062703d6f13 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
ab2f908f0b08 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
d062703d6f13 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(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1185 invcf, **filter_args
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1186 ):
7
7c5e867820cf 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1188 o.write(str(record))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1189 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1190 os.remove(f)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1191 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1192 pass
d062703d6f13 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:
d062703d6f13 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))
d062703d6f13 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:
d062703d6f13 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:
d062703d6f13 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
d062703d6f13 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
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1200 # filters
d062703d6f13 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)
d062703d6f13 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)
d062703d6f13 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
ab2f908f0b08 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
d062703d6f13 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(
d062703d6f13 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1207 ):
7
7c5e867820cf 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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1209 o.write(str(record))
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1210 try:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1211 os.remove(f)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1212 except Exception:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1213 pass
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1214
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1215
d062703d6f13 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):
d062703d6f13 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."""
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1218
d062703d6f13 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'):
d062703d6f13 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:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1221 out = (
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1222 output_path.replace('%T', 'snp'),
d062703d6f13 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')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1224 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1225 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1226 out = (
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1227 output_path + '.snp',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1228 output_path + '.indel'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1229 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1230 else:
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1231 out = (output_path, None)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1232
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1233 instance_args = {
d062703d6f13 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 [
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1235 'max_depth',
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1236 'count_orphans',
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1237 'detect_overlaps',
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1238 'min_mapqual',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1239 'min_basequal',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1240 'threads',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1241 'verbose',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1242 'quiet'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1243 ]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1244 }
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1245 varscan_somatic_args = {
d062703d6f13 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 [
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1247 'normal_purity',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1248 'tumor_purity',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1249 'min_coverage',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1250 'min_var_count',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1251 'min_var_freq',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1252 'min_hom_freq',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1253 'somatic_p_value',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1254 'p_value'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1255 ]
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1256 }
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1257
d062703d6f13 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)
d062703d6f13 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)
d062703d6f13 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)
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1261
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1262
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1263 if __name__ == '__main__':
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1264 p = argparse.ArgumentParser()
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1265 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1266 'ref_genome',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1267 metavar='reference_genome',
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1269 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1270 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1271 '--normal',
d062703d6f13 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,
d062703d6f13 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'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1274 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1275 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1276 '--tumor',
d062703d6f13 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,
d062703d6f13 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'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1279 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1280 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1281 '-o', '--ofile', required=True,
d062703d6f13 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',
d062703d6f13 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 '
d062703d6f13 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 '
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1286 '-s|--split-output below).'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1287 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1288 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1289 '-s', '--split-output',
9
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1290 dest='split_output', action='store_true',
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1291 help='indicate that separate output files for SNPs and indels '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1292 'should be generated (original VarScan behavior). If specified, '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1293 '%%T in the --ofile file name will be replaced with "snp" and '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1294 '"indel" to generate the names of the SNP and indel output '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1295 'files, respectively. If %%T is not found in the file name, it '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1296 'will get interpreted as a basename to which ".snp"/".indel" '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1297 'will be appended.'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1298 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1299 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1300 '-t', '--threads',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1301 type=int, default=1,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1302 help='level of parallelism'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1303 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1304 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1305 '-v', '--verbose',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1306 action='store_true',
d062703d6f13 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'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1308 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1309 p.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1310 '-q', '--quiet',
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1311 action='store_true',
d062703d6f13 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'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1313 )
d062703d6f13 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')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1315 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1316 '--normal-purity',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1318 default=1.0,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1320 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1321 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1322 '--tumor-purity',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1324 default=1.0,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1326 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1327 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1328 '--max-pileup-depth',
d062703d6f13 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,
d062703d6f13 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; '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1331 'default: 8000)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1332 )
d062703d6f13 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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1334 '--count-orphans',
e3f170cc4f95 "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',
e3f170cc4f95 "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 '
e3f170cc4f95 "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)'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1338 )
e3f170cc4f95 "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(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1340 '--no-detect-overlaps',
e3f170cc4f95 "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',
e3f170cc4f95 "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 '
e3f170cc4f95 "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 '
e3f170cc4f95 "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. '
e3f170cc4f95 "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)'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1346 )
e3f170cc4f95 "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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1348 '--min-basequal',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1350 default=13,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1352 '(default: 13)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1353 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1354 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1355 '--min-mapqual',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1357 default=0,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1359 '(default: 0)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1360 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1361 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1362 '--min-coverage',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1364 default=8,
d062703d6f13 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 '
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1367 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1368 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1369 '--min-var-count',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1371 default=2,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1373 'variant (default: 2)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1374 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1375 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1376 '--min-var-freq',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1378 default=0.1,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1380 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1381 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1382 '--min-hom-freq',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1384 default=0.75,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1386 '(default: 0.75)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1387 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1388 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1389 '--p-value',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1391 default=0.99,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1393 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1394 call_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1395 '--somatic-p-value',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1397 default=0.05,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1399 )
d062703d6f13 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')
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1401 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1402 '--no-filters',
d062703d6f13 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',
d062703d6f13 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. '
d062703d6f13 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'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1406 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1407 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1408 '--min-var-count2',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1410 default=4,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1412 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1413 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1414 '--min-var-count2-lc',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1416 default=2,
d062703d6f13 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
e3f170cc4f95 "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)'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1419 )
e3f170cc4f95 "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(
e3f170cc4f95 "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',
e3f170cc4f95 "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,
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1423 default=10,
e3f170cc4f95 "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 '
e3f170cc4f95 "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 '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1426 '(default: 10)'
2
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1427 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1428 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1429 '--min-var-freq2',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1431 default=0.05,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1433 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1434 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1435 '--min-ref-readpos',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1437 default=0.1,
d062703d6f13 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 '
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1440 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1441 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1442 '--min-var-readpos',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1444 default=0.1,
d062703d6f13 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 '
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1447 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1448 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1449 '--min-ref-dist3',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1451 default=0.1,
d062703d6f13 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 '
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1454 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1455 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1456 '--min-var-dist3',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1458 default=0.1,
d062703d6f13 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 '
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1461 )
d062703d6f13 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
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1463 '--detect-q2-runs',
e3f170cc4f95 "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',
e3f170cc4f95 "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 '
e3f170cc4f95 "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 '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1467 '(default: off)'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1468 )
e3f170cc4f95 "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
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1470 '--min-ref-len',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1472 default=90,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1474 'allele (default: 90)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1475 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1476 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1477 '--min-var-len',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1479 default=90,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1481 'allele (default: 90)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1482 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1483 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1484 '--max-len-diff',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1486 default=0.25,
d062703d6f13 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; '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1488 'default: 0.25)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1489 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1490 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1491 '--min-strandedness',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1493 default=0.01,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1495 '(default: 0.01)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1496 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1497 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1498 '--min-strand-reads',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1500 default=5,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1502 '(default: 5)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1503 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1504 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1505 '--min-ref-basequal',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1507 default=15,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1509 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1510 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1511 '--min-var-basequal',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1513 default=15,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1515 '(default: 15)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1516 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1517 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1518 '--max-basequal-diff',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1520 default=50,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1522 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1523 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1524 '--min-ref-mapqual',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1526 default=15,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1528 'allele (default: 15)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1529 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1530 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1531 '--min-var-mapqual',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1533 default=15,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1535 'allele (default: 15)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1536 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1537 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1538 '--max-mapqual-diff',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1540 default=50,
d062703d6f13 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; '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1542 'default: 50)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1543 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1544 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1545 '--max-ref-mmqs',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1547 default=100,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1549 'allele (default: 100)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1550 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1551 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1552 '--max-var-mmqs',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1554 default=100,
d062703d6f13 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 '
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1556 'allele (default: 100)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1557 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1558 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1559 '--min-mmqs-diff',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1561 default=0,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1563 )
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1564 filter_group.add_argument(
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1565 '--max-mmqs-diff',
d062703d6f13 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,
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1567 default=50,
d062703d6f13 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)'
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1569 )
9
e3f170cc4f95 "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(
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1571 '--ignore-md',
e3f170cc4f95 "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',
e3f170cc4f95 "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 '
e3f170cc4f95 "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 '
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1575 'alignments instead.'
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1576 )
e3f170cc4f95 "planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit fcf5ac14629c694f0f64773fab0428b1e78fe156"
iuc
parents: 8
diff changeset
1577
2
d062703d6f13 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())
d062703d6f13 planemo upload for repository https://github.com/galaxyproject/iuc/tree/master/tools/varscan commit 30867f1f022bed18ba1c3b8dc9c54226890b3a9c
iuc
parents:
diff changeset
1579 varscan_call(**args)