Skip to content

Commit ef56109

Browse files
committed
L statistic window
1 parent 004e2a7 commit ef56109

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

CommandLineFiles/CalculateGeneralizedDStatistic.py

+28
Original file line numberDiff line numberDiff line change
@@ -1272,3 +1272,31 @@ def calculate_generalized(alignment, species_tree, reticulations, verbose=False)
12721272
print trees_of_interest
12731273
increase, decrease = determine_patterns(trees_of_interest, trees_to_equality, patterns_pgN)
12741274
print generate_statistic_string((increase, decrease))
1275+
1276+
1277+
## Changing Network to Species Tree
1278+
def network_to_species_tree(network):
1279+
"""
1280+
1281+
:param network:
1282+
:return:
1283+
"""
1284+
# remove H1...
1285+
spec1 = re.sub('(#H\d\W\d\W+\d.\d+\W+)', '', network)
1286+
print spec1
1287+
# remove extra parentheses - this is v good
1288+
spec2 = re.sub('\((P\d+)\)', r'\1 ', spec1)
1289+
print spec2
1290+
# adds colon back in?? bad probably
1291+
spec3 = re.sub(' ', ':', spec2)
1292+
print spec3
1293+
# removes extras again?? this is bad
1294+
spec4 = re.sub('(,\()', ',', spec3)
1295+
print spec4
1296+
# removes extra colons
1297+
spectree = re.sub('(::)', ':', spec4)
1298+
1299+
return spectree
1300+
1301+
print 'output', network_to_species_tree(network)
1302+
print "should be", species_tree

main.py

+11
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ def displayDStatistic(self, dVal, dWindows):
247247
self.dStatisticLabel.setEnabled(True)
248248
self.dStatisticValueLabel.setEnabled(True)
249249

250+
# **************************** L STATISTIC PAGE ****************************#
251+
252+
def displayLStatistic(self, lVal, lWindows):
253+
self.lVal = lVal
254+
self.lWindows = lWindows
255+
self.lStatisticWindow = dStatisticWindow.DStatisticWindow(self.lWindows)
256+
257+
self.lStatisticValueLabel.setText(str(self.lVal))
258+
self.lStatisticLabel.setEnabled(True)
259+
self.lStatisticValueLabel.setEnabled(True)
260+
250261
# **************************** MS PAGE ****************************#
251262

252263
additionalFileCounter = 0
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from standardWindow import Window
2+
from PyQt4 import QtGui
3+
import sys
4+
5+
"""
6+
D-Statistic Window
7+
~
8+
Chabrielle Allen
9+
Travis Benedict
10+
Peter Dulworth
11+
"""
12+
13+
class LStatisticWindow(Window):
14+
def __init__(self, lWindows, title='Windows to L Statistic', xLabel='Window Indices', yLabel='L Statistic values'):
15+
Window.__init__(self, windowTitle='L Statistic Window')
16+
17+
self.plotter.stat_scatter(lWindows, title, xLabel=xLabel, yLabel=yLabel)
18+
self.show()
19+
20+
21+
if __name__ == '__main__': # only runs if not imported
22+
23+
# create a new instance of QApplication
24+
app = QtGui.QApplication(sys.argv)
25+
26+
a = {0:0, 2:2, 4:3}
27+
28+
# create window and plot
29+
form = LStatisticWindow(a)
30+
31+
# execute the app
32+
sys.exit(app.exec_())

test_module/test_RAxMLOperations.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ def test_taxon_names_getter(self):
88
self.assertEqual(["Seq0", "Seq1", "Seq2", "Seq3"], raxOps.taxon_names_getter("../exampleFiles/2basePhylip.txt"))
99

1010
def test_raxml_species_tree(self):
11-
self.fail()
11+
raxOps = RAxMLOperations.RAxMLOperations()
12+
print raxOps.raxml_species_tree("../exampleFiles/2basePhylip.txt")
1213

1314
def test_rooter(self):
1415
self.fail()

0 commit comments

Comments
 (0)