Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

More persumably non-working stuff.

This commit is contained in:
Einar Ryeng 2007-01-10 15:33:19 +00:00
parent 1e0b99f283
commit 060732d980
1 changed files with 36 additions and 2 deletions

View File

@ -112,6 +112,7 @@ class GoWorkflow (workflow.Workflow):
load = workflow.Stage('load', 'Load GO Annotations') load = workflow.Stage('load', 'Load GO Annotations')
load.add_function(LoadGOFunction()) load.add_function(LoadGOFunction())
load.add_function(LoadAnnotationsFunction()) load.add_function(LoadAnnotationsFunction())
load.add_function(LoadTextDatasetFunction())
self.add_stage(load) self.add_stage(load)
go = workflow.Stage('go', 'Gene Ontology') go = workflow.Stage('go', 'Gene Ontology')
@ -143,6 +144,7 @@ class LoadTextDatasetFunction(workflow.Function):
identifiers = {} identifiers = {}
type = 'dataset' type = 'dataset'
name = 'Unnamed dataset' name = 'Unnamed dataset'
graphtype = 'graph'
# Read header lines from file. # Read header lines from file.
line = fd.readline() line = fd.readline()
@ -168,13 +170,45 @@ class LoadTextDatasetFunction(workflow.Function):
elif key == 'name': elif key == 'name':
name = val name = val
elif key == 'graphtype':
graphtype = val
else: else:
break break
line = f.readline() line = f.readline()
# Dimensions in the form [(dim1, [id1, id2, id3 ..) ...]
dims = [(x, identifiers[x]) for x in dimensions]
dim_lengths = [len(identifiers[x]) for x in dimensions]
# Create dataset of specified type
if type == 'category':
matrix = zeros(dim_lengths, dtype=bool)
ds = dataset.CategoryDataset(matrix, dims)
elif type == 'network':
matrix = zeros(dim_lengths)
ds = dataset.GraphDataset(matrix, dims)
else:
matrix = zeros(dim_lengths)
ds = dataset.Dataset(matrix, dims)
line = f.readline()
y = 0
while line:
values = line.split()
for x, v in enumerate(values):
matrix[x,y] = float(v)
y += 1
line = f.readline()
# Build NetowrkX graph from matrix.
if type == 'network':
matrix = zeros(dim_lengths)
ds = dataset.NetworkDataset(matrix, dims)
def run(self): def run(self):
f = open('/home/einarr/foodata.tds') f = open('/home/einarr/foodata.fcsv')
return read_text_dataset(f) return read_text_dataset(f)