diff dexseq_helper.py @ 0:276833129f97 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dexseq commit eecb633ff51d61e8f94f580bb96053434029ab78-dirty
author iuc
date Thu, 24 Sep 2015 17:16:56 -0400
parents
children 28a2181df3b9
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dexseq_helper.py	Thu Sep 24 17:16:56 2015 -0400
@@ -0,0 +1,41 @@
+
+from galaxy.tools.parameters import DataToolParameter
+
+def validate_input( trans, error_map, param_values, page_param_map ):
+    """
+        Validates the user input, before execution.
+    """
+    factors = param_values['rep_factorName']
+    factor_name_list = []
+    factor_duplication = False
+    level_duplication = False
+
+    for factor in factors:
+        # factor names should be unique
+        fn = factor['factorName']
+        if fn in factor_name_list:
+            factor_duplication = True
+            break
+        factor_name_list.append( fn )
+
+        level_name_list = list()
+        factor_index_list = list()
+
+        for level in factor['rep_factorLevel']:
+            # level names under one factor should be unique
+            fl = level['factorLevel']
+            if fl in level_name_list:
+                level_duplication = True
+            level_name_list.append( fl )
+
+        if level_duplication:
+            error_map['rep_factorName'] = [ dict() for t in factors ]
+            for i in range( len( factors ) ):
+                error_map['rep_factorName'][i]['rep_factorLevel'] = [ {'factorLevel': 'Factor levels for each factor need to be unique'} for t in factor['rep_factorLevel'] ]
+            break
+
+    if factor_duplication:
+        error_map['rep_factorName'] = [ dict() for t in factors ]
+        for i in range( len( factors ) ):
+            error_map['rep_factorName'][i]['factorName'] = 'Factor names need to be unique.'
+