inf = open(filename,'r') reader = csv.reader(inf,delimiter='\t') ls = [] for row in reader: one_row = [] for data in row[1:]: #first column is gene name if data == 'NA': data=random.randint(-800,800) elif data=='': #some datasets' last column is None continue else: data = float(data) one_row.append(data) ls.append(one_row) instance = biclustering.biclustering(hscore_cut_off,min_height, min_width, bThreshold) biclustering.set_module_and_type('Numeric', 'ArrayType') instance.data_read_in(array(ls)) ls1 = instance.return_matrix_data() #output the matrix read in by the class writer = csv.writer(open('/tmp/test_biclustering.out', 'w'), delimiter='\t') for row in ls1: writer.writerow(row) del writer print "the first row is " print ls1[0] print "the penultimate row is " print ls1[-2] print "the final row is "
test_biclustering.py INPUTFILE Decription: A program to test the biclustering module. INPUTFILE is tab-delimited format. First column is the label. 'NA' denotes Not avaible. """ import csv,sys import biclustering if len(sys.argv)!=2: print __doc__ sys.exit(0) instance = biclustering.biclustering(50,5,6,100) filename=sys.argv[1] inf = open(filename,'r') reader = csv.reader(inf,delimiter='\t') ls = [] for row in reader: if row[-1]: #some datasets' last column is None ls.append(row[1:]) else: ls.append(row[1:-1]) instance.data_read_in(ls) ls1 = instance.return_matrix_data() #output the matrix read in by the class writer = csv.writer(open('/tmp/test_biclustering.out', 'w'), delimiter='\t') for row in ls1: