0
|
1 import pkg_resources; pkg_resources.require( "bx-python" )
|
|
2 from bx.align import maf
|
|
3 from galaxy import datatypes, config, jobs
|
|
4 from shutil import move
|
|
5
|
|
6 def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr):
|
|
7 output_data = out_data.items()[0][1]
|
|
8 history = output_data.history
|
|
9 if history == None:
|
|
10 print "unknown history!"
|
|
11 return
|
|
12 new_stdout = ""
|
|
13 split_stdout = stdout.split("\n")
|
|
14 basic_name = output_data.name
|
|
15 output_data_list = []
|
|
16 for line in split_stdout:
|
|
17 if line.startswith("#FILE1"):
|
|
18 fields = line.split("\t")
|
|
19 dbkey = fields[1]
|
|
20 filepath = fields[2]
|
|
21 output_data.dbkey = dbkey
|
|
22 output_data.name = basic_name + " (" + dbkey + ")"
|
|
23 app.model.context.add( output_data )
|
|
24 app.model.context.flush()
|
|
25 output_data_list.append(output_data)
|
|
26 elif line.startswith("#FILE"):
|
|
27 fields = line.split("\t")
|
|
28 dbkey = fields[1]
|
|
29 filepath = fields[2]
|
|
30 newdata = app.model.HistoryDatasetAssociation( create_dataset = True, sa_session = app.model.context )
|
|
31 newdata.set_size()
|
|
32 newdata.extension = "bed"
|
|
33 newdata.name = basic_name + " (" + dbkey + ")"
|
|
34 app.model.context.add( newdata )
|
|
35 app.model.context.flush()
|
|
36 history.add_dataset( newdata )
|
|
37 app.security_agent.copy_dataset_permissions( output_data.dataset, newdata.dataset )
|
|
38 app.model.context.add( history )
|
|
39 app.model.context.flush()
|
|
40 try:
|
|
41 move(filepath,newdata.file_name)
|
|
42 newdata.info = newdata.name
|
|
43 newdata.state = newdata.states.OK
|
|
44 except:
|
|
45 newdata.info = "The requested file is missing from the system."
|
|
46 newdata.state = newdata.states.ERROR
|
|
47 newdata.dbkey = dbkey
|
|
48 newdata.init_meta()
|
|
49 newdata.set_meta()
|
|
50 newdata.set_peek()
|
|
51 app.model.context.flush()
|
|
52 output_data_list.append(newdata)
|
|
53 else:
|
|
54 new_stdout = new_stdout + line
|
|
55 for data in output_data_list:
|
|
56 if data.state == data.states.OK:
|
|
57 data.info = new_stdout
|
|
58 app.model.context.add( data )
|
|
59 app.model.context.flush()
|