# HG changeset patch # User bzonnedda # Date 1499336927 14400 # Node ID cbe4551cdc277c54f83920f462d38c3b55c7b4ca # Parent abdc05fae16e805ae4224c018e2d5a9f61b4c6d6 Uploaded diff -r abdc05fae16e -r cbe4551cdc27 conifer_functions.py --- a/conifer_functions.py Thu Jul 06 06:28:33 2017 -0400 +++ b/conifer_functions.py Thu Jul 06 06:28:47 2017 -0400 @@ -25,7 +25,7 @@ ####################################################################### import csv -#from tables import * +from tables import * import numpy as np import operator @@ -79,7 +79,7 @@ def loadProbeList(CF_probe_filename): # Load data files - probefile = open(CF_probe_filename, 'rb') + probefile = open(CF_probe_filename) 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(map(operator.itemgetter("start"),exon_set)) + genomic_coords = np.array(list(map(operator.itemgetter("start"),exon_set))) - ticks = range(0,len(exon_set),len(exon_set)/5) + ticks = list(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(map(operator.itemgetter("start"),calls),dtype=np.int))] + calls=np.array(calls)[np.argsort(np.array(list(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,7 +249,7 @@ """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') @@ -367,4 +367,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 + return exons \ No newline at end of file