11from paths_cli .wizard .tools import a_an
22from paths_cli .wizard .core import get_missing_object
3- from paths_cli .wizard .shooting import (
4- shooting ,
5- # ALGORITHMS
6- one_way_shooting ,
7- two_way_shooting ,
8- spring_shooting ,
9- # SELECTORS
10- uniform_selector ,
11- gaussian_selector ,
12- # MODIFIERS
13- random_velocities ,
14- # all_atom_delta_v,
15- # single_atom_delta_v,
16- )
3+ from paths_cli .wizard .shooting import shooting
174from functools import partial
185
19- def _select_states (wizard , state_type ):
20- # TODO: change this significantly ... I dislike in usage
21- states = []
22- do_another = True
23- while do_another :
24- options = [name for name in wizard .states
25- if name not in states ]
26- done = f"No more { state_type } states to select"
27- if len (states ) >= 1 :
28- options .append (done )
29-
30- state = wizard .ask_enumerate (
31- f"Pick a state to use for as { a_an (state_type )} { state_type } "
32- "state" , options = options
33- )
34- if state == done :
35- do_another = False
36- else :
37- states .append (state )
38-
39- state_objs = [wizard .states [state ] for state in states ]
40- return state_objs
41-
42- def _get_pathlength (wizard ):
43- # redo as get_custom_eval with int type
44- pathlength = None
45- while pathlength is None :
46- len_str = wizard .ask ("How long (in frames) do you want yout "
47- "trajectories to be?" )
48- try :
49- pathlength = int (len_str )
50- except Exceptions as e :
51- wizard .exception (f"Sorry, I couldn't make '{ len_str } ' into "
52- "an integer." , e )
53- return pathlength
54-
55- def flex_length_tps_network (wizard ):
56- import openpathsampling as paths
57- initial_states = _select_states (wizard , 'initial' )
58- final_states = _select_states (wizard , 'final' )
59- network = paths .TPSNetwork (initial_states , final_states )
60- return network
61-
62- def fixed_length_tps_network (wizard ):
63- import openpathsampling as paths
64- pathlength = _get_pathlength (wizard )
65- initial_states = _select_states (wizard , 'initial' )
66- final_states = _select_states (wizard , 'final' )
67- network = paths .FixedLengthTPSNetwork (initial_states , final_states ,
68- length = pathlength )
69- return network
70-
71- def tps_network (wizard ):
72- import openpathsampling as paths
73- FIXED = "Fixed length TPS"
74- FLEX = "Flexible length TPS"
75- tps_types = {
76- FLEX : paths .TPSNetwork ,
77- FIXED : paths .FixedLengthTPSNetwork ,
78- }
79- network_type = None
80- network_type = wizard .ask_enumerate (
81- "Do you want to do flexible path length TPS (recommended) "
82- "or fixed path length TPS?" , options = list (tps_types .keys ())
83- )
84- network_class = tps_types [network_type ]
85-
86- if network_type == FIXED :
87- pathlength = _get_pathlength (wizard )
88- network_class = partial (network_class , length = pathlength )
89-
90- initial_states = _select_states (wizard , 'initial' )
91- final_states = _select_states (wizard , 'final' )
92-
93- # TODO: summary
94-
95- obj = network_class (initial_states , final_states )
96- return obj
97-
986def _get_network (wizard ):
997 if len (wizard .networks ) == 0 :
1008 network = tps_network (wizard )
@@ -121,16 +29,3 @@ def tps_scheme(wizard, network=None):
12129 scheme .append (shooting_strategy )
12230 scheme .append (global_strategy )
12331 return scheme
124-
125- def tps_setup (wizard ):
126- network = tps_network (wizard )
127- scheme = tps_scheme (wizard , network )
128- # name it
129- # provide final info on how to use it
130- return scheme
131-
132-
133- if __name__ == "__main__" :
134- from paths_cli .wizard .wizard import Wizard
135- wiz = Wizard ({'tps_network' : ('networks' , 1 , '=' ),
136- 'tps_scheme' : ('schemes' , 1 , '=' )})
0 commit comments