Merge pull request #6627 from mvdbeek/test_more_tools

Test tools shipped with Galaxy
This commit is contained in:
John Chilton
2018-09-05 14:43:13 -04:00
committed by GitHub
34 changed files with 231 additions and 197 deletions
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
./run_tests.sh --dockerize --python3 --db postgres --clean_pyc -main "$@"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
./run_tests.sh --dockerize --db postgres --external_tmp --clean_pyc -main "$@"
+2 -2
View File
@@ -188,7 +188,7 @@ class GFFReaderWrapper(NiceReaderWrapper):
if not self.seed_interval:
while not self.seed_interval:
try:
self.seed_interval = GenomicIntervalReader.next(self)
self.seed_interval = super(GenomicIntervalReader, self).__next__()
except ParseError as e:
handle_parse_error(e)
# TODO: When no longer supporting python 2.4 use finally:
@@ -215,7 +215,7 @@ class GFFReaderWrapper(NiceReaderWrapper):
feature_intervals.append(self.seed_interval)
while True:
try:
interval = GenomicIntervalReader.next(self)
interval = super(GenomicIntervalReader, self).__next__()
raw_size += len(self.current_line)
except StopIteration as e:
# No more intervals to read, but last feature needs to be
+2 -1
View File
@@ -5,6 +5,7 @@ Provides wrappers and utilities for working with MAF files and alignments.
# Dan Blankenberg
from __future__ import print_function
import functools
import logging
import os
import resource
@@ -655,7 +656,7 @@ def sort_block_components_by_block(block1, block2):
# orders the components in block1 by the index of the component in block2
# block1 must be a subset of block2
# occurs in-place
return block1.components.sort(cmp=lambda x, y: block2.components.index(x) - block2.components.index(y))
return block1.components.sort(key=functools.cmp_to_key(lambda x, y: block2.components.index(x) - block2.components.index(y)))
def get_species_in_maf(maf_filename):
+6 -3
View File
@@ -18,19 +18,22 @@ class UCSCOutWrapper(object):
def __iter__(self):
return self
def next(self):
def __next__(self):
if self.lookahead is None:
line = self.other.next()
line = next(self.other)
else:
line = self.lookahead
self.lookahead = None
if line.startswith("----------"):
next_line = self.other.next()
next_line = next(self.other)
if next_line.startswith("Reached output limit"):
raise UCSCLimitException(next_line.strip())
else:
self.lookahead = next_line
return line
def next(self):
return self.__next__()
def readline(self):
return self.next()
+5 -1
View File
@@ -1,11 +1,15 @@
# Deprecated, IUC provides same tool, kept for backwards compat?
Extract genomic DNA 1
# Relies on data table, but data table not available
# Relies on data table or loc file, but data table not available
Interval2Maf1
Interval2Maf_pairwise1
maf_stats1
Interval_Maf_Merged_Fasta2
GeneBed_Maf_Fasta2
# No dependency available
hgv_lps
# Some weird parameter issue
maf_by_block_number1
# Requires hg17.len to be present
bed_to_bigBed
wig_to_bigWig
+2 -2
View File
@@ -39,12 +39,12 @@
<param name="blockSize" value="256" />
<param name="itemsPerSlot" value="512" />
<param name="unc" value="False" />
<output name="out_file1" file="7.bigbed"/>
<output name="out_file1" file="7.bigbed" compare="sim_size"/>
</test>
<test>
<param name="input1" value="7.bed" dbkey="hg17" />
<param name="settingsType" value="preset" />
<output name="out_file1" file="7.bigbed"/>
<output name="out_file1" file="7.bigbed" compare="sim_size"/>
</test>
</tests>
<help>
+5 -5
View File
@@ -79,7 +79,7 @@ class SortedOffsets(OffsetList):
def __init__(self, indexed_filename, column, split=None):
OffsetList.__init__(self, os.stat(indexed_filename).st_size)
self.indexed_filename = indexed_filename
self.indexed_file = open(indexed_filename, 'rb')
self.indexed_file = open(indexed_filename, 'r')
self.column = column
self.split = split
self.last_identifier = None
@@ -149,7 +149,7 @@ class SortedOffsets(OffsetList):
class OffsetIndex:
def __init__(self, filename, column, split=None, index_depth=3):
self.filename = filename
self.file = open(filename, 'rb')
self.file = open(filename, 'r')
self.column = column
self.split = split
self._offsets = {}
@@ -243,7 +243,7 @@ class BufferedIndex:
def __init__(self, filename, column, split=None, buffer=1000000, index_depth=3):
self.index = OffsetIndex(filename, column, split, index_depth)
self.buffered_offsets = {}
f = open(filename, 'rb')
f = open(filename, 'r')
offset = f.tell()
identified_offset_count = 1
while True:
@@ -296,9 +296,9 @@ def join_files(filename1, column1, filename2, column2, out_filename, split=None,
if fill_options is None:
fill_options = Bunch(fill_unjoined_only=True, file1_columns=None, file2_columns=None)
keep_headers_done = False
out = open(out_filename, 'w+b')
out = open(out_filename, 'w')
index = BufferedIndex(filename2, column2, split, buffer, index_depth)
for line1 in open(filename1, 'rb'):
for line1 in open(filename1, 'r'):
if keep_headers and not keep_headers_done:
header1 = line1
with open(filename2, 'r') as file2:
+1 -1
View File
@@ -53,7 +53,7 @@ def main():
if ret == 0:
cl = subprocess.Popen(["join", "--version"], stdout=subprocess.PIPE)
(stdout, _) = cl.communicate()
version_line = stdout.split("\n")[0]
version_line = stdout.decode('utf-8').split("\n")[0]
(version, _) = version_line.split()[-1].split(".")
if int(version) >= 7:
flags = "--nocheck-order"
+11 -12
View File
@@ -29,19 +29,18 @@ def __main__():
assert options.input, "You must provide an input filename."
assert options.output, "You must provide an output filename."
input = open(options.input)
while True:
chunk = input.read(CHUNK_SIZE)
if chunk:
for algorithm in algorithms.values():
algorithm.update(chunk)
else:
break
with open(options.input, 'rb') as fh:
while True:
chunk = fh.read(CHUNK_SIZE)
if chunk:
for algorithm in algorithms.values():
algorithm.update(chunk)
else:
break
output = open(options.output, 'wb')
output.write('#%s\n' % ('\t'.join(algorithms.keys())))
output.write('%s\n' % ('\t'.join(x.hexdigest() for x in algorithms.values())))
output.close()
with open(options.output, 'w') as output:
output.write('#%s\n' % ('\t'.join(algorithms.keys())))
output.write('%s\n' % ('\t'.join(x.hexdigest() for x in algorithms.values())))
if __name__ == "__main__":
+7 -4
View File
@@ -1,9 +1,12 @@
<tool id="Sff_extractor" name="SFF converter" version="1.0.1">
<description></description>
<command interpreter="python">
#if str($fastq_output) == "fastq_false" #sff_extract.py $clip --seq_file=$out_file3 --qual_file=$out_file4 --xml_file=$out_file2 $input
#elif str($fastq_output) == "fastq_true" #sff_extract.py $clip --fastq --seq_file=$out_file1 --xml_file=$out_file2 $input
#end if#
<requirements>
<requirement type="package" version="2.7">python</requirement>
</requirements>
<command>
#if str($fastq_output) == "fastq_false" #python '$__tool_directory__/sff_extract.py' $clip --seq_file='$out_file3' --qual_file='$out_file4' --xml_file='$out_file2' '$input'
#elif str($fastq_output) == "fastq_true" #python '$__tool_directory__/sff_extract.py' $clip --fastq --seq_file='$out_file1' --xml_file='$out_file2' '$input'
#end if#
</command>
<inputs>
<param format="sff" name="input" type="data" label="Extract from this dataset"/>
+2 -1
View File
@@ -1,6 +1,7 @@
<tool id="Show tail1" name="Select last" version="1.0.0">
<description>lines from a dataset</description>
<command interpreter="perl">tailWrapper.pl $input $lineNum $out_file1</command>
<command detect_errors="exit_code">
perl '$__tool_directory__/tailWrapper.pl' '$input' $lineNum '$out_file1'</command>
<inputs>
<param name="lineNum" size="5" type="integer" value="10" label="Select last" help="lines"/>
<param format="txt" name="input" type="data" label="from"/>
+4 -1
View File
@@ -1,6 +1,9 @@
<tool id="Count1" name="Count" version="1.0.2">
<description>occurrences of each record</description>
<command interpreter="python">uniq.py -i $input -o $out_file1 -c "$column" -d $delim -s $sorting</command>
<requirements>
<requirement type="package" version="8.30">coreutils</requirement>
</requirements>
<command>python '$__tool_directory__/uniq.py' -i '$input' -o '$out_file1' -c '$column' -d $delim -s $sorting</command>
<inputs>
<param name="input" type="data" format="tabular" label="from dataset" help="Dataset missing? See TIP below"/>
<param name="column" type="data_column" data_ref="input" multiple="True" numerical="False" label="Count occurrences of values in column(s)" help="Multi-select list - hold the appropriate key while clicking to select multiple columns" />
+3 -3
View File
@@ -4,11 +4,11 @@
#set $word_to_arg = { 'characters':'m', 'words':'w', 'lines':'l' }
#set $arg_order = [ 'lines', 'words', 'characters' ]
#if not isinstance( $options.value, list ):
#set $args = [ $options.value ]
#set global $args = [ $options.value ]
#else:
#set $args = $options.value
#set global $args = $options.value
#end if
#if $include_header.value:
#if $include_header.value
echo "#${ "\t".join( [ i for i in $arg_order if i in $args ] ) }" &gt; $out_file1
&amp;&amp;
#end if
+3 -3
View File
@@ -11,7 +11,7 @@
</stdio>
<command>
<![CDATA[
grep -v "^track" $input1 | wigToBigWig stdin $chromInfo $out_file1
grep -v "^track" '$input1' | wigToBigWig stdin '$chromInfo' '$out_file1'
#if $settings.settingsType == "full":
-blockSize=${settings.blockSize} -itemsPerSlot=${settings.itemsPerSlot} ${settings.clip} ${settings.unc}
#else:
@@ -57,9 +57,9 @@
<output name="out_file1" file="2.bigwig"/>
</test>
<test>
<param name="input1" value="1.bedgraph" dbkey="hg19" ftype="bedgraph"/>
<param name="input1" value="1.bedgraph" dbkey="hg17" ftype="bedgraph"/>
<param name="settingsType" value="preset" />
<output name="out_file1" file="3.bigwig"/>
<output name="out_file1" file="3.bigwig" compare="sim_size"/>
</test>
</tests>
<help>
+2 -1
View File
@@ -46,7 +46,8 @@ def main():
maf_reader.close()
maf_writer.close()
print("Restricted to species: %s." % ", ".join(species))
if species:
print("Restricted to species: %s." % ", ".join(species))
print("%i MAF blocks have been kept." % maf_blocks_kept)
+2 -2
View File
@@ -18,12 +18,12 @@
<test>
<param name="input1" value="maf_split_by_species_in.maf"/>
<param name="collapse_columns" value="True"/>
<output name="out_file1" file="maf_split_by_species_collapsed_out.maf"/>
<output name="out_file1" file="maf_split_by_species_collapsed_out.maf" sort="true"/>
</test>
<test>
<param name="input1" value="maf_split_by_species_in.maf"/>
<param name="collapse_columns" value="False"/>
<output name="out_file1" file="maf_split_by_species_not_collapsed_out.maf"/>
<output name="out_file1" file="maf_split_by_species_not_collapsed_out.maf" sort="true"/>
</test>
</tests>
<help>
+26 -25
View File
@@ -6,6 +6,7 @@ from __future__ import print_function
import os
import sys
from collections import OrderedDict
from bx.align import maf
@@ -23,14 +24,15 @@ def __main__():
primary_spec = None
if "None" in species:
species = set()
species = OrderedDict()
try:
for i, m in enumerate(maf.Reader(open(input_filename, 'r'))):
for c in m.components:
spec, chrom = maf.src_split(c.src)
if not spec or not chrom:
spec = chrom = c.src
species.add(spec)
spec = c.src
species[spec] = None
species = species.keys()
except Exception:
print("Invalid MAF file specified", file=sys.stderr)
return
@@ -44,36 +46,35 @@ def __main__():
out_files[spec] = open(output_filename, 'w')
primary_spec = spec
else:
out_files[spec] = open(os.path.join(database_tmp_dir, 'primary_%s_%s_visible_bed_%s' % (output_id, spec, spec)), 'wb+')
out_files[spec] = open(os.path.join(database_tmp_dir, 'primary_%s_%s_visible_bed_%s' % (output_id, spec, spec)), 'w+')
num_species = len(species)
print("Restricted to species:", ",".join(species))
file_in = open(input_filename, 'r')
maf_reader = maf.Reader(file_in)
with open(input_filename, 'r') as file_in:
maf_reader = maf.Reader(file_in)
block_num = -1
block_num = -1
for i, m in enumerate(maf_reader):
block_num += 1
if "None" not in species:
m = m.limit_to_species(species)
l = m.components
if len(l) < num_species and partial == "partial_disallowed":
continue
for c in l:
spec, chrom = maf.src_split(c.src)
if not spec or not chrom:
spec = chrom = c.src
if spec not in out_files.keys():
out_files[spec] = open(os.path.join(database_tmp_dir, 'primary_%s_%s_visible_bed_%s' % (output_id, spec, spec)), 'wb+')
for i, m in enumerate(maf_reader):
block_num += 1
if "None" not in species:
m = m.limit_to_species(species)
l = m.components
if len(l) < num_species and partial == "partial_disallowed":
continue
for c in l:
spec, chrom = maf.src_split(c.src)
if not spec or not chrom:
spec = chrom = c.src
if spec not in out_files.keys():
out_files[spec] = open(os.path.join(database_tmp_dir, 'primary_%s_%s_visible_bed_%s' % (output_id, spec, spec)), 'wb+')
if c.strand == "-":
out_files[spec].write(chrom + "\t" + str(c.src_size - c.end) + "\t" + str(c.src_size - c.start) + "\t" + spec + "_" + str(block_num) + "\t" + "0\t" + c.strand + "\n")
else:
out_files[spec].write(chrom + "\t" + str(c.start) + "\t" + str(c.end) + "\t" + spec + "_" + str(block_num) + "\t" + "0\t" + c.strand + "\n")
if c.strand == "-":
out_files[spec].write(chrom + "\t" + str(c.src_size - c.end) + "\t" + str(c.src_size - c.start) + "\t" + spec + "_" + str(block_num) + "\t" + "0\t" + c.strand + "\n")
else:
out_files[spec].write(chrom + "\t" + str(c.start) + "\t" + str(c.end) + "\t" + spec + "_" + str(block_num) + "\t" + "0\t" + c.strand + "\n")
file_in.close()
for file_out in out_files.keys():
out_files[file_out].close()
+1 -1
View File
@@ -22,7 +22,7 @@
</outputs>
<tests>
<test>
<param name="input1" value="4.maf"/>
<param name="input1" value="4.maf" ftype="maf"/>
<param name="species" value="hg17"/>
<param name="complete_blocks" value="partial_disallowed"/>
<output name="out_file1" file="cf_maf_to_bed.dat"/>
+3 -1
View File
@@ -6,6 +6,7 @@ Read a maf and output a multiple block fasta file.
from __future__ import print_function
import sys
from collections import OrderedDict
from bx.align import maf
@@ -51,7 +52,8 @@ def __main__():
spec_counts[spec] = 0
else:
spec_counts[spec] += 1
file_out.write("%s\n" % maf_utilities.get_fasta_header(component, {'block_index': block_num, 'species': spec, 'sequence_index': spec_counts[spec]}, suffix="%s_%i_%i" % (spec, block_num, spec_counts[spec])))
d = OrderedDict([('block_index', block_num), ('species', spec), ('sequence_index', spec_counts[spec])])
file_out.write("%s\n" % maf_utilities.get_fasta_header(component, d, suffix="%s_%i_%i" % (spec, block_num, spec_counts[spec])))
file_out.write("%s\n" % component.text)
file_out.write("\n")
file_out.close()
+2 -2
View File
@@ -35,9 +35,9 @@ def __main__():
all_species.sort()
for spec in species:
if spec == primary_spec:
out_files[spec] = open(output_filename, 'wb+')
out_files[spec] = open(output_filename, 'w+')
else:
out_files[spec] = open(os.path.join(database_tmp_dir, 'primary_%s_%s_visible_interval_%s' % (output_id, spec, spec)), 'wb+')
out_files[spec] = open(os.path.join(database_tmp_dir, 'primary_%s_%s_visible_interval_%s' % (output_id, spec, spec)), 'w+')
out_files[spec].write('#chrom\tstart\tend\tstrand\tscore\tname\t%s\n' % ('\t'.join(all_species)))
num_species = len(all_species)
+1 -1
View File
@@ -26,7 +26,7 @@
</outputs>
<tests>
<test>
<param name="input1" value="4.maf" dbkey="hg17"/>
<param name="input1" value="4.maf" dbkey="hg17" ftype="maf"/>
<param name="complete_blocks" value="partial_disallowed"/>
<param name="remove_gaps" value="keep_gaps"/>
<param name="species" value="panTro1" />
+4 -4
View File
@@ -46,9 +46,9 @@
<param name="input2" value="fr.qualsolid" ftype="qualsolid" />
<param name="paired" value="no"/>
<param name="qual" value="0" />
<param name="trim_first_base" value="No" />
<param name="trim_first_base" value="No (bowtie)" />
<param name="trim_name" value="No" />
<param name="double_encode" value="No"/>
<param name="double_encode" value="No (bowtie)"/>
<output name="out_file1" file="solid2fastq_out_1.fastq"/>
</test>
<test>
@@ -58,9 +58,9 @@
<param name="input3" value="rr.csfasta" ftype="csfasta"/>
<param name="input4" value="rr.qualsolid" ftype="qualsolid" />
<param name="qual" value="0" />
<param name="trim_first_base" value="No" />
<param name="trim_first_base" value="No (bowtie)" />
<param name="trim_name" value="Yes" />
<param name="double_encode" value="No"/>
<param name="double_encode" value="No (bowtie)"/>
<output name="out_file1" file="solid2fastq_out_2.fastq"/>
<output name="out_file2" file="solid2fastq_out_3.fastq"/>
</test>
+5 -3
View File
@@ -1,8 +1,10 @@
<tool id="hgv_ldtools" name="LD" version="1.0.0">
<description>linkage disequilibrium and tag SNPs</description>
<command interpreter="bash">
ldtools_wrapper.sh rsquare=$rsquare freq=$freq input=$input output=$output
<requirements>
<requirement type="package" version="2.7">python</requirement>
</requirements>
<command detect_errors="exit_code">
'$__tool_directory__/ldtools_wrapper.sh' rsquare=$rsquare freq=$freq input='$input' output='$output'
</command>
<inputs>
@@ -5,7 +5,7 @@
set -e
export PATH=$PATH:$(dirname $0)
SCRIPT_DIR=$(dirname $0)
## pagetag options
input=
@@ -46,19 +46,16 @@ do
done
## run pagetag
pagetag.py --rsquare $rsquare --freq $freq $input snps.txt neighborhood.txt &> /dev/null
python $SCRIPT_DIR/pagetag.py --rsquare $rsquare --freq $freq "$input" snps.txt neighborhood.txt
if [ $? -ne 0 ]; then
echo "failed: pagetag.py --rsquare $rsquare --freq $freq $input snps.txt neighborhood.txt"
echo "failed: pagetag.py --rsquare $rsquare --freq $freq \"$input\" snps.txt neighborhood.txt"
exit 1
fi
## run sentag
senatag.py neighborhood.txt snps.txt > $output 2> /dev/null
python $SCRIPT_DIR/senatag.py neighborhood.txt snps.txt > "$output"
if [ $? -ne 0 ]; then
echo "failed: senatag.py neighborhood.txt snps.txt"
exit 1
fi
## cleanup
rm -f snps.txt neighborhood.txt
@@ -77,7 +77,7 @@ if (@pos) { $params{"region_query"} = 1; }
open(FH, ">", $out) or die "Couldn't open $out, $!\n";
print FH "<html><head><title>g:Profiler link</title></head><body>\n";
print FH '<form method="POST" action="http://biit.cs.ut.ee/gprofiler/index.cgi">';
print FH '<form method="POST" action="http://biit.cs.ut.ee/gprofiler/index.cgi">', "\n";
foreach my $k (keys %params) {
print FH "<input type='hidden' name='$k' value='$params{$k}'>\n";
}
@@ -1,8 +1,8 @@
<tool id="hgv_linkToGProfile" name="g:Profiler" version="1.0.0">
<description>tools for functional profiling of gene lists</description>
<command interpreter="perl">
linkToGProfile.pl $input $type $out_file1 -region=$region -gene=$genes -chr=${input.metadata.chromCol} -start=${input.metadata.startCol} -end=${input.metadata.endCol}
<command detect_errors="exit_code">
perl '$__tool_directory__/linkToGProfile.pl' '$input' $type '$out_file1' -region='$region' -gene=$genes -chr=${input.metadata.chromCol} -start=${input.metadata.startCol} -end=${input.metadata.endCol}
</command>
<inputs>
@@ -34,10 +34,10 @@
<tests>
<test>
<param name="input" ftype="tabular" value="linkToGProfile.tabular" />
<param name="input" ftype="bed" value="linkToGProfile.tabular" />
<param name="genes" value="2" />
<param name="type" value="ENTREZGENE_ACC" />
<output name="out_file1" file="linkToGProfile_1.out" />
<param name="type" value="Entrez Gene Acc" />
<output name="out_file1" file="linkToGProfile_1.out" sort="true"/>
</test>
</tests>
+11 -3
View File
@@ -25,6 +25,7 @@ from __future__ import print_function
import heapq
import os
from functools import total_ordering
from getopt import getopt, GetoptError
from sys import argv, exit, stderr
@@ -35,6 +36,7 @@ __email__ = "ratan@bx.psu.edu"
debug_flag = False
@total_ordering
class node:
def __init__(self, name):
self.name = name
@@ -50,8 +52,14 @@ class node:
num += 1
return num
def __cmp__(self, other):
return other.num_not_visited() - self.num_not_visited()
def __eq__(self, other):
return self.num_not_visited() == other.num_not_visited()
def __ne__(self, other):
return not (self == other)
def __lt__(self, other):
return other.num_not_visited() < self.num_not_visited()
def __str__(self):
return self.name
@@ -165,7 +173,7 @@ def main(ldfile, snpsfile, required, excluded):
neighbors[t.name] = list(set(ns))
# find the tag SNPs for this graph
data = g.nodes.values()[:]
data = list(g.nodes.values())[:]
heapq.heapify(data)
while data:
+4 -4
View File
@@ -1,8 +1,8 @@
<tool id="qual_stats_boxplot" name="Boxplot" version="1.0.0">
<tool id="qual_stats_boxplot" name="Boxplot" version="1.0.1">
<description>of quality statistics</description>
<command>gnuplot &lt; '$gnuplot_commands' 2&gt;&amp;1 || echo "Error running gnuplot." >&amp;2</command>
<requirements>
<requirement type="package" version="4.6">gnuplot</requirement>
<requirement type="package" version="5.2.3">gnuplot</requirement>
</requirements>
<inputs>
<param name="input_file" type="data" format="tabular" label="Quality Statistics File"/>
@@ -44,7 +44,7 @@ set offsets 1, 1, 1, 1
plot '${input_file}' using ${xcol}:${q1col}:${lwcol}:${rwcol}:${q3col} with candlesticks lt 1 lw 1 title 'Quartiles' whiskerbars, \
'' using ${xcol}:${medcol}:${medcol}:${medcol}:${medcol} with candlesticks lt -1 lw 2 title 'Medians'\
#if str( $use_outliers['use_outliers_type'] ) == 'use_outliers':
, "&lt; python -c \"for xval, yvals in [ ( fields[${xcol} - 1], fields[${use_outliers['outliercol']} - 1].split( ',' ) ) for fields in [ line.rstrip( '\\n\\r' ).split( '\\t' ) for line in open( '${input_file}' ) if not line.startswith( '#' ) ] if len( fields ) &gt; max( ${xcol} - 1, ${use_outliers['outliercol']} - 1 ) ]: print '\\n'.join( [ '%s\\t%s' % ( xval, yval ) for yval in yvals if yval ] )\"" using 1:2 with points pt 29 title 'Outliers'
, "&lt; python -c \"for xval, yvals in [ ( fields[${xcol} - 1], fields[${use_outliers['outliercol']} - 1].split( ',' ) ) for fields in [ line.rstrip( '\\n\\r' ).split( '\\t' ) for line in open( '${input_file}' ) if not line.startswith( '#' ) ] if len( fields ) &gt; max( ${xcol} - 1, ${use_outliers['outliercol']} - 1 ) ]: print('\\n'.join( [ '%s\\t%s' % ( xval, yval ) for yval in yvals if yval ] ))\"" using 1:2 with points pt 29 title 'Outliers'
#end if
</configfile>
</configfiles>
@@ -66,7 +66,7 @@ plot '${input_file}' using ${xcol}:${q1col}:${lwcol}:${rwcol}:${q3col} with cand
<param name="rwcol" value="12" />
<param name="use_outliers_type" value="use_outliers" />
<param name="outliercol" value="13" />
<output name="output_file" file="boxplot_summary_statistics_out.png" />
<output name="output_file" file="boxplot_summary_statistics_out.png" compare="sim_size"/>
</test>
</tests>
<help>
+92 -91
View File
@@ -26,109 +26,110 @@ def unzip(filename):
def __main__():
infile_score_name = sys.argv[1].strip()
fout = open(sys.argv[2].strip(), 'r+w')
with open(sys.argv[2].strip(), 'w') as fout:
if zipfile.is_zipfile(infile_score_name):
infile_name = unzip(infile_score_name)
else:
infile_name = infile_score_name
if zipfile.is_zipfile(infile_score_name):
infile_name = unzip(infile_score_name)
else:
infile_name = infile_score_name
readlen = None
invalid_lines = 0
j = 0
for line in open(infile_name):
line = line.strip()
if not(line) or line.startswith("#") or line.startswith(">"):
continue
elems = line.split()
try:
for item in elems:
int(item)
if not readlen:
readlen = len(elems)
if len(elems) != readlen:
print("Note: Reads in the input dataset are of variable lengths.")
j += 1
except ValueError:
invalid_lines += 1
if j > 10:
break
readlen = None
invalid_lines = 0
j = 0
with open(infile_name) as fin:
for line in fin:
line = line.strip()
if not(line) or line.startswith("#") or line.startswith(">"):
continue
elems = line.split()
try:
for item in elems:
int(item)
if not readlen:
readlen = len(elems)
if len(elems) != readlen:
print("Note: Reads in the input dataset are of variable lengths.")
j += 1
except ValueError:
invalid_lines += 1
if j > 10:
break
position_dict = {}
print("column\tcount\tmin\tmax\tsum\tmean\tQ1\tmed\tQ3\tIQR\tlW\trW", file=fout)
for k, line in enumerate(open(infile_name)):
line = line.strip()
if not(line) or line.startswith("#") or line.startswith(">"):
continue
elems = line.split()
if position_dict == {}:
for pos in range(readlen):
position_dict[pos] = [0] * QUAL_UPPER_BOUND
if len(elems) != readlen:
invalid_lines += 1
continue
for ind, item in enumerate(elems):
try:
item = int(item)
position_dict[ind][item] += 1
except Exception:
pass
position_dict = {}
print("column\tcount\tmin\tmax\tsum\tmean\tQ1\tmed\tQ3\tIQR\tlW\trW", file=fout)
for k, line in enumerate(open(infile_name)):
line = line.strip()
if not(line) or line.startswith("#") or line.startswith(">"):
continue
elems = line.split()
if position_dict == {}:
for pos in range(readlen):
position_dict[pos] = [0] * QUAL_UPPER_BOUND
if len(elems) != readlen:
invalid_lines += 1
continue
for ind, item in enumerate(elems):
try:
item = int(item)
position_dict[ind][item] += 1
except Exception:
pass
invalid_positions = 0
for pos in position_dict:
carr = position_dict[pos] # count array for position pos
total = sum(carr) # number of bases found in this column.
med_elem = int(round(total / 2.0))
lowest = None # Lowest quality score value found in this column.
highest = None # Highest quality score value found in this column.
median = None # Median quality score value found in this column.
qsum = 0.0 # Sum of quality score values for this column.
q1 = None # 1st quartile quality score.
q3 = None # 3rd quartile quality score.
q1_elem = int(round((total + 1) / 4.0))
q3_elem = int(round((total + 1) * 3 / 4.0))
invalid_positions = 0
for pos in position_dict:
carr = position_dict[pos] # count array for position pos
total = sum(carr) # number of bases found in this column.
med_elem = int(round(total / 2.0))
lowest = None # Lowest quality score value found in this column.
highest = None # Highest quality score value found in this column.
median = None # Median quality score value found in this column.
qsum = 0.0 # Sum of quality score values for this column.
q1 = None # 1st quartile quality score.
q3 = None # 3rd quartile quality score.
q1_elem = int(round((total + 1) / 4.0))
q3_elem = int(round((total + 1) * 3 / 4.0))
try:
for ind, cnt in enumerate(carr):
qsum += ind * cnt
try:
for ind, cnt in enumerate(carr):
qsum += ind * cnt
if cnt != 0:
highest = ind
if cnt != 0:
highest = ind
if lowest is None and cnt != 0: # first non-zero count
lowest = ind
if lowest is None and cnt != 0: # first non-zero count
lowest = ind
if q1 is None:
if sum(carr[:ind + 1]) >= q1_elem:
q1 = ind
if q1 is None:
if sum(carr[:ind + 1]) >= q1_elem:
q1 = ind
if median is None:
if sum(carr[:ind + 1]) < med_elem:
continue
median = ind
if total % 2 == 0: # even number of elements
median2 = median
if sum(carr[:ind + 1]) < med_elem + 1:
for ind2, elem in enumerate(carr[ind + 1:]):
if elem != 0:
median2 = ind + ind2 + 1
break
median = (median + median2) / 2.0
if median is None:
if sum(carr[:ind + 1]) < med_elem:
continue
median = ind
if total % 2 == 0: # even number of elements
median2 = median
if sum(carr[:ind + 1]) < med_elem + 1:
for ind2, elem in enumerate(carr[ind + 1:]):
if elem != 0:
median2 = ind + ind2 + 1
break
median = (median + median2) / 2.0
if q3 is None:
if sum(carr[:ind + 1]) >= q3_elem:
q3 = ind
if q3 is None:
if sum(carr[:ind + 1]) >= q3_elem:
q3 = ind
mean = qsum / total # Mean quality score value for this column.
iqr = q3 - q1
left_whisker = max(q1 - 1.5 * iqr, lowest)
right_whisker = min(q3 + 1.5 * iqr, highest)
mean = qsum / total # Mean quality score value for this column.
iqr = q3 - q1
left_whisker = max(q1 - 1.5 * iqr, lowest)
right_whisker = min(q3 + 1.5 * iqr, highest)
print("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (pos + 1, total, lowest, highest, qsum, mean, q1, median, q3, iqr, left_whisker, right_whisker), file=fout)
except Exception:
invalid_positions += 1
nullvals = ['NA'] * 11
print("%s\t%s" % (pos + 1, '\t'.join(nullvals)), file=fout)
print("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (pos + 1, total, lowest, highest, qsum, mean, q1, median, q3, iqr, left_whisker, right_whisker), file=fout)
except Exception:
invalid_positions += 1
nullvals = ['NA'] * 11
print("%s\t%s" % (pos + 1, '\t'.join(nullvals)), file=fout)
if invalid_lines:
print("Skipped %d reads as invalid." % invalid_lines)
+3 -3
View File
@@ -1,7 +1,7 @@
<tool id="solid_qual_stats" name="Compute quality statistics" version="1.0.0">
<description>for SOLiD data</description>
<command interpreter="python">solid_qual_stats.py $input $output1</command>
<command>
python '$__tool_directory__/solid_qual_stats.py' '$input' '$output1'</command>
<inputs>
<param format="qualsolid" name="input" type="data" label="SOLiD qual file" help="If your dataset doesn't show up in the menu, click the pencil icon next to your dataset and set the datatype to 'qualsolid'" />
</inputs>
@@ -11,7 +11,7 @@
<tests>
<test>
<param name="input" value="qualscores.qualsolid" />
<output name="output1" file="qualsolid.stats" />
<output name="output1" file="qualsolid.stats" compare="sim_size" />
</test>
</tests>
@@ -38,6 +38,7 @@ python '$__tool_directory__/aggregate_scores_in_intervals.py'
<data format="interval" name="out_file1" metadata_source="input1"/>
</outputs>
<tests>
<!-- no clue where to find the 'datasets' files
<test>
<param name="input1" value="6.bed" dbkey="hg17" ftype="bed"/>
<param name="score_source" value="cached"/>
@@ -50,11 +51,12 @@ python '$__tool_directory__/aggregate_scores_in_intervals.py'
<param name="datasets" value="/galaxy/data/binned_scores/hg18/phastCons17way/ba" />
<output name="out_file1" file="aggregate_binned_scores_in_intervals2.interval" />
</test>
-->
<test>
<param name="input1" value="6.bed" dbkey="hg17" ftype="bed"/>
<param name="score_source" value="user"/>
<param name="input2" value="aggregate_binned_scores_3.wig" dbkey="hg17" ftype="wig"/>
<output name="out_file1" file="aggregate_binned_scores_in_intervals3.out"/>
<output name="out_file1" file="aggregate_binned_scores_in_intervals3.out" lines_diff="2"/>
</test>
</tests>
<help>
+1 -1
View File
@@ -72,7 +72,7 @@ def main():
except Exception:
stop_err("Group column not specified.")
tmpfile = tempfile.NamedTemporaryFile()
tmpfile = tempfile.NamedTemporaryFile(mode='r')
try:
"""
+2 -2
View File
@@ -1,10 +1,10 @@
<tool id="Summary_Statistics1" name="Summary Statistics" version="1.1.1">
<tool id="Summary_Statistics1" name="Summary Statistics" version="1.1.2">
<description>for any numerical column</description>
<edam_topics>
<edam_topic>topic_2269</edam_topic>
</edam_topics>
<requirements>
<requirement type="package" version="2.7.8">rpy2</requirement>
<requirement type="package" version="2.9.4">rpy2</requirement>
</requirements>
<stdio>
<exit_code range="1" level="fatal" />