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
|
from fluents import dataset, logger, plots, workflow, fluents
|
||||||
import geneontology
|
import geneontology
|
||||||
#import gostat
|
#import gostat
|
||||||
from scipy import array, randn, log, ones
|
from scipy import array, randn, log, ones, zeros
|
||||||
import networkx
|
import networkx
|
||||||
|
|
||||||
EVIDENCE_CODES=[('IMP', 'Inferred from mutant phenotype'),
|
EVIDENCE_CODES=[('IMP', 'Inferred from mutant phenotype'),
|
||||||
|
@ -22,6 +22,10 @@ DISTANCE_METRICS = [('resnik', 'Resnik'),
|
||||||
('jiang', 'Jiang & Conrath'),
|
('jiang', 'Jiang & Conrath'),
|
||||||
('fussimeg', 'FuSSiMeG')]
|
('fussimeg', 'FuSSiMeG')]
|
||||||
|
|
||||||
|
GO_DATA_DIR = '/home/einarr/data'
|
||||||
|
|
||||||
|
evidence = None
|
||||||
|
|
||||||
class GoTermView (gtk.Frame):
|
class GoTermView (gtk.Frame):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -133,35 +137,29 @@ class LoadAnnotationsFunction(workflow.Function):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
workflow.Function.__init__(self, 'load-go-ann', 'Load Annotations')
|
workflow.Function.__init__(self, 'load-go-ann', 'Load Annotations')
|
||||||
self.annotations = None
|
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):
|
def run(self):
|
||||||
btns = ('Open', gtk.RESPONSE_OK, \
|
global evidence
|
||||||
'Cancel', gtk.RESPONSE_CANCEL)
|
f = open(GO_DATA_DIR + '/goa-condensed')
|
||||||
dialog = gtk.FileChooserDialog('Open GO Annotation File',
|
ev_codes = f.readline().split()
|
||||||
buttons=btns)
|
go_terms = []
|
||||||
dialog.connect('response', self.on_response)
|
|
||||||
dialog.run()
|
lines = f.readlines()
|
||||||
dialog.destroy()
|
m = zeros((len(lines), len(ev_codes)))
|
||||||
return [self.annotations]
|
|
||||||
|
|
||||||
|
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):
|
class EvidenceCodeFrame(gtk.Frame):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -249,8 +247,11 @@ class GoDistanceFunction(workflow.Function):
|
||||||
workflow.Function.__init__(self, 'go-dist', 'GO term distance matrix')
|
workflow.Function.__init__(self, 'go-dist', 'GO term distance matrix')
|
||||||
self.options = GoDistanceOptions()
|
self.options = GoDistanceOptions()
|
||||||
|
|
||||||
def run(self, data):
|
def run(self, selection):
|
||||||
self.options = self.show_gui(self.options)
|
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):
|
def show_gui(self, options, edit=True):
|
||||||
dialog = GoDistanceDialog()
|
dialog = GoDistanceDialog()
|
||||||
|
|
Reference in New Issue