diff replace_chromosome_names.py @ 1:6c0373cc070f draft default tip

planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/replace_chromosome_names/ commit c8418d1d7657dacae7f81fe4aa0aba051873d4ad
author earlhaminst
date Tue, 13 Jun 2017 14:43:07 -0400
parents 97c11d04cd4c
children
line wrap: on
line diff
--- a/replace_chromosome_names.py	Thu May 18 14:17:48 2017 -0400
+++ b/replace_chromosome_names.py	Tue Jun 13 14:43:07 2017 -0400
@@ -32,9 +32,14 @@
             line_cols = line.split('\t')
             for col_to_map in cols_to_map:
                 old_value = line_cols[col_to_map]
-                line_cols[col_to_map] = map_dict.get(old_value, old_value)
-            mapped_line = '\t'.join(line_cols)
-            print(mapped_line, file=args.output)
+                new_value = map_dict.get(old_value, '')
+                if not new_value:
+                    print('%s has no valid mapping, skipping line: %s' % (old_value, line), file=sys.stderr)
+                    break
+                line_cols[col_to_map] = new_value
+            else:
+                mapped_line = '\t'.join(line_cols)
+                print(mapped_line, file=args.output)
 
 
 if __name__ == "__main__":