Mercurial > repos > devteam > subtract_query
changeset 1:960d5d114184 draft
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/subtract_query commit a1517c9d22029095120643bbe2c8fa53754dd2b7
author | devteam |
---|---|
date | Wed, 11 Nov 2015 12:49:38 -0500 |
parents | 5f6ebef89722 |
children | ff3901618482 |
files | subtract_query.py tool_dependencies.xml |
diffstat | 2 files changed, 21 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/subtract_query.py Tue Apr 01 10:51:41 2014 -0400 +++ b/subtract_query.py Wed Nov 11 12:49:38 2015 -0500 @@ -6,7 +6,7 @@ usage: %prog in_file_1 in_file_2 begin_col end_col output --ignore-empty-end-cols: ignore empty end columns when subtracting """ -import sys, re +import sys from bx.cookbook import doc_optparse # Older py compatibility @@ -17,6 +17,7 @@ assert sys.version_info[:2] >= ( 2, 4 ) + def get_lines(fname, begin_col='', end_col='', ignore_empty_end_cols=False): lines = set([]) i = 0 @@ -27,22 +28,25 @@ """Both begin_col and end_col must be integers at this point.""" try: line = line.split('\t') - line = '\t'.join([line[j] for j in range(begin_col-1, end_col)]) + line = '\t'.join([line[j] for j in range(begin_col - 1, end_col)]) if ignore_empty_end_cols: # removing empty fields, we do not compare empty fields at the end of a line. line = line.rstrip() lines.add( line ) - except: pass + except: + pass else: if ignore_empty_end_cols: # removing empty fields, we do not compare empty fields at the end of a line. line = line.rstrip() lines.add( line ) - if i: return (i+1, lines) - else: return (i, lines) + if i: + return (i + 1, lines) + else: + return (i, lines) + def main(): - # Parsing Command Line here options, args = doc_optparse.parse( __doc__ ) @@ -50,10 +54,10 @@ inp1_file, inp2_file, begin_col, end_col, out_file = args except: doc_optparse.exception() - + begin_col = begin_col.strip() end_col = end_col.strip() - + if begin_col != 'None' or end_col != 'None': """ The user selected columns for restriction. We'll allow default @@ -75,7 +79,7 @@ begin_col = end_col = '' try: - fo = open(out_file,'w') + fo = open(out_file, 'w') except: print >> sys.stderr, "Unable to open output file" sys.exit() @@ -88,7 +92,7 @@ len1, lines1 = get_lines(inp1_file, begin_col, end_col, options.ignore_empty_end_cols) diff1 = len1 - len(lines1) len2, lines2 = get_lines(inp2_file, begin_col, end_col, options.ignore_empty_end_cols) - + lines1.difference_update(lines2) """lines1 is now the set of unique lines in inp1_file - the set of unique lines in inp2_file""" @@ -96,15 +100,15 @@ print >> fo, line fo.close() - - info_msg = 'Subtracted %d lines. ' %((len1 - diff1) - len(lines1)) - + + info_msg = 'Subtracted %d lines. ' % ((len1 - diff1) - len(lines1)) + if begin_col and end_col: info_msg += 'Restricted to columns c' + str(begin_col) + ' thru c' + str(end_col) + '. ' if diff1 > 0: - info_msg += 'Eliminated %d duplicate/blank/comment/invalid lines from first query.' %diff1 - + info_msg += 'Eliminated %d duplicate/blank/comment/invalid lines from first query.' % diff1 + print info_msg if __name__ == "__main__":
--- a/tool_dependencies.xml Tue Apr 01 10:51:41 2014 -0400 +++ b/tool_dependencies.xml Wed Nov 11 12:49:38 2015 -0500 @@ -1,9 +1,9 @@ <?xml version="1.0"?> <tool_dependency> <package name="bx-python" version="0.7.1"> - <repository changeset_revision="41eb9d9f667d" name="package_bx_python_0_7" owner="devteam" prior_installation_required="False" toolshed="http://toolshed.g2.bx.psu.edu" /> + <repository changeset_revision="2d0c08728bca" name="package_bx_python_0_7" owner="devteam" toolshed="https://toolshed.g2.bx.psu.edu" /> </package> <package name="galaxy-ops" version="1.0.0"> - <repository changeset_revision="4e39032e4ec6" name="package_galaxy_ops_1_0_0" owner="devteam" prior_installation_required="False" toolshed="http://toolshed.g2.bx.psu.edu" /> + <repository changeset_revision="9cbb20b85c01" name="package_galaxy_ops_1_0_0" owner="devteam" toolshed="https://toolshed.g2.bx.psu.edu" /> </package> </tool_dependency>