calc_depth_mean.py 907 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
align_file = "/home/theo/dev/git/cnvCallerGPU/test_depth.txt"
depth_sup_mean = "/home/theo/dev/git/cnvCallerGPU/depth_sup_mean.txt"
def calc_depth_mean(align_file):
    with open(align_file, 'r') as file:
        total_depth = 0
        total_window = 0

        for line in file:
            depth_str_split = line.split()
            depth_str_value = depth_str_split[6:]
            total_depth += float(depth_str_value[0])
            total_window += 1
        mean = total_depth / total_window
        return mean

with open(depth_sup_mean, 'w') as output:
    with open(align_file, 'r') as file:
        mean = calc_depth_mean(align_file)  

        for line in file:
            depth_str_split = line.split()
            depth_str_value = depth_str_split[6:]
            
            if float(depth_str_value[0]) > mean:
                output.write(f"{depth_str_split[5]}: {depth_str_value[0]}\n")