PEATDB/plugins/PEATSAplugin.py
def mergeMatrix(self, matrix, model, fields=None, newfields=None):
        """Merge a peatsa matrix with a table, returns merged tablemodel
        tablemodel: input tablemodel       
        fields: which fields from matrix should be included in merge, default all
        newfields: a dict that can map matrix names to new col names
        """
        M = self.matrix2Table(matrix)
        if fields==None:
            fields = M.columnNames
        key = 'Mutations'        
        if not key in model.columnNames:
            print 'this table has no mutations column, we cannot merge'
            return
        i = matrix.indexOfColumnWithHeader(key)
      
        for row in model.reclist:
            try:
                mset1 = Core.Data.MutationSet(model.data[row][key])
            except:
                continue
            for rec in M.reclist:
                try:
                    mset2 = Core.Data.MutationSet(M.data[rec][key])
                except:
                    continue                 
                if mset1 == mset2:
                    #add this data to table
                    for f in fields:                       
                        if newfields!=None and newfields.has_key(f):
                            col = newfields[f]
                        else:
                            col = f
                        if not M.data[rec].has_key(f): continue
                        model.addColumn(col)
                        try:
                            model.data[row][col] = float(M.data[rec][f])
                        except:
                            model.data[row][col] = M.data[rec][f]
        return model
Merge a peatsa matrix with a table, returns merged tablemodel
        tablemodel: input tablemodel       
        fields: which fields from matrix should be included in merge, default all
        newfields: a dict that can map matrix names to new col names
        
Merge a peatsa matrix with a table, returns merged tablemodel
tablemodel: input tablemodel
fields: which fields from matrix should be included in merge, default all
newfields: a dict that can map matrix names to new col names
Merge a peatsa matrix with a table returns merged tablemodel tablemodel : input tablemodel fields : which fields from matrix should be included in merge default all newfields : a dict that can map matrix names to new col names
def mergeMatrix(self, matrix, model, fields=None, newfields=None):
        M = self.matrix2Table(matrix)
        if fields==None:
            fields = M.columnNames
        key = 'Mutations'        
        if not key in model.columnNames:
            print 'this table has no mutations column, we cannot merge'
            return
        i = matrix.indexOfColumnWithHeader(key)
        for row in model.reclist:
            try:
                mset1 = Core.Data.MutationSet(model.data[row][key])
            except:
                continue
            for rec in M.reclist:
                try:
                    mset2 = Core.Data.MutationSet(M.data[rec][key])
                except:
                    continue                 
                if mset1 == mset2:
                    for f in fields:                       
                        if newfields!=None and newfields.has_key(f):
                            col = newfields[f]
                        else:
                            col = f
                        if not M.data[rec].has_key(f): continue
                        model.addColumn(col)
                        try:
                            model.data[row][col] = float(M.data[rec][f])
                        except:
                            model.data[row][col] = M.data[rec][f]
        return model
def mergeMatrix ( self , matrix , model , fields = None , newfields = None ) : M = self . matrix2Table ( matrix ) if fields == None : fields = M . columnNames key = 'Mutations' if not key in model . columnNames : print 'this table has no mutations column, we cannot merge' return i = matrix . indexOfColumnWithHeader ( key ) for row in model . reclist : try : mset1 = Core . Data . MutationSet ( model . data [ row ] [ key ] ) except : continue for rec in M . reclist : try : mset2 = Core . Data . MutationSet ( M . data [ rec ] [ key ] ) except : continue if mset1 == mset2 : for f in fields : if newfields != None and newfields . has_key ( f ) : col = newfields [ f ] else : col = f if not M . data [ rec ] . has_key ( f ) : continue model . addColumn ( col ) try : model . data [ row ] [ col ] = float ( M . data [ rec ] [ f ] ) except : model . data [ row ] [ col ] = M . data [ rec ] [ f ] return model
Merge a peatsa matrix with a table, returns merged tablemodel
tablemodel: input tablemodel
fields: which fields from matrix should be included in merge, default all
newfields: a dict that can map matrix names to new col names
Merge a peatsa matrix with a table returns merged tablemodel tablemodel : input tablemodel fields : which fields from matrix should be included in merge default all newfields : a dict that can map matrix names to new col names
"""Merge a peatsa matrix with a table, returns merged tablemodel
        tablemodel: input tablemodel       
        fields: which fields from matrix should be included in merge, default all
        newfields: a dict that can map matrix names to new col names
        """ #add this data to table
self
matrix
model
fields
newfields