@@ -2,7 +2,7 @@ extern crate serde;
22extern crate serde_json;
33extern crate npy;
44
5- use lightdock:: GSO ;
5+ use lightdock:: { swarm , GSO } ;
66use lightdock:: constants:: { DEFAULT_LIGHTDOCK_PREFIX , DEFAULT_SEED , DEFAULT_REC_NM_FILE , DEFAULT_LIG_NM_FILE } ;
77use lightdock:: scoring:: { Score , Method } ;
88use lightdock:: dfire:: DFIRE ;
@@ -124,9 +124,10 @@ fn run() {
124124 }
125125}
126126
127- fn parse_swarm_id ( filename : & str ) -> Option < i32 > {
128- filename
129- . strip_prefix ( "initial_positions_" )
127+ fn parse_swarm_id ( path : & Path ) -> Option < i32 > {
128+ path. file_name ( )
129+ . and_then ( |s| s. to_str ( ) )
130+ . and_then ( |s| s. strip_prefix ( "initial_positions_" ) )
130131 . and_then ( |s| s. strip_suffix ( ".dat" ) )
131132 . and_then ( |s| s. parse :: < i32 > ( ) . ok ( ) )
132133}
@@ -143,7 +144,8 @@ fn simulate(setup: &SetupFile, swarm_filename: &str, steps: u32, method: Method)
143144 } ;
144145
145146 println ! ( "Reading starting positions from {:?}" , swarm_filename) ;
146- let swarm_id = parse_swarm_id ( swarm_filename) . expect ( "Could not parse swarm from swarm filename" ) ;
147+ let file_path = Path :: new ( swarm_filename) ;
148+ let swarm_id = parse_swarm_id ( file_path) . expect ( "Could not parse swarm from swarm filename" ) ;
147149 println ! ( "Swarm ID {:?}" , swarm_id) ;
148150 let swarm_directory = format ! ( "swarm_{}" , swarm_id) ;
149151
0 commit comments