Skip to content
Permalink
4f40b11ca2
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
42 lines (28 sloc) 1.3 KB
import os
class ResultSaver:
"""
Class to save the results. The output is saved to the temp directory in the data folder if crossmapping is necessary.
@author: Sebastian Beyvers
@contact: sebastian.beyvers@med.uni-giessen.de
"""
def __init__(self, results, organism, wd, mapped, is_data_dir, out):
# Constructor and main method for result-saving
# input_parameter: results = finished list of gtf-entries
# organism = input_organism
# wd = working directory
# mapped = boolean if crossmapping is necessary
# is_data_dir = boolean if wd is a data_dir (true) or not (false)
print("Save results to File !")
self.path = ""
# If results has to be crossmapped -> Path is tempdirectory.
if mapped:
if is_data_dir:
self.path = os.path.join(wd + "/temp/" + organism + ".gtf")
else:
self.path = os.path.join(wd + "/data/temp/" + organism + ".gtf")
# if no crossmapping is needed:
else:
self.path = os.path.join(out)
with open(self.path, "w") as output_file:
for line in results:
output_file.write("\t".join(line)+"\n")