-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCircuitscapeProvider.py
134 lines (109 loc) · 5.12 KB
/
CircuitscapeProvider.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# -*- coding: utf-8 -*-
"""
***************************************************************************
CircuitscapeProvider.py
---------------------
Date : May 2014
Copyright : (C) 2014 by Alexander Bruy
Email : alexander dot bruy at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Alexander Bruy'
__date__ = 'May 2014'
__copyright__ = '(C) 2014, Alexander Bruy'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import os
from PyQt4.QtGui import *
from processing.core.AlgorithmProvider import AlgorithmProvider
from processing.core.ProcessingConfig import Setting, ProcessingConfig
from processing.tools import system
from processing_circuitscape.Pairwise import Pairwise
from processing_circuitscape.OneToAll import OneToAll
from processing_circuitscape.Advanced import Advanced
from processing_circuitscape.CircuitscapeUtils import CircuitscapeUtils
class CircuitscapeProvider(AlgorithmProvider):
def __init__(self):
AlgorithmProvider.__init__(self)
self.activate = False
self.alglist = [Pairwise(), OneToAll(), Advanced()]
for alg in self.alglist:
alg.provider = self
def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
if system.isWindows():
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.CIRCUITSCAPE_FOLDER,
'Circuitscape folder',
CircuitscapeUtils.circuitscapePath()))
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.LOG_COMMANDS,
'Log execution commands',
True))
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.LOG_CONSOLE,
'Log console output',
True))
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.FOUR_NEIGHBOURS,
'Connect raster cells to four neighbors instead of eight',
False))
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.AVERAGE_CONDUCTANCE,
'Use average conductance instead of resistance for connections '
'between cells',
False))
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.PREEMPT_MEMORY,
'Preemptively release memory when possible',
False))
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.MAX_CURRENT_MAPS,
'Write maximum of current maps',
False))
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.CUM_MAX_MAPS,
'Write cumulative & maximum current maps only',
False))
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.ZERO_FOCAL,
'Set focal nodes currents to zero',
False))
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.LOG_TRANSFORM,
'Log-transform current maps',
False))
ProcessingConfig.addSetting(Setting(self.getDescription(),
CircuitscapeUtils.COMPRESS_OUTPUT,
'Compress output grids',
False))
def unload(self):
AlgorithmProvider.unload(self)
if system.isWindows():
ProcessingConfig.removeSetting(
CircuitscapeUtils.CIRCUITSCAPE_FOLDER)
ProcessingConfig.removeSetting(CircuitscapeUtils.LOG_COMMANDS)
ProcessingConfig.removeSetting(CircuitscapeUtils.LOG_CONSOLE)
ProcessingConfig.removeSetting(CircuitscapeUtils.FOUR_NEIGHBOURS)
ProcessingConfig.removeSetting(CircuitscapeUtils.AVERAGE_CONDUCTANCE)
ProcessingConfig.removeSetting(CircuitscapeUtils.PREEMPT_MEMORY)
ProcessingConfig.removeSetting(CircuitscapeUtils.MAX_CURRENT_MAPS)
ProcessingConfig.removeSetting(CircuitscapeUtils.CUM_MAX_MAPS)
ProcessingConfig.removeSetting(CircuitscapeUtils.ZERO_FOCAL)
ProcessingConfig.removeSetting(CircuitscapeUtils.LOG_TRANSFORM)
ProcessingConfig.removeSetting(CircuitscapeUtils.COMPRESS_OUTPUT)
def getName(self):
return 'Circuitscape'
def getDescription(self):
return 'Circuitscape'
def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/icons/circuitscape.png')
def _loadAlgorithms(self):
self.algs = self.alglist