当前位置: 首页>>代码示例>>Python>>正文


Python Properties.getInstance方法代码示例

本文整理汇总了Python中properties.Properties.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python Properties.getInstance方法的具体用法?Python Properties.getInstance怎么用?Python Properties.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在properties.Properties的用法示例。


在下文中一共展示了Properties.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CreatePerObjectClassTable

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
    def CreatePerObjectClassTable(self, classes):
        '''
    	Saves object keys and classes to a SQL table
    	'''
        p = Properties.getInstance()
        if p.class_table is None:
            raise ValueError('"class_table" in properties file is not set.')

        index_cols = dbconnect.UniqueObjectClause()
        class_cols = dbconnect.UniqueObjectClause() + ', class, class_number'
        class_col_defs = dbconnect.object_key_defs() + ', class VARCHAR (%d)'%(max([len(c.label) for c in self.classBins])+1) + ', class_number INT'

        # Drop must be explicitly asked for Classifier.ScoreAll
        db = dbconnect.DBConnect.getInstance()
        db.execute('DROP TABLE IF EXISTS %s'%(p.class_table))
        db.execute('CREATE TABLE %s (%s)'%(p.class_table, class_col_defs))
        db.execute('CREATE INDEX idx_%s ON %s (%s)'%(p.class_table, p.class_table, index_cols))
        for clNum, clName in enumerate(self.perClassObjects.keys()):
            for obj in self.perClassObjects[clName]:
                query = ''.join(['INSERT INTO ',p.class_table,' (',class_cols,') VALUES (',str(obj[0]),', ',str(obj[1]),', "',clName,'", ',str(clNum+1),')'])
                db.execute(query)

        if p.db_type.lower() == 'mysql':
            query = ''.join(['ALTER TABLE ',p.class_table,' ORDER BY ',p.image_id,' ASC, ',p.object_id,' ASC'])
            db.execute(query)
            db.Commit()
开发者ID:chadchouGitHub,项目名称:CellProfiler-Analyst,代码行数:28,代码来源:supportvectormachines.py

示例2: on_save_workspace

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
 def on_save_workspace(self, evt):
     p = Properties.getInstance()
     dlg = wx.FileDialog(self, message="Save workspace as...", defaultDir=os.getcwd(), 
                         defaultFile='%s_%s.workspace'%(os.path.splitext(os.path.split(p._filename)[1])[0], p.image_table), 
                         style=wx.SAVE|wx.FD_OVERWRITE_PROMPT|wx.FD_CHANGE_DIR)
     if dlg.ShowModal() == wx.ID_OK:
         wx.GetApp().save_workspace(dlg.GetPath())
开发者ID:jburel,项目名称:CellProfiler-Analyst,代码行数:9,代码来源:cpa.py

示例3: Save

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
    def Save(self, filename):
        # check cache freshness
        try:
            self.cache.clear_if_objects_modified()
        except:
            logging.info("Couldn't check cache freshness, DB connection lost?")

        f = open(filename, 'w')
        try:
            from properties import Properties
            p = Properties.getInstance()
            f.write('# Training set created while using properties: %s\n'%(p._filename))
            f.write('label '+' '.join(self.labels)+'\n')
            i = 0
            for label, obKey in self.entries:
                line = '%s %s %s\n'%(label, ' '.join([str(int(k)) for k in obKey]), ' '.join([str(int(k)) for k in self.coordinates[i]]))
                f.write(line)
                i += 1 # increase counter to keep track of the coordinates positions
            try:
                f.write('# ' + self.cache.save_to_string([k[1] for k in self.entries]) + '\n')
            except:
                logging.error("No DB connection, couldn't save cached image strings")
        except:
            logging.error("Error saving training set %s" % (filename))
            f.close()
            raise
        f.close()
        logging.info('Training set saved to %s'%filename)
        self.saved = True
开发者ID:daviddao,项目名称:cpa-multiclass,代码行数:31,代码来源:trainingset.py

