From 39f811eff7f29b42b397d44fa24fbc8b5f69d610 Mon Sep 17 00:00:00 2001 From: Greg Von Kuster Date: Mon, 7 May 2007 18:59:15 +0000 Subject: [PATCH] Added new Subtract Whole Query tool. Also some miscellaneous code clean-up. --- test-data/1.txt | 10 +++ tool_conf.xml.sample | 3 +- tools/data_source/upload_code.py | 11 ---- tools/filters/compare.xml | 2 +- tools/new_operations/subtract_query.py | 45 ++++++++++++++ tools/new_operations/subtract_query.xml | 82 +++++++++++++++++++++++++ 6 files changed, 140 insertions(+), 13 deletions(-) create mode 100644 test-data/1.txt delete mode 100644 tools/data_source/upload_code.py create mode 100644 tools/new_operations/subtract_query.py create mode 100644 tools/new_operations/subtract_query.xml diff --git a/test-data/1.txt b/test-data/1.txt new file mode 100644 index 00000000000..9e8397bcbd6 --- /dev/null +++ b/test-data/1.txt @@ -0,0 +1,10 @@ +chr1 4225 19670 +chr10 6 8 +chr1 24417 24420 +chr6_hla_hap2 0 150 +chr2 1 5 +chr10 2 10 +chr1 30 55 +chrY 1 20 +chr1 1225979 42287290 +chr10 7 8 diff --git a/tool_conf.xml.sample b/tool_conf.xml.sample index 9b5b8e886d8..ad5f815b8dc 100644 --- a/tool_conf.xml.sample +++ b/tool_conf.xml.sample @@ -42,12 +42,13 @@ -
+
+
diff --git a/tools/data_source/upload_code.py b/tools/data_source/upload_code.py deleted file mode 100644 index 0bdf2e3b0af..00000000000 --- a/tools/data_source/upload_code.py +++ /dev/null @@ -1,11 +0,0 @@ -#Provides Upload tool with access to list of available builds -import galaxy.util -builds = [] - -#Read build names and keys from galaxy.util -for dbkey, build_name in galaxy.util.dbnames: - builds.append((build_name,dbkey,False)) - -#Return available builds -def get_available_builds(): - return builds diff --git a/tools/filters/compare.xml b/tools/filters/compare.xml index b6eda4809cd..ec87a8aa724 100644 --- a/tools/filters/compare.xml +++ b/tools/filters/compare.xml @@ -65,7 +65,7 @@ Finding lines of the **First query** whose 4th column matching the 1st column of chr1 10 20 geneA chr1 50 80 geneB -Converesely, using options **Non Matching rows of First query** on same fields will yield:: +Conversely, using options **Non Matching rows of First query** on same fields will yield:: chr5 10 40 geneL diff --git a/tools/new_operations/subtract_query.py b/tools/new_operations/subtract_query.py new file mode 100644 index 00000000000..ff7fa458978 --- /dev/null +++ b/tools/new_operations/subtract_query.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python2.4 +# Greg Von Kuster + +""" +Subtract an entire query from another query +usage: %prog in_file_1 in_file_2 out_file +""" + +import sys, sets +import cookbook.doc_optparse + + +def get_lines(fname): + lines = set([]) + for i, line in enumerate(file(fname)): + line = line.strip() + lines.add( line ) + return lines + +def main(): + # Parsing Command Line here + options, args = cookbook.doc_optparse.parse( __doc__ ) + + try: + inp1_file, inp2_file, out_file = args + except: + cookbook.doc_optparse.exception() + + try: + fo = open(out_file,'w') + except: + print >> sys.stderr, "Unable to open output file" + sys.exit() + + lines1 = get_lines(inp1_file) + lines2 = get_lines(inp2_file) + lines1.difference_update(lines2) + + for line in lines1: + print >> fo, line + + fo.close() + +if __name__ == "__main__": + main() diff --git a/tools/new_operations/subtract_query.xml b/tools/new_operations/subtract_query.xml new file mode 100644 index 00000000000..758785613d9 --- /dev/null +++ b/tools/new_operations/subtract_query.xml @@ -0,0 +1,82 @@ + + from another query + subtract_query.py $input1 $input2 $output + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +.. class:: infomark + +**TIP:** This tool complements the tool in the **Operate on Genomic Intervals** tool set which subtracts the intervals of two queries. + + +----- + +**Syntax** + +This tool subtracts an entire query from another query. Any text format is valid. + +----- + +**Example** + +If this is the **First query**:: + + chr1 4225 19670 + chr10 6 8 + chr1 24417 24420 + chr6_hla_hap2 0 150 + chr2 1 5 + chr10 2 10 + chr1 30 55 + chrY 1 20 + chr1 1225979 42287290 + chr10 7 8 + +and this is the **Second query**:: + + chr1 4225 19670 + chr10 6 8 + chr1 24417 24420 + chr6_hla_hap2 0 150 + chr2 1 5 + chr1 30 55 + chrY 1 20 + chr1 1225979 42287290 + +Subtracting the **Second query** from the **First query** will yield:: + + chr10 7 8 + chr10 2 10 + +Conversely, subtracting the **First query** from the **Second query** will result in an empty dataset. + + + \ No newline at end of file