Skip to content

Commit

Permalink
Push to v2.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
donovan-h-parks committed Dec 5, 2014
1 parent b41c9a1 commit 896b894
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions stamp/STAMP.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
__copyright__ = 'Copyright 2013'
__credits__ = ['Donovan Parks']
__license__ = 'GPL3'
__version__ = '2.0.8'
__date__ = 'August 4, 2014'
__version__ = '2.0.9'
__date__ = 'December 5, 2014'
__maintainer__ = 'Donovan Parks'
__email__ = '[email protected]'
__status__ = 'Development'
Expand All @@ -35,7 +35,7 @@
import string

import stamp.Dependencies
from stamp.GUI.plotDlg import PlotDlg # forward reference so py2app recognizes this file is required
from stamp.GUI.plotDlg import PlotDlg # forward reference so py2app recognizes this file is required

from PyQt4 import QtGui, QtCore

Expand Down Expand Up @@ -200,7 +200,7 @@ def __init__(self, preferences, parent=None):

self.metadata = None

#self.loadProfile() # *** For debugging purposes
# self.loadProfile() # *** For debugging purposes

def propertiesTabChanged(self, currentIndex):
self.ui.stackedWidgetViews.setCurrentIndex(currentIndex)
Expand Down Expand Up @@ -691,7 +691,7 @@ def group1ColourDlg(self):
if colour.isValid():
self.setGroup1Colour(colour)

def setGroup1Colour(self, colour, bUpdatePlot = True):
def setGroup1Colour(self, colour, bUpdatePlot=True):
colourStr = str(colour.red()) + ',' + str(colour.green()) + ',' + str(colour.blue())
self.ui.btnGroup1Colour.setStyleSheet('* { background-color: rgb(' + colourStr + ') }')
self.preferences['Group colours'][self.groupProfile.groupName1] = colour
Expand All @@ -706,7 +706,7 @@ def group2ColourDlg(self):
if colour.isValid():
self.setGroup2Colour(colour)

def setGroup2Colour(self, colour, bUpdatePlot = True):
def setGroup2Colour(self, colour, bUpdatePlot=True):
colourStr = str(colour.red()) + ',' + str(colour.green()) + ',' + str(colour.blue())
self.ui.btnGroup2Colour.setStyleSheet('* { background-color: rgb(' + colourStr + ') }')
self.preferences['Group colours'][self.groupProfile.groupName2] = colour
Expand Down Expand Up @@ -757,7 +757,7 @@ def loadProfile(self):
QtGui.QMessageBox.information(self, 'Error reading profile file', errMsg, QtGui.QMessageBox.Warning)
return
except:
QtGui.QMessageBox.information(self, 'Error reading profile file','Unknown parsing error.', QtGui.QMessageBox.Warning)
QtGui.QMessageBox.information(self, 'Error reading profile file', 'Unknown parsing error.', QtGui.QMessageBox.Warning)
return

self.metadata = None
Expand Down Expand Up @@ -800,7 +800,7 @@ def loadProfile(self):
# indicate the hierarchical level of interest has changed
bGroupLegendVisibility = self.groupLegendDlg.isVisible()
if platform.system() != 'Windows' and bGroupLegendVisibility:
self.groupLegendDlg.setVisible(False) # HACK: OS X crashes if this dialog is open when loading data for the first time!
self.groupLegendDlg.setVisible(False) # HACK: OS X crashes if this dialog is open when loading data for the first time!

self.multiGroupHierarchicalLevelsChanged()
self.groupHierarchicalLevelsChanged()
Expand Down Expand Up @@ -829,7 +829,7 @@ def populateGroupComboBoxes(self):

def parentLevelChanged(self):
parentDepth = self.profileTree.getHierarchicalLevelDepth(str(self.ui.cboParentalLevel.currentText()))
profileDepth= self.profileTree.getHierarchicalLevelDepth(str(self.ui.cboProfileLevel.currentText()))
profileDepth = self.profileTree.getHierarchicalLevelDepth(str(self.ui.cboProfileLevel.currentText()))
if parentDepth >= profileDepth:
QtGui.QMessageBox.information(self, 'Invalid profile', 'The parent level must be higher in the hierarchy than the profile level.', QtGui.QMessageBox.Warning)
self.ui.cboParentalLevel.setCurrentIndex(0)
Expand All @@ -840,11 +840,11 @@ def parentLevelChanged(self):

