| 
0
 | 
     1 <tool id="filter_vcf" name="Filter VCF" version="1.0">
 | 
| 
 | 
     2   <description>filters a VCF file</description>
 | 
| 
 | 
     3   <requirements>
 | 
| 
 | 
     4     <requirement type="package" version="2.7.10">python</requirement>
 | 
| 
 | 
     5     <requirement type="package" version="0.6.8dev">pyvcf</requirement>
 | 
| 
 | 
     6     <requirement type="package" version="3.11">pyyaml</requirement>
 | 
| 
 | 
     7     <requirement type="package" version="2.0.2">bintrees</requirement>
 | 
| 
 | 
     8 	<requirement type="package" version="1.66">biopython</requirement>
 | 
| 
 | 
     9 	<requirement type="package" version="1.4">matplotlib</requirement>
 | 
| 
 | 
    10 	<requirement type="package" version="0.23.1">cython</requirement>
 | 
| 
 | 
    11 	<requirement type="package" version="1.0">phephenix</requirement>
 | 
| 
 | 
    12   </requirements>
 | 
| 
 | 
    13   <stdio>
 | 
| 
 | 
    14     <!-- Assume anything other than zero is an error -->
 | 
| 
 | 
    15     <exit_code range="1:" />
 | 
| 
 | 
    16     <exit_code range=":-1" />
 | 
| 
 | 
    17   </stdio>
 | 
| 
 | 
    18   <command interpreter="bash">
 | 
| 
 | 
    19     filter_vcf.sh
 | 
| 
 | 
    20 	$output
 | 
| 
 | 
    21 	$input
 | 
| 
6
 | 
    22     $ref_fa
 | 
| 
0
 | 
    23     #if str($onlygood) == "false":
 | 
| 
 | 
    24 		onlygood
 | 
| 
 | 
    25 	#else
 | 
| 
 | 
    26 		NOTTHERE
 | 
| 
 | 
    27 	#end if
 | 
| 
 | 
    28 	#for $sf in $snp_filter:
 | 
| 
 | 
    29 		#for $name, $param in $sf.snp_filter_type.iteritems():
 | 
| 
 | 
    30 			#if $name not in [ "__current_case__", "snp_filter_type_selector" ]:
 | 
| 
 | 
    31 				${name}:"${param}"
 | 
| 
 | 
    32 			#end if
 | 
| 
 | 
    33 		#end for
 | 
| 
 | 
    34 	#end for
 | 
| 
 | 
    35   </command>
 | 
| 
 | 
    36 
 | 
| 
 | 
    37   <inputs>
 | 
| 
 | 
    38     <param name="input" type="data" format="vcf" label="VCF File to filter" />
 | 
| 
 | 
    39 
 | 
| 
6
 | 
    40     <param name="ref_fa" type="data" format="fasta" label="Reference genome fasta file" help="REQUIRED."/>
 | 
| 
 | 
    41 
 | 
| 
0
 | 
    42     <repeat name="snp_filter" title="SNP Filter" help="">
 | 
| 
 | 
    43         <conditional name="snp_filter_type">
 | 
| 
 | 
    44 			<param name="snp_filter_type_selector" type="select" label="SNP Filter Type">
 | 
| 
 | 
    45 				<option value="gq_score_option">GQ score</option>
 | 
| 
 | 
    46 				<option value="dp4_ratio_option">DP4 ratio</option>
 | 
| 
 | 
    47 				<option value="ad_ratio_option">AD ratio</option>
 | 
| 
 | 
    48 				<option value="mq_score_option">MQ score</option>
 | 
| 
 | 
    49 				<option value="min_depth_option">Minimum depth</option>
 | 
| 
 | 
    50 				<option value="uncall_gt_option">Uncall GT</option>
 | 
| 
 | 
    51 				<option value="mq0_ratio_option">MQ0 ratio</option>
 | 
| 
 | 
    52 				<option value="qual_score_option">Quality score</option>
 | 
| 
 | 
    53 				<option value="mq0f_ratio_option">MQ0F ratio</option>
 | 
| 
 | 
    54             </param>
 | 
| 
 | 
    55 			<when value="gq_score_option">
 | 
| 
12
 | 
    56 				<param name="gq_score" type="integer" value="0" label="Minimum GC score" help="Type integer."/>
 | 
| 
0
 | 
    57 			</when>
 | 
| 
 | 
    58 			<when value="dp4_ratio_option">
 | 
| 
12
 | 
    59 				<param name="dp4_ratio" type="float" value="0.9" label="Minimum DP4 ratio" help="Type float. Only samtools mpileup before version 1.3."/>
 | 
| 
0
 | 
    60 			</when>
 | 
| 
 | 
    61 			<when value="ad_ratio_option">
 | 
| 
12
 | 
    62 				<param name="ad_ratio" type="float" value="0.9" label="Minimum AD ratio" help="Type float. GATK only and samtools from version 1.3."/>
 | 
| 
0
 | 
    63 			</when>
 | 
| 
 | 
    64 			<when value="mq_score_option">
 | 
| 
12
 | 
    65 				<param name="mq_score" type="integer" value="30" label="Minimum MQ score" help="Type integer."/>
 | 
| 
0
 | 
    66 			</when>
 | 
| 
 | 
    67 			<when value="min_depth_option">
 | 
| 
12
 | 
    68 				<param name="min_depth" type="integer" value="5" label="Minimum depth" help="Type integer."/>
 | 
| 
0
 | 
    69 			</when>
 | 
| 
 | 
    70 			<when value="uncall_gt_option">
 | 
| 
 | 
    71 				<param name="uncall_gt" type="text" value="" hidden="True"/>
 | 
| 
 | 
    72 			</when>
 | 
| 
 | 
    73 			<when value="mq0_ratio_option">
 | 
| 
12
 | 
    74 				<param name="mq0_ratio" type="float" value="0.05" label="Minimim MQ0 ratio" help="Type float. GATK only."/>
 | 
| 
0
 | 
    75 			</when>
 | 
| 
 | 
    76 			<when value="qual_score_option">
 | 
| 
12
 | 
    77 				<param name="qual_score" type="integer" value="30" label="Minimim quality score" help="Type integer."/>
 | 
| 
0
 | 
    78 			</when>
 | 
| 
 | 
    79 			<when value="mq0f_ratio_option">
 | 
| 
12
 | 
    80 				<param name="mq0f_ratio" type="float" value="0.05" label="Minimum MQ0F ratio" help="Type float. Samtools only."/>
 | 
| 
0
 | 
    81 			</when>
 | 
| 
 | 
    82 		</conditional>
 | 
| 
 | 
    83     </repeat>
 | 
| 
 | 
    84 	<param name="onlygood" type="select" label="Write only good variants to output" help="Write only variants that PASS all filters. ">
 | 
| 
 | 
    85 			<option value="true" selected="true">Write all</option>
 | 
| 
 | 
    86 			<option value="false">Write only good</option>
 | 
| 
 | 
    87     </param>
 | 
| 
 | 
    88   </inputs>
 | 
| 
 | 
    89 
 | 
| 
 | 
    90   <outputs>
 | 
| 
 | 
    91     <data format="vcf" name="output" label="${tool.name} on ${on_string}: filtered VCF" />
 | 
| 
 | 
    92   </outputs>
 | 
| 
 | 
    93     <tests>
 | 
| 
 | 
    94         <test>
 | 
| 
 | 
    95             <param name="input" value="test_input.vcf" ftype="vcf" />
 | 
| 
 | 
    96             <param name="min_depth" value="100" />
 | 
| 
 | 
    97             <output name="output" file="test_output.vcf" ftype="vcf" />
 | 
| 
 | 
    98         </test>
 | 
| 
 | 
    99     </tests>
 | 
| 
 | 
   100   <help>
 | 
| 
 | 
   101 
 | 
| 
 | 
   102 usage: filter_vcf.py [-h] \-\-vcf VCF \-\-filters FILTERS \-\-output OUTPUT
 | 
| 
 | 
   103 
 | 
| 
 | 
   104 optional arguments:
 | 
| 
 | 
   105 
 | 
| 
 | 
   106 -h, \-\-help            show this help message and exit
 | 
| 
 | 
   107 
 | 
| 
 | 
   108 \-\-vcf VCF, -v VCF     VCF file to (re)filter.
 | 
| 
 | 
   109 
 | 
| 
 | 
   110 \-\-filters FILTERS, -f FILTERS	Filter(s) to apply as key:threshold pairs, separated by comma.
 | 
| 
 | 
   111 
 | 
| 
 | 
   112 \-\-output OUTPUT, -o OUTPUT	Location for filtered VCF to be written.
 | 
| 
 | 
   113 
 | 
| 
6
 | 
   114 \-\-reference REFERENCE, -r REFERENCE   mpileup versions 1.3 and before do not output all positions. This is required to fix reference base in VCF.
 | 
| 
 | 
   115 
 | 
| 
 | 
   116 \-\-only-good           Write only variants that PASS all filters (default all variants are written).
 | 
| 
 | 
   117 
 | 
| 
15
 | 
   118 -----
 | 
| 
 | 
   119 
 | 
| 
 | 
   120 Which filter can be used for your data depends on the variant caller that was used to create the VCF file.
 | 
| 
 | 
   121 
 | 
| 
 | 
   122 =============  ===============================================
 | 
| 
 | 
   123 Filter         Remark
 | 
| 
 | 
   124 =============  ===============================================
 | 
| 
 | 
   125 GQ score       Always available*
 | 
| 
 | 
   126 DP4 ratio      Samtools mpileup before version 1.3 only*
 | 
| 
 | 
   127 AD ratio       GATK and samtools mpileup from version 1.3 only
 | 
| 
 | 
   128 MQ score       Always available*
 | 
| 
 | 
   129 Minimum depth  Always available*
 | 
| 
 | 
   130 MQ0 ratio      GATK only
 | 
| 
 | 
   131 Quality score  Always available*
 | 
| 
 | 
   132 MQ0F ratio     Samtools mpileup only*
 | 
| 
 | 
   133 =============  ===============================================
 | 
| 
 | 
   134 
 | 
| 
 | 
   135 Filters marked with * are availabe for the workflow included with PHE Phenix.
 | 
| 
 | 
   136 
 | 
| 
0
 | 
   137   </help>
 | 
| 
 | 
   138 </tool>
 |