Skip to content
Permalink
6c912f8859
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
47 lines (32 sloc) 1.27 KB
import os
class Validator:
"""
Class to validate and sort 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 output file
self.out_file = out_file
self.sort_file()
self.test_read_file()
def sort_file(self):
# function that utilizes linux sort to sort the output by chromosome and start coordinate,
# this improves handling in tools like IGV
command = "sort -V -k1,1 -k4,4n -o "+self.out_file+" "+self.out_file
os.system(command)
def test_read_file(self):
# Method to test the output file-format
with open(self.out_file) as outfile:
line = outfile.readline()
if line:
if len(line.split("\t")) == 9:
print("Validation complete no errors found !")
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")