From b3223d11b1f2f46c460ab464866ecdfb5732dd28 Mon Sep 17 00:00:00 2001 From: basti Date: Sun, 6 Jan 2019 15:31:40 +0100 Subject: [PATCH] Added Validator -> Fix #32 --- bin/3.1_create_gtf/Modules/Validator.py | 35 +++++++++++++++++++++++++ bin/3.1_create_gtf/RegGTFExtractor.py | 5 ++++ 2 files changed, 40 insertions(+) create mode 100644 bin/3.1_create_gtf/Modules/Validator.py diff --git a/bin/3.1_create_gtf/Modules/Validator.py b/bin/3.1_create_gtf/Modules/Validator.py new file mode 100644 index 0000000..55c03e0 --- /dev/null +++ b/bin/3.1_create_gtf/Modules/Validator.py @@ -0,0 +1,35 @@ +class Validator: + + """ + Class to validate the gtf-output-file. + @author: Sebastian Beyvers + @contact: sebastian.beyvers@med.uni-giessen.de + + """ + + def __init__(self, out_file): + + # Constructor + # input_parameter: out_file = Path to Outputfile + + self.out_file = out_file + self.test_read_file() + + def test_read_file(self): + + # Method to testread the file + + with open(self.out_file) as outfile: + line = outfile.readline() + + if line: + if len(line.split("\t")) == 9: + print("Check successfull !") + else: + print("Incorrect output Format: Try again after deleting data folder.") + else: + print("Outputfile not in correct Format: Try again after deleting data Folder.") + exit(1) + +# Debug +# v = Validator("/home/basti/Schreibtisch/test_hg38.gtf") \ No newline at end of file diff --git a/bin/3.1_create_gtf/RegGTFExtractor.py b/bin/3.1_create_gtf/RegGTFExtractor.py index 9286151..9000341 100644 --- a/bin/3.1_create_gtf/RegGTFExtractor.py +++ b/bin/3.1_create_gtf/RegGTFExtractor.py @@ -14,6 +14,7 @@ from Modules.Uniquifier import UniqueFilter from Modules.SaveResults import ResultSaver from Modules.CrossMapper import CrossMapper +from Modules.Validator import Validator import os import json @@ -134,6 +135,10 @@ def main_script(organism, wd, data_dir, out, tissuetype=None): if x_mappable: CrossMapper(organism, wd, out, False) + # Validate outputfile + + Validator(out) + if __name__ == '__main__':