示例4: on_save_properties

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
 def on_save_properties(self, evt):
     p = Properties.getInstance()
     dirname, filename = os.path.split(p._filename)
     ext = os.path.splitext(p._filename)[-1]
     dlg = wx.FileDialog(self, message="Save properties as...", defaultDir=dirname, 
                         defaultFile=filename, wildcard=ext, 
                         style=wx.SAVE|wx.FD_OVERWRITE_PROMPT|wx.FD_CHANGE_DIR)
     if dlg.ShowModal() == wx.ID_OK:
         p.save_file(dlg.GetPath())
开发者ID:jburel,项目名称:CellProfiler-Analyst,代码行数:11,代码来源:cpa.py

示例5: OnBrowse

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
 def OnBrowse(self, evt):
     dlg = wx.FileDialog(self, "Select a properties file", defaultDir=os.getcwd(), style=wx.OPEN|wx.FD_CHANGE_DIR)
     if dlg.ShowModal() == wx.ID_OK:
         p = Properties.getInstance()
         p.LoadFile(dlg.GetPath())
         self.lblDBHost.SetLabel(p.db_host)
         self.lblDBName.SetLabel(p.db_name)
         self.btnTest.SetLabel('Test')
         self.btnTest.Enable()
开发者ID:afraser,项目名称:CellProfiler-Analyst,代码行数:11,代码来源:CreateMasterTableWizard.py

示例6: dimensionReduction

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
 def dimensionReduction():
     # Initialize PCA/tSNE plot
     pca_main = dr.PlotMain(self.classifier, properties = Properties.getInstance(), loadData = False)
     pca_main.set_data(self.classifier.trainingSet.values,
                       dict([(index, object) for index, object in 
                             enumerate(self.classifier.trainingSet.get_object_keys())]),
                       np.int64(self.classifier.trainingSet.label_matrix > 0),
                       self.classifier.trainingSet.labels,
                       np.array([len(misclassifications[i])/float(nPermutations) for i in xrange(len(misclassifications))]).round(2))
     pca_main.Show(True)
开发者ID:chadchouGitHub,项目名称:CellProfiler-Analyst,代码行数:12,代码来源:supportvectormachines.py

示例7: extractDataFromGroupsMysql

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
    def extractDataFromGroupsMysql(self, dependentDataValues, independentDataValues):
        from properties import Properties
        from dbconnect import (
            DBConnect,
            UniqueImageClause,
            UniqueObjectClause,
            GetWhereClauseForImages,
            GetWhereClauseForObjects,
            image_key_columns,
            object_key_columns,
        )
        import sqltools as sql

        p = Properties.getInstance()
        p.LoadFile("C:\\Users\\Dalitso\\Desktop\\workspace2\\abhakar\\Properties_README.txt")
        db = DBConnect.getInstance()

        def buildquery(self, theGroup, var):
            pairs = theGroup.pairsDict
            if var == "dep":
                for i in pairs.keys():
                    print i
                    q = "SELECT " + "`" + self.dependentVariable + "`" + "FROM " + self.table + " WHERE "
                    q2 = [i + " LIKE `" + pairs[i] + "` AND " for i in pairs.keys()]
                    result = q + "".join(q2)[:-4]
                    print result
            if var == "ind":
                for i in pairs.keys():
                    print i
                    q = "SELECT " + "`" + self.independentVariable + "`" + "FROM " + self.table + "WHERE"
                    q2 = [i + "`" + " LIKE `" + pairs[i] + "` AND " for i in pairs.keys()]
                    result = q + "".join(q2)[:-4]
                    print result
            return result

        import numpy as np

        dataDict = {}
        dependentDataValues = np.array(dependentDataValues)
        independentDataValues = np.array(independentDataValues)
        tmp = {}
        for iGrp in self.groupDefinitions:
            theGroup = iGrp
            theGroup.checkMatchCount
            tmp["dependentData"] = db.execute(buildquery(self, theGroup, "dep"))
            tmp["independentData"] = db.execute(buildquery(self, theGroup, "ind"))
            # tmp['pairs'] = theGroup.pairsDict[theGroup.description]
            dataDict[theGroup.description] = tmp
            # print iGrp,theGroup.description,tmp
        return dataDict