def profileLevelChanged(self):
parentDepth = self.profileTree.getHierarchicalLevelDepth(str(self.ui.cboParentalLevel.currentText()))
profileDepth= self.profileTree.getHierarchicalLevelDepth(str(self.ui.cboProfileLevel.currentText()))
profileDepth = self.profileTree.getHierarchicalLevelDepth(str(self.ui.cboProfileLevel.currentText()))

if profileDepth <= parentDepth:
QtGui.QMessageBox.information(self, 'Invalid profile', 'The profile level must be deeper in the hierarchy than the parent level.', QtGui.QMessageBox.Warning)
self.ui.cboProfileLevel.setCurrentIndex(len(self.profileTree.hierarchyHeadings)-1)
self.ui.cboProfileLevel.setCurrentIndex(len(self.profileTree.hierarchyHeadings) - 1)
return

self.sampleHierarchicalLevelsChanged()
Expand Down Expand Up @@ -874,7 +874,7 @@ def sampleHierarchicalLevelsChanged(self):
profileIndex = self.profileTree.hierarchyHeadings.index(profileHeading)
self.ui.cboSampleHighlightHierarchy.clear()
self.ui.cboSampleHighlightHierarchy.addItem('None')
for header in self.profileTree.hierarchyHeadings[0:profileIndex+1]:
for header in self.profileTree.hierarchyHeadings[0:profileIndex + 1]:
self.ui.cboSampleHighlightHierarchy.addItem(header)
self.ui.cboSampleHighlightHierarchy.setCurrentIndex(0)

Expand Down Expand Up @@ -911,7 +911,7 @@ def groupHierarchicalLevelsChanged(self):
profileIndex = self.profileTree.hierarchyHeadings.index(profileHeading)
self.ui.cboGroupHighlightHierarchy.clear()
self.ui.cboGroupHighlightHierarchy.addItem('None')
for header in self.profileTree.hierarchyHeadings[0:profileIndex+1]:
for header in self.profileTree.hierarchyHeadings[0:profileIndex + 1]:
self.ui.cboGroupHighlightHierarchy.addItem(header)
self.ui.cboGroupHighlightHierarchy.setCurrentIndex(0)

Expand Down Expand Up @@ -940,7 +940,7 @@ def multiGroupHierarchicalLevelsChanged(self):
profileIndex = self.profileTree.hierarchyHeadings.index(profileHeading)
self.ui.cboMultiGroupHighlightHierarchy.clear()
self.ui.cboMultiGroupHighlightHierarchy.addItem('None')
for header in self.profileTree.hierarchyHeadings[0:profileIndex+1]:
for header in self.profileTree.hierarchyHeadings[0:profileIndex + 1]:
self.ui.cboMultiGroupHighlightHierarchy.addItem(header)
self.ui.cboMultiGroupHighlightHierarchy.setCurrentIndex(0)

Expand Down Expand Up @@ -977,7 +977,7 @@ def groupFeaturesTableUpdate(self):
self.preferences['Selected group feature'] = ''

self.groupFeatureTable = GenericTable(tableData, ['Feature', 'Diff. between means', 'p-value', 'Corrected p-value', 'Note'], self)
self.groupFeatureTable.sort(0,QtCore.Qt.AscendingOrder) # start with features in alphabetical order
self.groupFeatureTable.sort(0, QtCore.Qt.AscendingOrder) # start with features in alphabetical order

self.ui.tableGroupFeatures.horizontalHeader().setStretchLastSection(True)
self.ui.tableGroupFeatures.setModel(self.groupFeatureTable)
Expand Down Expand Up @@ -1007,7 +1007,7 @@ def multiGroupFeaturesTableUpdate(self):
self.preferences['Selected multiple group feature'] = ''

