fix permissions and bugs, use decompressed_name in output
authorTom Clegg <tom@clinicalfuture.com>
Tue, 25 Jun 2013 15:57:20 +0000 (11:57 -0400)
committerTom Clegg <tom@clinicalfuture.com>
Tue, 25 Jun 2013 20:52:01 +0000 (16:52 -0400)
crunch_scripts/grep [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 6392e0c..908cea2
@@ -1,20 +1,21 @@
 #!/usr/bin/env python
 
 import arvados
+import string
 
 arvados.job_setup.one_task_per_input_file(if_sequence=0, and_end_task=True)
 
 this_job = arvados.current_job()
 this_task = arvados.current_task()
 this_task_input = this_task['parameters']['input']
-search_string = this_task['parameters']['pattern']
+search_string = this_job['script_parameters']['pattern']
 
 input_file = list(arvados.CollectionReader(this_task_input).all_files())[0]
 out = arvados.CollectionWriter()
-out.set_current_file_name(input_file.name())
+out.set_current_file_name(input_file.decompressed_name())
 out.set_current_stream_name(input_file.stream_name())
 for line in input_file.readlines():
-    if string.find(line, search_string):
+    if 0 <= string.find(line, search_string):
         out.write(line)
 
 this_task.set_output(out.finish())