Beispiel #1
0
    def send2Labbook(self):
        """Send matrix to selected labbook"""
        #get name
        cols = [''] + self.DB.getSimpleFields()
        DB = self.DB
        mpDlg = MultipleValDialog(title='Send to Labbook',
                                  initialvalues=(self.currname, cols),
                                  labels=('table name', 'exp data column'),
                                  types=('string', 'list'),
                                  parent=self.mainwin)
        if mpDlg.result == False:
            return
        name = mpDlg.results[0]
        expcol = mpDlg.results[1]

        M = DBActions.sendDB2Labbook(DB,
                                     recs=None,
                                     cols=['Mutations', expcol],
                                     name=name)
        for m in self.matrices:
            matrix = self.matrices[m]
            if matrix != None:
                M = self.mergeMatrix(matrix, M)
                self.DB.createLabbookSheet(name, M)
        self.parent.startLabbook('ALL')
        return
Beispiel #2
0
def createProjects(files):
    """Create multiple projects at once from csv files"""

    for filename in files:
        print filename
        name = os.path.splitext(filename)[0]
        #create/open db
        DB = PDatabase(local=os.path.join(savepath,name))
        DB.add('wt')
        #add wt pdb
        stream = DBActions.fetchPDB(name)
        DBActions.addPDBFile(DB, 'wt', pdbdata=stream, pdbname=name, gui=False)
        DB.meta.refprotein = 'wt'
        DB.meta.info['protein'] = name
        #import data from csv
        DB.importCSV(os.path.join(cpath,filename), namefield='Mutations')
        print 'imported ok'
        DB.deleteField('PDB')
        DB.commit()
        DB.close()
        print 'done'
    return
Beispiel #3
0
 def selectfromDB(self):
     """Get an ekin prj from the DB"""
     if self.DB == None:
         return
     from PEATDB.Actions import DBActions
     fr=Toplevel()
     rbox, cbox = DBActions.getRecordsSelector(self.DB,fr)
     def loadselected():
         item = rbox.curselection()[0]
         rec = self.DB.getRecs()[int(item)]
         item = cbox.curselection()[0]
         col = self.DB.getFields()[int(item)]
         E=self.DB[rec][col]
         self.loadEkinProj(E)
         fr.destroy()
     Button(fr, text='OK',
             command=loadselected).grid(row=3,column=0,
             columnspan=2,sticky='news',padx=1,pady=3)
     return
Beispiel #4
0
 def send2Labbook(self):
     """Send matrix to selected labbook"""
     #get name
     cols = ['']+self.DB.getSimpleFields()
     DB=self.DB
     mpDlg = MultipleValDialog(title='Send to Labbook',
                                 initialvalues=(self.currname, cols),
                                 labels=('table name','exp data column'),
                                 types=('string','list'),
                                 parent=self.mainwin)
     if mpDlg.result == False:
         return        
     name = mpDlg.results[0]
     expcol = mpDlg.results[1]
                
     M = DBActions.sendDB2Labbook(DB,recs=None,cols=['Mutations',expcol],name=name)        
     for m in self.matrices:
         matrix = self.matrices[m]
         if matrix != None:              
             M = self.mergeMatrix(matrix, M)
             self.DB.createLabbookSheet(name, M)
     self.parent.startLabbook('ALL')
     return        
Beispiel #5
0
    def plotCorrelation(self,
                        x,
                        y,
                        labels=None,
                        key='Mutations',
                        title='',
                        xlabel='Predicted',
                        ylabel='Experimental',
                        ms=5,
                        err=None,
                        axeslabels=True,
                        plotname=None,
                        stats=True,
                        side=LEFT,
                        ax=None):
        """Show exp vs pred. for a set of x-y values """

        #check if x and y are number cols and round
        x = [round(float(i), 2) for i in x]
        y = [round(float(i), 2) for i in y]

        if min(x) < min(y): a = min(x) - 2
        else: a = min(y) - 4
        if max(x) > max(y): b = max(x) + 2
        else: b = max(y) + 4

        colors = ['b', 'g', 'r', 'y', 'm', 'c']
        if ax == None:
            fig = plt.figure(figsize=(6, 6))
            ax = fig.add_subplot(111)
        else:
            #fig = ax.get_figure()
            fig = None
        if axeslabels == True:
            ax.set_xlabel(xlabel)
            ax.set_ylabel(ylabel)
        legs = []
        legnames = []
        bad = []
        good = []

        if len(x) == 0:
            return
        errs = [i - j for i, j in zip(x, y)]
        line = ax.plot(x,
                       y,
                       'o',
                       mew=0,
                       ms=ms,
                       alpha=0.6,
                       label=plotname,
                       picker=3)

        #draw expected correlation line with slope x
        slope = 1
        #set range of axes
        ax.plot((a, b), (a, b), 'g')
        ax.axhline(y=0, color='grey')
        ax.axvline(x=0, color='grey')
        ax.set_xlim(a, b)
        ax.set_ylim(a, b)
        ax.set_title(title)

        if err != None:
            ax.plot((a, b), (a + err, b + err), '--', color='g')
            ax.plot((a, b), (a - err, b - err), '--', color='g')
        if stats == True:
            self.addStats(ax, x, y)
        if fig != None:
            fig.suptitle('Predicted vs Experimental')
            from PEATDB.Actions import DBActions
            frame = DBActions.showTkFigure(fig, side=side)
            #mh = MouseHandler(ax, self, labels, key)
            #mh.connect()
            mh = self.addMouseHandler(ax, labels, key)
        else:
            mh = frame = None
        return ax, frame, mh
Beispiel #6
0
    def plotCorrelation(self, x, y, labels=None,
                          key='Mutations',
                          title='',
                          xlabel='Predicted',
                          ylabel='Experimental', ms=5,
                          err=None, axeslabels=True,
                          plotname=None, stats=True,        
                          side=LEFT, ax=None):
        """Show exp vs pred. for a set of x-y values """
               
        #check if x and y are number cols and round
        x=[round(float(i),2) for i in x]
        y=[round(float(i),2) for i in y]

        if min(x)<min(y): a=min(x)-2
        else: a=min(y)-4
        if max(x)>max(y): b=max(x)+2
        else: b=max(y)+4
       
        colors = ['b','g','r','y','m','c']        
        if ax==None:
            fig = plt.figure(figsize=(6,6))
            ax = fig.add_subplot(111)
        else:       
            #fig = ax.get_figure()
            fig = None
        if axeslabels==True:    
            ax.set_xlabel(xlabel)
            ax.set_ylabel(ylabel)
        legs=[]; legnames=[]
        bad=[]; good=[]
       
        if len(x) ==0:
            return
        errs = [i - j for i, j in zip(x, y)]
        line = ax.plot(x, y, 'o', mew=0, ms=ms,
                       alpha=0.6, label=plotname,
                       picker=3)  

        #draw expected correlation line with slope x
        slope=1
        #set range of axes
        ax.plot((a,b),(a,b),'g')
        ax.axhline(y=0, color='grey'); ax.axvline(x=0,color='grey')
        ax.set_xlim(a,b); ax.set_ylim(a,b)
        ax.set_title(title)
           
        if err!=None:
            ax.plot((a,b),(a+err,b+err),'--',color='g')
            ax.plot((a,b),(a-err,b-err),'--',color='g')         
        if stats==True:
            self.addStats(ax,x,y)
        if fig!=None:
            fig.suptitle('Predicted vs Experimental')            
            from PEATDB.Actions import DBActions
            frame = DBActions.showTkFigure(fig, side=side)            
            #mh = MouseHandler(ax, self, labels, key)
            #mh.connect()
            mh = self.addMouseHandler(ax, labels, key)
        else:
            mh = frame = None
        return ax, frame, mh