-
Notifications
You must be signed in to change notification settings - Fork 2
/
calculateMetrics.py
56 lines (54 loc) · 1.98 KB
/
calculateMetrics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
from ecosystemDataManager.ecosystemDataManager import EcosystemDataManager
def isValidArguments(arguments):
options = ["evaluate", "globalrate", "globalmean", "contextsize", "proportion"]
for argument in arguments:
if argument not in options:
return False
return True
if __name__ == '__main__':
if len(sys.argv) < 2 or not isValidArguments(sys.argv[2:]):
print("Usage:", sys.argv[0], "<ecosystem> [evaluate] [globalrate] [globalmean] [contextsize] [proportion]")
sys.exit(1)
if len(sys.argv) == 2:
print("no options provided. calculating all metrics")
options = ["evaluate", "globalrate", "globalmean", "contextsize", "proportion"]
else:
options = [argument for argument in sys.argv[2:]]
ecosystem = sys.argv[1]
ecosystemDataManager = EcosystemDataManager(ecosystem)
if "evaluate" in options:
print("evaluating edges")
ecosystemDataManager.evaluateEdges()
print("saving")
ecosystemDataManager.save()
print("done")
else:
print("assuming that edges are already evaluated")
if "globalrate" in options or "globalmean" in options:
if "globalrate" in options and "globalmean" in options:
print("calculating both globalrate and globalmean metrics")
ecosystemDataManager.calculateGlobalRegularityMetrics()
else:
print("calculate globalrate and globalmean together is faster")
if "globalrate" in options:
print("calculating globalrate")
ecosystemDataManager.calculateGlobalRegularityRate()
elif "globalmean" in options:
print("calculating globalmean")
ecosystemDataManager.calculateGlobalRegularityMean()
print("saving")
ecosystemDataManager.save()
print("done")
if "contextsize" in options:
print("calculating contextsize")
ecosystemDataManager.calculateContextSize()
print("saving")
ecosystemDataManager.save()
print("done")
if "proportion" in options:
print("calculating proportion")
ecosystemDataManager.proportion()
print("in case rates or means has to been calculated: saving")
ecosystemDataManager.save()
print("done")