# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User jeremy goecks jeremy.goecks@emory.edu # Date 1283373340 14400 # Node ID f205636ed466f490a081681e76b23196dbc80e7c # Parent 2ba0fe1297a8a31f99c412f05046ec7c2f749798 Improved error checking for condition provided to tool 'gff_filter_by_feature_count.
--- a/tools/filters/gff/gff_filter_by_feature_count.py +++ b/tools/filters/gff/gff_filter_by_feature_count.py @@ -11,14 +11,25 @@ from galaxy.tools.util.gff_util import p
assert sys.version_info[:2] >= ( 2, 4 )
+# Valid operators, ordered so that complex operators (e.g. '>=') are +# recognized before simple operators (e.g. '>') +ops = [ + '>=', + '<=', + '<', + '>', + '==', + '!=' +] + # Escape sequences for valid operators. mapped_ops = { - '__lt__': '<', - '__le__': '<=', - '__eq__': '==', - '__ne__': '!=', - '__gt__': '>', - '__ge__': '>=', + '__ge__': ops[0], + '__le__': ops[1], + '__lt__': ops[2], + '__gt__': ops[3], + '__eq__': ops[4], + '__ne__': ops[5], }
@@ -34,7 +45,7 @@ def __main__(): condition = condition.replace( key, value )
# Error checking: condition should be of the form <operator><number> - for op in mapped_ops.itervalues(): + for op in ops: if op in condition: empty, number_str = condition.split( op ) try: @@ -44,6 +55,7 @@ def __main__(): if empty != "" or not number: print >> sys.stderr, "Invalid condition: %s, cannot filter." % condition return + break
# Do filtering. kept_lines = 0
galaxy-commits@lists.galaxyproject.org