Mercurial > repos > bzonnedda > conifer2
changeset 28:629681116b5f draft
Uploaded
author | bzonnedda |
---|---|
date | Fri, 07 Jul 2017 04:04:25 -0400 |
parents | 02091c92f4f1 |
children | 2e8281109e79 |
files | conifer_functions.py |
diffstat | 1 files changed, 9 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/conifer_functions.py Thu Jul 06 06:29:12 2017 -0400 +++ b/conifer_functions.py Fri Jul 07 04:04:25 2017 -0400 @@ -79,7 +79,7 @@ def loadProbeList(CF_probe_filename): # Load data files - probefile = open(CF_probe_filename) + probefile = open(CF_probe_filename, 'rb') s = csv.Sniffer() header = s.has_header(probefile.read(1024)) probefile.seek(0) @@ -145,9 +145,9 @@ import operator import locale exon_set = rpkm_data.exons - genomic_coords = np.array(list(map(operator.itemgetter("start"),exon_set))) + genomic_coords = np.array(map(operator.itemgetter("start"),exon_set)) - ticks = list(range(0,len(exon_set),len(exon_set)/5)) + ticks = range(0,len(exon_set),len(exon_set)/5) ticks[-1] -= 1 # the last tick is going to be off the chart, so we estimate it as the second to last genomic coord. labels = [locale.format("%d", genomic_coords[i], grouping=True) for i in ticks if i < len(genomic_coords)] @@ -177,7 +177,7 @@ return [] out_calls = [] - calls=np.array(calls)[np.argsort(np.array(list(map(operator.itemgetter("start"),calls)),dtype=np.int))] + calls=np.array(calls)[np.argsort(np.array(map(operator.itemgetter("start"),calls),dtype=np.int))] pstart = calls[0]["start"] pstop = calls[0]["stop"] for d in calls: @@ -202,7 +202,7 @@ def smooth(self, window = 15, padded = False): #todo, fix the padding here if self.isGenotype: - print("Warning: the data in this rpkm_data container are single genotype values. Smoothing will have no effect!") + print "Warning: the data in this rpkm_data container are single genotype values. Smoothing will have no effect!" return self.rpkm if window > 0: @@ -249,10 +249,11 @@ """Initialize an rpkm_reader instance. Specify the location of the data file""" if rpkm_fn == None: - print("Must specify RPKM HDF5 file!") + print "Must specify RPKM HDF5 file!" return 0 # set up file access - self.h5file = openFile(rpkm_fn, mode='r') + # self.h5file = openFile(rpkm_fn, mode='r') + self.h5file = open_file(rpkm_fn, mode='r') self.sample_table = self.h5file.root.samples.samples def __del__(self): @@ -367,4 +368,4 @@ def getExonIDs(self, chromosome, start, stop): probe_tbl = self.h5file.root.probes._f_getChild("probes_chr" + str(chromosome)) exons = probe_tbl.getWhereList('(start >= %d) & (stop <= %d)' % (start,stop)) - return exons \ No newline at end of file + return exons