-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhighlownoisevals.py
71 lines (44 loc) · 1.93 KB
/
highlownoisevals.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 27 12:50:14 2017
@author: lpsmith
"""
from __future__ import division
from os import walk
import lucianSNPLibrary as lsl
import numpy
(seglengths, avgseg) = lsl.getNumSegmentsPerSample()
directories = ["expands_full_input/results/"]
for n in range(100):
directories.append("expands_full_input_shuffled_" + str(n) + "/results/")
print "average, stdev, median, max, min"
for directory in directories:
flist = []
for (_, _, f) in walk(directory):
flist += f
lownoisevals = []
highnoisevals = []
for f in flist:
if f.find(".spstats") == -1:
continue
(patient, sample, tag) = f.split("_")
statfile = open(directory + f, "r")
for line in statfile:
if line.find("expands") != -1:
continue
if line.find("Mean") != -1:
continue
splitline = line.split()
if len(splitline) < 2:
continue
if seglengths[(patient, sample)] < avgseg:
lownoisevals.append(float(splitline[1]))
else:
highnoisevals.append(float(splitline[1]))
statfile.close()
if (len(highnoisevals) > 0):
print directory, "High:", numpy.average(highnoisevals), numpy.std(highnoisevals), numpy.median(highnoisevals), numpy.max(highnoisevals), numpy.min(highnoisevals)
print directory, "Low:", numpy.average(lownoisevals), numpy.std(lownoisevals), numpy.median(lownoisevals), numpy.max(lownoisevals), numpy.min(lownoisevals)
lsl.createPrintAndSaveHistogram(highnoisevals, "highnoiseout.txt", 0.01, xdata="noise")
lsl.createPrintAndSaveHistogram(lownoisevals, "lownoiseout.txt", 0.01, xdata="noise")