Repository revision
19:a2f8dc22d7c0

Repository 'bcftools_stats'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats

bcftools stats tool metadata
Miscellaneous
Parses VCF or BCF and produces stats which can be plotted using plot-vcfstats
bcftools_stats
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.15.1+galaxy3
1.15.1+galaxy3
bcftools 2>&1 | grep 'Version:'
True
Version lineage of this tool (guids ordered most recent to oldest)
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.15.1+galaxy3 (this tool)
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.15.1+galaxy2
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.15.1+galaxy1
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.15.1+galaxy0
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.10+galaxy1
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.10
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.9+galaxy1
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.9
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.4.0
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.3.1
toolshed.g2.bx.psu.edu/repos/iuc/bcftools_stats/bcftools_stats/1.3.0
bcftools_stats
Requirements (dependencies defined in the <requirements> tag set)
name version type
bcftools 1.15.1 package
htslib 1.15.1 package
samtools 1.15.1 package
matplotlib 3.5.3 package
tectonic 0.12.0 package
Additional information about this tool
export BCFTOOLS_PLUGINS=`which bcftools | sed 's,bin/bcftools,libexec/bcftools,'`;

  
#set $input_files = [$input_file]
#if $inputB_file:
    #silent $input_files.append($inputB_file)
#end if


## May need to symlink input if there is an associated
#set $input_vcfs = []
#set $vcfs_list_file = 'vcfs_list'
#for (i, input_file) in enumerate($input_files):
  #set $input_vcf = 'input' + str($i) + '.vcf.gz'
  #if $input_file.is_of_type('vcf')
    bgzip -c '$input_file' > $input_vcf &&
    bcftools index $input_vcf &&
  ##elif $input_file.is_of_type('vcf_bgzip') or $input_file.is_of_type('vcf.gz') -> REQUIRES  https://github.com/galaxyproject/galaxy/pull/14605
  #elif $input_file.is_of_type('vcf_bgzip') or $input_file.is_of_type('vcf.gz')
    ln -s '$input_file' $input_vcf &&
    #if $input_file.metadata.tabix_index:
      ln -s '${input_file.metadata.tabix_index}' ${input_vcf}.tbi &&
    #else
      bcftools index $input_vcf &&
    #end if
  #elif $input_file.is_of_type('bcf')
    #set $input_vcf = 'input' + str($i) + '.bcf.gz'
    ln -s '$input_file' $input_vcf &&
    #if $input_file.metadata.bcf_index:
      ln -s '${input_file.metadata.bcf_index}' ${input_vcf}.csi &&
    #else
      bcftools index $input_vcf &&
    #end if
  #end if
  echo '$input_vcf' >> $vcfs_list_file &&
  $input_vcfs.append($input_vcf)
#end for

  
#set $section = $sec_restrict


#set $targets_path = None
#if 'targets' in $section
  #if $section.targets.targets_src == 'targets_file':
    #set $targets_path = 'targets_file.tab.gz'
    bgzip -c "$section.targets.targets_file" > $targets_path &&
    tabix -s 1 -b 2 -e 2 $targets_path &&
  #end if
#elif $tgts_sec.targets_file:
  #set $targets_path = 'targets_file.tab.gz'
  bgzip -c "$section.targets_file" > $targets_path &&
  tabix -s 1 -b 2 -e 2 $targets_path &&
#end if

  


#set $regions_path = None
#if 'regions' in $section
  #if $section.regions.regions_src == 'regions_file' and $section.regions.regions_file:
    #if $section.regions.regions_file.ext.startswith('bed'):
      #set $regions_path = 'regions_file.bed'
      ln -s '$section.regions.regions_file' $regions_path &&
    #end if
  #end if
#end if

  
## Stats section
#set $section = $sec_default.reference_source


#set $input_fa_ref = None
#if 'fasta_ref' in $section and $section.fasta_ref:
  #if 'reference_source_selector' in $section:
    #if str($section.reference_source_selector) == "history":
      #set $input_fa_ref = 'ref.fa'
      ln -s '$section.fasta_ref' $input_fa_ref &&
      samtools faidx $input_fa_ref &&
    #else:
      #set $input_fa_ref = str($section.fasta_ref.fields.path)
    #end if
  #end if
#end if

  
#set $section = $sec_default


#set $exons_path = None
#if 'exons_file' in $section and $section.exons_file:
    #set $exons_path = 'exons_file.tab.gz'
    bgzip -c "$section.exons_file" > $exons_path &&
    tabix -s 1 -b 2 -e 3 $exons_path &&
#end if

  

bcftools stats

## Stats section
#set $section = $sec_default.reference_source

#if $input_fa_ref is not None:
  --fasta-ref $input_fa_ref