self.multiGroupFeatureTable = GenericTable(tableData, ['Feature', 'Eta-squared', 'p-value', 'Corrected p-value', 'Note'], self)
self.multiGroupFeatureTable.sort(0,QtCore.Qt.AscendingOrder) # start with features in alphabetical order
self.multiGroupFeatureTable.sort(0, QtCore.Qt.AscendingOrder) # start with features in alphabetical order

self.ui.tableMultiGroupFeatures.horizontalHeader().setStretchLastSection(True)
self.ui.tableMultiGroupFeatures.setModel(self.multiGroupFeatureTable)
Expand Down Expand Up @@ -1045,7 +1045,7 @@ def sampleRunTest(self):
self.ui.cboUnclassified.currentText())

# show progress of test
progress = QtGui.QProgressDialog('Running two-sample statistical test...', 'Cancel', 0, len(self.sampleProfile.getFeatures())+1, self)
progress = QtGui.QProgressDialog('Running two-sample statistical test...', 'Cancel', 0, len(self.sampleProfile.getFeatures()) + 1, self)
progress.setWindowTitle('Progress')
progress.setWindowModality(QtCore.Qt.WindowModal)
progress.setVisible(True)
Expand Down Expand Up @@ -1093,7 +1093,7 @@ def groupRunTest(self):
self.setGroup2Colour(self.preferences['All other samples colour'])

# show progress of test
progress = QtGui.QProgressDialog('Running two-group statistical test...', 'Cancel', 0, len(self.groupProfile.getFeatures())+1, self)
progress = QtGui.QProgressDialog('Running two-group statistical test...', 'Cancel', 0, len(self.groupProfile.getFeatures()) + 1, self)
progress.setWindowTitle('Progress')
progress.setWindowModality(QtCore.Qt.WindowModal)
progress.setVisible(True)
Expand Down Expand Up @@ -1133,7 +1133,7 @@ def multiGroupRunTest(self):

if len(self.multiGroupProfile.activeGroupNames) >= 2:
# show progress of test
progress = QtGui.QProgressDialog('Running multiple groups statistical test...', 'Cancel', 0, len(self.multiGroupProfile.getFeatures())+1, self)
progress = QtGui.QProgressDialog('Running multiple groups statistical test...', 'Cancel', 0, len(self.multiGroupProfile.getFeatures()) + 1, self)
progress.setWindowTitle('Progress')
progress.setWindowModality(QtCore.Qt.WindowModal)
progress.setVisible(True)
Expand Down Expand Up @@ -1558,7 +1558,7 @@ def sampleHighlightHierarchyChanged(self):
featureStrList.append(feature)

self.ui.cboSampleHighlightFeature.clear()
self.ui.cboSampleHighlightFeature.insertItems(len(featureStrList),featureStrList)
self.ui.cboSampleHighlightFeature.insertItems(len(featureStrList), featureStrList)
self.ui.cboSampleHighlightFeature.setCurrentIndex(0)

self.ui.cboSampleHighlightFeature.adjustSize()
Expand Down Expand Up @@ -1586,7 +1586,7 @@ def groupHighlightHierarchyChanged(self):
featureStrList.append(feature)

self.ui.cboGroupHighlightFeature.clear()
self.ui.cboGroupHighlightFeature.insertItems(len(featureStrList),featureStrList)
self.ui.cboGroupHighlightFeature.insertItems(len(featureStrList), featureStrList)
self.ui.cboGroupHighlightFeature.setCurrentIndex(0)

self.ui.cboGroupHighlightFeature.adjustSize()
Expand Down Expand Up @@ -1614,7 +1614,7 @@ def multiGroupHighlightHierarchyChanged(self):
featureStrList.append(feature)

self.ui.cboMultiGroupHighlightFeature.clear()
self.ui.cboMultiGroupHighlightFeature.insertItems(len(featureStrList),featureStrList)
self.ui.cboMultiGroupHighlightFeature.insertItems(len(featureStrList), featureStrList)
self.ui.cboMultiGroupHighlightFeature.setCurrentIndex(0)