开发者ID:dbanda,项目名称:BearlabCellprofiler,代码行数:52,代码来源:dataSelectionObject.py

示例8: clear_link_tables

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
 def clear_link_tables(self, evt=None):
     p = Properties.getInstance()
     dlg = wx.MessageDialog(self, 'This will delete the tables '
                 '"%s" and "%s" from your database. '
                 'CPA will automatically recreate these tables as it '
                 'discovers how your database is linked. Are you sure you '
                 'want to proceed?'
                 %(p.link_tables_table, p.link_columns_table),
                 'Clear table linking information?', 
                 wx.YES_NO|wx.NO_DEFAULT|wx.ICON_QUESTION)
     response = dlg.ShowModal()
     if response != wx.ID_YES:
         return
     db = dbconnect.DBConnect.getInstance()
     db.execute('DROP TABLE IF EXISTS %s'%(p.link_tables_table))
     db.execute('DROP TABLE IF EXISTS %s'%(p.link_columns_table))
     db.Commit()
开发者ID:jburel,项目名称:CellProfiler-Analyst,代码行数:19,代码来源:cpa.py

示例9: Renumber

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
 def Renumber(self, label_dict):
     from properties import Properties
     obkey_length = 3 if Properties.getInstance().table_id else 2
     
     have_asked = False
     progress = None
     for label in label_dict.keys():
         for idx, key in enumerate(label_dict[label]):
             if len(key) > obkey_length:
                 obkey = key[:obkey_length]
                 x, y = key[obkey_length:obkey_length+2]
                 coord = db.GetObjectCoords(obkey, none_ok=True, silent=True) 
                 if coord == None or (int(coord[0]), int(coord[1])) != (x, y):
                     if not have_asked:
                         dlg = wx.MessageDialog(None, 'Cells in the training set and database have different image positions.  This could be caused by running CellProfiler with different image analysis parameters.  Should CPA attempt to remap cells in the training set to their nearest match in the database?',
                                                'Attempt remapping of cells by position?', wx.CANCEL|wx.YES_NO|wx.ICON_QUESTION)
                         response = dlg.ShowModal()
                         have_asked = True
                         if response == wx.ID_NO:
                             return
                         elif response == wx.ID_CANCEL:
                             label_dict.clear()
                             return
                     if progress is None:
                         total = sum([len(v) for v in label_dict.values()])
                         done = 0
                         progress = wx.ProgressDialog("Remapping", "0%", maximum=total, style=wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME | wx.PD_CAN_ABORT)
                     label_dict[label][idx] = db.GetObjectNear(obkey[:-1], x, y, silent=True)
                     done = done + 1
                     cont, skip = progress.Update(done, '%d%%'%((100 * done) / total))
                     if not cont:
                         label_dict.clear()
                         return
                     
     have_asked = False
     for label in label_dict.keys():
         if None in label_dict[label]:
             if not have_asked:
                 dlg = wx.MessageDialog(None, 'Some cells from the training set could not be remapped to cells in the database, indicating that the corresponding images are empty.  Continue anyway?',
                                        'Some cells could not be remapped!', wx.YES_NO|wx.ICON_ERROR)
                 response = dlg.ShowModal()
                 have_asked = True
                 if response == wx.ID_NO:
                     label_dict.clear()
                     return
             label_dict[label] = [k for k in label_dict[label] if k is not None]
开发者ID:daviddao,项目名称:cpa-multiclass,代码行数:48,代码来源:trainingset.py

