Added very hackish annotation count reader.
This commit is contained in:
parent
6aa1a1a817
commit
fac9346aad
|
@ -2,7 +2,7 @@ import gtk
|
|||
from fluents import dataset, logger, plots, workflow, fluents
|
||||
import geneontology
|
||||
#import gostat
|
||||
from scipy import array, randn, log, ones
|
||||
from scipy import array, randn, log, ones, zeros
|
||||
import networkx
|
||||
|
||||
EVIDENCE_CODES=[('IMP', 'Inferred from mutant phenotype'),
|
||||
|
@ -22,6 +22,10 @@ DISTANCE_METRICS = [('resnik', 'Resnik'),
|
|||
('jiang', 'Jiang & Conrath'),
|
||||
('fussimeg', 'FuSSiMeG')]
|
||||
|
||||
GO_DATA_DIR = '/home/einarr/data'
|
||||
|
||||
evidence = None
|
||||
|
||||
class GoTermView (gtk.Frame):
|
||||
|
||||
def __init__(self):
|
||||
|
@ -134,33 +138,27 @@ class LoadAnnotationsFunction(workflow.Function):
|
|||
workflow.Function.__init__(self, 'load-go-ann', 'Load Annotations')
|
||||
self.annotations = None
|
||||
|
||||
def load_file(self, filename):
|
||||
f = open(filename)
|
||||
self.annotations = Annotations('genes', 'go-terms')
|
||||
logger.log('notice', 'Loading annotation file: %s' % filename)
|
||||
|
||||
for line in f.readlines():
|
||||
val = line.split(' \t')
|
||||
|
||||
if len(val) > 1:
|
||||
val = [v.strip() for v in val]
|
||||
retval.add_annotations('genes', val[0],
|
||||
'go-terms', set(val[1:]))
|
||||
|
||||
def on_response(self, dialog, response):
|
||||
if response == gtk.RESPONSE_OK:
|
||||
logger.log('notice', 'Reading file: %s' % dialog.get_filename())
|
||||
self.load_file(dialog.get_filename())
|
||||
|
||||
def run(self):
|
||||
btns = ('Open', gtk.RESPONSE_OK, \
|
||||
'Cancel', gtk.RESPONSE_CANCEL)
|
||||
dialog = gtk.FileChooserDialog('Open GO Annotation File',
|
||||
buttons=btns)
|
||||
dialog.connect('response', self.on_response)
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
return [self.annotations]
|
||||
global evidence
|
||||
f = open(GO_DATA_DIR + '/goa-condensed')
|
||||
ev_codes = f.readline().split()
|
||||
go_terms = []
|
||||
|
||||
lines = f.readlines()
|
||||
m = zeros((len(lines), len(ev_codes)))
|
||||
|
||||
for i, l in enumerate(lines):
|
||||
values = l.split()
|
||||
go_terms.append(values[0])
|
||||
for j, v in enumerate(values[1:]):
|
||||
m[i,j] = float(v.strip())
|
||||
|
||||
d = dataset.Dataset(m,
|
||||
[['go-terms', go_terms], ['evidence', ev_codes]],
|
||||
name='GO evidence')
|
||||
|
||||
evidence = d
|
||||
return [d]
|
||||
|
||||
|
||||
class EvidenceCodeFrame(gtk.Frame):
|
||||
|
@ -249,8 +247,11 @@ class GoDistanceFunction(workflow.Function):
|
|||
workflow.Function.__init__(self, 'go-dist', 'GO term distance matrix')
|
||||
self.options = GoDistanceOptions()
|
||||
|
||||
def run(self, data):
|
||||
def run(self, selection):
|
||||
self.options = self.show_gui(self.options)
|
||||
if not selection.has_key('go-terms') or len(selection['go-terms']) == 0:
|
||||
logger.log('warning', 'No GO terms selected. Cannot make distance matrix.')
|
||||
|
||||
|
||||
def show_gui(self, options, edit=True):
|
||||
dialog = GoDistanceDialog()
|
||||
|
|
Reference in New Issue