#elif 'fasta_ref' in $section and $section.fasta_ref:
  --fasta-ref '${section.fasta_ref}'
#end if
  
#set $section = $sec_default

#if 'exons_file' in $section and $section.exons_file:
  --exons $exons_path
#end if
  
${section.first_allele_only}
#if $section.depth.set_depth == 'yes':
    --depth ${section.depth.depth_min},${section.depth.depth_max},${section.depth.depth_bin_size}
#end if
#if $section.user_tstv:
    --user-tstv '${section.user_tstv}'
#end if
#if $section.afbins.afbins_select == 'af_bins_list':
    --af-bins '$section.afbins.af_bins_list'
#elif $section.afbins.afbins_select == 'af_bins_file':
    --af-bins '$section.afbins.af_bins_file'
#end if
#if $section.af_tag:
    --af-tag '${section.af_tag}'
#end if
#if len($input_vcfs) == 1:
    ${section.split_by_ID}
#end if
${section.verbose}

## Stats section
#set $section = $sec_restrict

#if $section.apply_filters:
  --apply-filters '${section.apply_filters}'
#end if
  

#if $section.collapse:
  --collapse ${section.collapse}
#end if
  


#if $section.regions.regions_src == 'regions':
  #set $intervals = $section.regions.regions
  

#set $components = []
#for $i in $intervals:
  #set $chrom = str($i.chrom).strip()
  #set $start = str($i.start).strip()
  #set $stop = str($i.stop).strip()
  #if $start or $stop:
    $components.append($chrom + ':' + ($start or '0') + '-' + $stop)
  #else:
    $components.append($chrom)
  #end if
#end for
#set $intervals_spec = ','.join($components)

  
  --regions '$intervals_spec'
#elif $section.regions.regions_src == 'regions_file' and $section.regions.regions_file:
  #if $regions_path is not None:
    --regions-file '$regions_path'
  #else:
    --regions-file '$section.regions.regions_file'
  #end if
#end if
#if $section.regions_overlap
  --regions-overlap $section.regions_overlap
#end if


  

#set $samples_defined = False
#if str($section.samples) != '':
  #set $samples_defined = True
  --samples '${section.invert_samples}${section.samples}'
#end if
#if $section.samples_file:
  #set $samples_defined = True
  --samples-file "${section.invert_samples_file}${section.samples_file}"
#end if
  


#if $targets_path:
  --targets-file "${section.targets.invert_targets_file}${targets_path}"
#elif $section.targets.targets_src == 'targets':
  #set $intervals = $section.targets.targets
  

#set $components = []
#for $i in $intervals:
  #set $chrom = str($i.chrom).strip()
  #set $start = str($i.start).strip()
  #set $stop = str($i.stop).strip()
  #if $start or $stop:
    $components.append($chrom + ':' + ($start or '0') + '-' + $stop)
  #else:
    $components.append($chrom)
  #end if
#end for
#set $intervals_spec = ','.join($components)

  
  --targets '${section.targets.invert_targets_file}$intervals_spec'
#elif $section.targets.targets_src == 'targets_file' and $section.targets.targets_file:
  --targets-file "${section.targets.invert_targets_file}${section.targets.targets_file}"
#end if
#if $section.targets_overlap
  --targets-overlap $section.targets_overlap
#end if

  

#if $section.include:
  --include '${section.include}'
#end if
  

#if $section.exclude:
  --exclude '${section.exclude}'
#end if
  

## Primary Input/Outputs

#echo ' '.join($input_vcfs)#
  
> '$output_file'
#if $plot_title:
    && plot-vcfstats
    -p 'plot_tmp/'
    -T '$plot_title'
    -s
    '$output_file'
    || (printf "The content of plot_tmp/plot-vcfstats.log is:\n" >&2 && cat plot_tmp/plot-vcfstats.log >&2 && exit 1)
#end if
    
None
False
Functional tests
name inputs outputs required files
Test-1 input_file: stats.b.vcf
inputB_file: stats.a.vcf
name: value
stats.b.vcf
stats.a.vcf
value
Test-2 input_file: mpileup.vcf
sec_default|reference_source|fasta_ref: mpileup
sec_default|reference_source|reference_source_selector: cached
name: value
mpileup.vcf
value
Test-3 input_file: mpileup.vcf
plot_title: Plot for mpileup.vcf
name: value
name: value
mpileup.vcf
value
Test-4 input_file: stats.b.vcf
inputB_file: stats.a.vcf
sec_restrict|regions_overlap: 1
name: value
stats.b.vcf
stats.a.vcf
value
Test-5 input_file: mpileup.vcf
sec_restrict|samples: -
name: value
mpileup.vcf
value