示例10: OnInit

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
    def OnInit(self):
        '''Initialize CPA
        '''

        '''List of tables created by the user during this session'''
        self.user_tables = []

        # splashscreen
        splashimage = icons.cpa_splash.ConvertToBitmap()
        # If the splash image has alpha, it shows up transparently on
        # windows, so we blend it into a white background.
        splashbitmap = wx.EmptyBitmapRGBA(splashimage.GetWidth(),
                                          splashimage.GetHeight(),
                                          255, 255, 255, 255)
        dc = wx.MemoryDC()
        dc.SelectObject(splashbitmap)
        dc.DrawBitmap(splashimage, 0, 0)
        dc.Destroy() # necessary to avoid a crash in splashscreen
        splash = wx.SplashScreen(splashbitmap, wx.SPLASH_CENTRE_ON_SCREEN |
                                 wx.SPLASH_TIMEOUT, 2000, None, -1)
        self.splash = splash

        p = Properties.getInstance()
        if not p.is_initialized():
            from guiutils import show_load_dialog
            splash.Destroy()
            if not show_load_dialog():
                logging.error('CellProfiler Analyst requires a properties file. Exiting.')
                return False
        self.frame = MainGUI(p, None, size=(860,-1))
        self.frame.Show(True)
        db = dbconnect.DBConnect.getInstance()
        db.register_gui_parent(self.frame)

        try:
            if __version__ != -1:
                import cellprofiler.utilities.check_for_updates as cfu
                cfu.check_for_updates('http://cellprofiler.org/CPAupdate.html',
                                      max(__version__, cpaprefs.get_skip_version()),
                                      new_version_cb,
                                      user_agent='CPAnalyst/2.0.%d'%(__version__))
        except ImportError:
            logging.warn("CPA was unable to check for updates. Could not import cellprofiler.utilities.check_for_updates.")

        return True
开发者ID:dbanda,项目名称:BearlabCellprofiler,代码行数:47,代码来源:cpa.py

示例11: Save

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
    def Save(self, filename):
        # check cache freshness
        self.cache.clear_if_objects_modified()

        f = open(filename, 'w')
        try:
            from properties import Properties
            p = Properties.getInstance()
            f.write('# Training set created while using properties: %s\n'%(p._filename))
            f.write('label '+' '.join(self.labels)+'\n')
            for label, obKey in self.entries:
                line = '%s %s %s\n'%(label, ' '.join([str(int(k)) for k in obKey]), ' '.join([str(int(k)) for k in db.GetObjectCoords(obKey)]))
                f.write(line)
            f.write('# ' + self.cache.save_to_string([k[1] for k in self.entries]) + '\n')
        except:
            logging.error("Error saving training set %s" % (filename))
            f.close()
            raise
        f.close()
        logging.info('Training set saved to %s'%filename)
        self.saved = True
开发者ID:LeeKamentsky,项目名称:CellProfiler-Analyst,代码行数:23,代码来源:trainingset.py

示例12: ImagePanel

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
import wx
import imagetools
from properties import Properties

p = Properties.getInstance()

class ImagePanel(wx.Panel):
    '''
    ImagePanels are wxPanels that display a wxBitmap and store multiple
    image channels which can be recombined to mix different bitmaps.
    '''
    def __init__(self, images, channel_map, parent, 
                 scale=1.0, brightness=1.0, contrast=None):
        """
        images -- list of numpy arrays
        channel_map -- list of strings naming the color to map each channel 
                       onto, e.g., ['red', 'green', 'blue']
        parent -- parent window to the wx.Panel
        scale -- factor to scale image by
        brightness -- factor to scale image pixel intensities by
        
        """
        self.chMap       = channel_map
        self.toggleChMap = channel_map[:]
        self.images      = images
        # Displayed bitmap
        self.bitmap      = imagetools.MergeToBitmap(images,
                               chMap = channel_map,
                               scale = scale,
                               brightness = brightness,
                               contrast = contrast)
开发者ID:daviddao,项目名称:CellProfiler-Analyst,代码行数:33,代码来源:imagepanel.py

示例13: setup_mysql

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
 def setup_mysql(self):
     self.p  = Properties.getInstance()
     self.db = DBConnect.getInstance( )
     self.db.Disconnect()
     self.p.LoadFile('../../CPAnalyst_test_data/nirht_test.properties')
开发者ID:CellProfiler,项目名称:CellProfiler-Analyst,代码行数:7,代码来源:testdbconnect.py

