Permalink
Cannot retrieve contributors at this time
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?
master_project_JLU2018/bin/3.1_create_gtf/Modules/SaveResults.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
42 lines (28 sloc)
1.3 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |