Metadata will now be set on all output datasets when getting encode data.

This commit is contained in:
Greg Von Kuster
2008-01-03 14:12:07 +00:00
parent 637c9f02c4
commit 05df900b3d
2 changed files with 65 additions and 71 deletions
+64 -67
View File
@@ -9,76 +9,73 @@ from shutil import copyfile
#tempfile, shutil
BUFFER = 1048576
uids = sys.argv[1].split(",")
out_file1 = sys.argv[2]
def stop_err( msg ):
sys.stderr.write( msg )
sys.exit()
#remove NONE from uids
have_none = True
while have_none:
try:
uids.remove('None')
except:
have_none = False
#create dictionary keyed by uid of tuples of (displayName,filePath,build) for all files
available_files = {}
try:
for line in open( "/depot/data2/galaxy/encode_datasets.loc" ):
if line[0:1] == "#" : continue
fields = line.split('\t')
#read each line, if not enough fields, go to next line
def main():
uids = sys.argv[1].split(",")
out_file1 = sys.argv[2]
file_name = "/depot/data2/galaxy/encode_datasets.loc"
#remove NONE from uids
have_none = True
while have_none:
try:
encode_group = fields[0]
build = fields[1]
description = fields[2]
uid = fields[3]
path = fields[4]
path = path.replace("\n","")
path = path.replace("\r","")
try:
file_type = fields[5]
#remove newlines from file type
file_type = file_type.replace("\n","")
file_type = file_type.replace("\r","")
except:
file_type = "bed"
uids.remove('None')
except:
have_none = False
#create dictionary keyed by uid of tuples of (displayName,filePath,build) for all files
available_files = {}
try:
for line in open( file_name ):
line = line.rstrip( '\r\n' )
if line and not line.startswith( '#' ):
fields = line.split( '\t' )
try:
encode_group = fields[0].strip()
build = fields[1].strip()
description = fields[2].strip()
uid = fields[3].strip()
path = fields[4].strip()
try:
file_type = fields[5].strip()
except:
file_type = "bed"
except:
continue
available_files[uid] = ( description, path, build, file_type )
except:
stop_err( "It appears that the configuration file for this tool is missing." )
#create list of tuples of ( displayName, FileName, build ) for desired files
desired_files = []
for uid in uids:
try:
desired_files.append( available_files[uid] )
except:
continue
available_files[uid]=(description,path,build,file_type)
except:
print >>sys.stderr, "It appears that the configuration file for this tool is missing."
#create list of tuples of (displayName,FileName,build) for desired files
desired_files = []
for uid in uids:
try:
desired_files.append(available_files[uid])
except:
continue
#copy first file to contents of given output file
file1_copied = False
while not file1_copied:
try:
first_file = desired_files.pop(0)
except:
print >>sys.stderr, "There were no valid files requested."
sys.exit()
file1_desc, file1_path, file1_build, file1_type = first_file
try:
copyfile(file1_path,out_file1)
print "#File1\t"+file1_desc+"\t"+file1_build+"\t"+file1_type
file1_copied = True
except:
print >>sys.stderr, "The file specified is missing."
continue
#print >>sys.stderr, "The file specified is missing."
#copy first file to contents of given output file
file1_copied = False
while not file1_copied:
try:
first_file = desired_files.pop(0)
except:
stop_err( "There were no valid files requested." )
file1_desc, file1_path, file1_build, file1_type = first_file
try:
copyfile( file1_path, out_file1 )
print "#File1\t" + file1_desc + "\t" + file1_build + "\t" + file1_type
file1_copied = True
except:
#print "The file '%s' is missing." %str( file1_path )
continue
#Tell post-process filter where remaining files reside
for extra_output in desired_files:
file_desc, file_path, file_build, file_type = extra_output
print "#NewFile\t" + file_desc + "\t" + file_build + "\t" + file_path + "\t" + file_type
#Tell post-process filter where remaining files reside
for extra_output in desired_files:
file_desc, file_path, file_build, file_type = extra_output
print "#NewFile\t"+file_desc+"\t"+file_build+"\t"+file_path+"\t"+file_type
if __name__ == "__main__": main()
+1 -4
View File
@@ -35,9 +35,7 @@ def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr
newdata = app.model.Dataset()
newdata.extension = file_type
newdata.name = basic_name + " (" + description + ")"
newdata.flush()
history.add_dataset( newdata )
newdata.flush()
app.model.flush()
try:
copyfile(filepath,newdata.file_name)
@@ -47,7 +45,6 @@ def exec_after_process(app, inp_data, out_data, param_dict, tool, stdout, stderr
newdata.info = "The requested file is missing from the system."
newdata.state = jobs.JOB_ERROR
newdata.dbkey = dbkey
newdata.init_meta()
newdata.set_meta()
newdata.set_peek()
#
app.model.flush()