-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathaibs.py
More file actions
43 lines (32 loc) · 1.13 KB
/
aibs.py
File metadata and controls
43 lines (32 loc) · 1.13 KB
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
import csv
import numpy as np
def read_expression_values(file_name):
values = np.loadtxt(open(file_name, 'rb'), delimiter=",")
return np.delete(values, 0, 1);
def read_probes(file_name):
probes = []
with open(file_name, 'rb') as probesfile:
reader = csv.DictReader(probesfile)
probes = list(reader)
gene_probes = {}
for i, probe in enumerate(probes):
gene_id = probe['gene_id']
probe_info = { 'probe_id': probe['probe_id'], 'index': i }
if not gene_probes.has_key(gene_id):
gene_probes[gene_id] = [probe_info]
else:
gene_probes[gene_id].append(probe_info)
return probes, gene_probes
def read_structures(file_name):
structures = {}
with open(file_name, 'rb') as structures_file:
reader = csv.DictReader(structures_file)
structure_list = list(reader)
structures = { s['id']: s for s in structure_list }
return structures
def read_samples(file_name):
samples = []
with open(file_name, 'rb') as samplesfile:
reader = csv.DictReader(samplesfile)
samples = list(reader)
return samples