示例14: setup_sqlite2

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
 def setup_sqlite2(self):
     self.p  = Properties.getInstance()
     self.db = DBConnect.getInstance()
     self.db.Disconnect()
     self.p.LoadFile('../../CPAnalyst_test_data/export_to_db_test.properties')
开发者ID:CellProfiler,项目名称:CellProfiler-Analyst,代码行数:7,代码来源:testdbconnect.py

示例15: HTS_GroupDataExtractMySql

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import getInstance [as 别名]
def HTS_GroupDataExtractMySql(dataSelector,table):
    from HTS_dataDict import HTS_dataDict
    import xlrd as xl
    import numpy as np
    import matplotlib.pyplot as plt
    from properties import Properties
    from dbconnect import DBConnect, UniqueImageClause, UniqueObjectClause, GetWhereClauseForImages, GetWhereClauseForObjects, image_key_columns, object_key_columns
    import sqltools as sql

    p = Properties.getInstance()
    db = DBConnect.getInstance()
    dependentDataValues = False
    independentDataValues = False
#    def buildquery(self, table):
#        q = 'SELECT ' + self.independentVar + ', '+ self.dependentVar +' FROM ' + table
#        q2= [' WHERE '+ y[1] +' LIKE ' +y[0] for y in group.pairs]
#        return q + ''.join(q2)

    returnDict = HTS_dataDict(dataSelector)
    #for iFile in range(nFiles):
    dataSelector.clearAllIndici
    print('HTS_GroupDataExtract: using sheet %s for %s\n',table)
    query ='SELECT `' + dataSelector.independentVariable + '`  FROM ' + '`' +table+'`'
    print query
    dataSelector.findValidIndiciFromDataColumn(dataSelector.independentVariable,db.execute(query))
    query = 'SELECT `' + dataSelector.dependentVariable + '`  FROM ' + '`' +table+'`'
    print query
    dataSelector.findValidIndiciFromDataColumn(dataSelector.dependentVariable,db.execute(query))
    print dependentDataValues, independentDataValues, "variables"
    if not dependentDataValues:
        print 'HTS_GroupDataExtract: dependent variable not found in %s',
    if not independentDataValues:
        print 'HTS_GroupDataExtract: independent variable not found in %s'
    # print dataSelector.extractDataFromGroups(dependentDataValues,independentDataValues)
    dataSelector.table =  table
    returnDict.dict[table] =  dataSelector.extractDataFromGroupsMysql(dependentDataValues,independentDataValues)



#    if nFiles > 1:
#       # Get data from the selector
#        nGroups = dataSelector.nGroups
#        groupKeys = dataSelector.getGroupDescriptions()
#      # Create the combined group
#        combinedData = {}
#        tmpStruct = {}
#        tmpStruct['dependentData'] = np.array([])
#        tmpStruct['independentData'] = np.array([])
#        for iGrp in range(nGroups):
#            combinedData[groupKeys[iGrp]] = tmpStruct
#        for iFile in range(nFiles):
#            #print('the key = %s\n')
#            fileData = returnDict.dict[dataFiles[iFile]]
#            for iGrp in range(nGroups):
#                grpKey = groupKeys[iGrp]
#                #combDepData = combinedData[grpKey]['dependentData']
#                fileDepData = fileData[grpKey]['dependentData']
#                tmpStruct['dependentData'] = np.concatenate((tmpStruct['dependentData'],fileDepData[:]))
#                #combIndData = [combinedData[grpKey]['independentData']]
#                fileIndData = fileData[grpKey]['independentData']
#                tmpStruct['independentData'] = np.concatenate((tmpStruct['independentData'],fileIndData[:]))
#                combinedData[grpKey] = tmpStruct
#
#        returnDict.dict['combinedData'] = combinedData

    return returnDict
开发者ID:dbanda,项目名称:BearlabCellprofiler,代码行数:68,代码来源:HTS_GroupDataExtractMySql.py


注:本文中的properties.Properties.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。