self.ui.cboMultiGroupHighlightFeature.adjustSize()
Expand Down Expand Up @@ -1691,7 +1691,7 @@ def saveImageDlg(self):
if f != '':
self.preferences['Last directory'] = f[0:f.lastIndexOf('/')]
try:
if f[len(f)-3:len(f)] == 'png' or f[len(f)-3:len(f)] == 'PNG':
if f[len(f) - 3:len(f)] == 'png' or f[len(f) - 3:len(f)] == 'PNG':
dpi, ok = QtGui.QInputDialog.getInteger(self, 'Desired resolution', 'Enter desired resolution (DPI) of image:', 300)
if ok:
plotToSave.save(str(f), dpi)
Expand Down Expand Up @@ -1760,28 +1760,28 @@ def closeEvent(self, event):
settings.setValue('Preferences/Minimum reported p-value exponent', self.preferences['Minimum reported p-value exponent'])

def exceptHook(exc_type, exc_value, exc_traceback):
## Copyright (c) 2002-2007 Pascal Varet <[email protected]>
##
## Originally part of Spyrit.
# # Copyright (c) 2002-2007 Pascal Varet <[email protected]>
# #
# # Originally part of Spyrit.

import traceback

## KeyboardInterrupt is a special case.
## We don't raise the error dialog when it occurs.
if issubclass( exc_type, KeyboardInterrupt ):
# # KeyboardInterrupt is a special case.
# # We don't raise the error dialog when it occurs.
if issubclass(exc_type, KeyboardInterrupt):
if qApp():
qApp().quit()
return

filename, line, dummy, dummy = traceback.extract_tb( exc_traceback ).pop()
filename = os.path.basename( filename )
error = "%s: %s" % ( exc_type.__name__, exc_value)
filename, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop()
filename = os.path.basename(filename)
error = "%s: %s" % (exc_type.__name__, exc_value)

QtGui.QMessageBox.critical(None, "Unknown error...",
"<center>An error has occured:<br/><br/>"
+ "<b><i>%s</i></b><br/>" % error
+ "It occured at <b>line %d</b> of file <b>%s</b>.<br/>" % ( line, filename )
+ "</center>" )
+ "It occured at <b>line %d</b> of file <b>%s</b>.<br/>" % (line, filename)
+ "</center>")

def main():
# ignore numpy warnings as invalid results are handled within STAMP
Expand Down Expand Up @@ -1816,7 +1816,7 @@ def main():
workingDir = getMainDir()
preferences['Last directory'] = ''
if 'STAMP.app/Contents/Resources' in workingDir:
workingDir = workingDir[0:len(workingDir)-len('/STAMP.app/Contents/Resources')]
workingDir = workingDir[0:len(workingDir) - len('/STAMP.app/Contents/Resources')]
preferences['Last directory'] = workingDir
os.chdir(workingDir)

Expand All @@ -1826,23 +1826,23 @@ def main():
# the program icon is displayed in the taskbar instead of the generic
# Python icon.
import ctypes
myappid = 'beikolab.software.stamp.2' # arbitrary string
myappid = 'beikolab.software.stamp.2' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

if (platform.system() == 'Windows' and len(sys.argv) == 1) or (platform.system() != 'Windows' and len(sys.argv) <= 2):
sys.excepthook = exceptHook
app = QtGui.QApplication(sys.argv)

if(False): # profile code
if(False): # profile code
import cProfile
cProfile.run('mainWindow = MainWindow(preferences)', 'profile.txt')
##########################################
##########################################
# Use this in python console!
#import pstats
#p = pstats.Stats('profile.txt')
#p.sort_stats('cumulative').print_stats(10)
#p.sort_stats('time').print_stats(10)
# import pstats
# p = pstats.Stats('profile.txt')
# p.sort_stats('cumulative').print_stats(10)
# p.sort_stats('time').print_stats(10)
##########################################
##########################################
else:
Expand Down

0 comments on commit 896b894

Please sign in to comment.