@@ -2,7 +2,7 @@ extern crate serde;
2
2
extern crate serde_json;
3
3
extern crate npy;
4
4
5
- use lightdock:: GSO ;
5
+ use lightdock:: { swarm , GSO } ;
6
6
use lightdock:: constants:: { DEFAULT_LIGHTDOCK_PREFIX , DEFAULT_SEED , DEFAULT_REC_NM_FILE , DEFAULT_LIG_NM_FILE } ;
7
7
use lightdock:: scoring:: { Score , Method } ;
8
8
use lightdock:: dfire:: DFIRE ;
@@ -124,9 +124,10 @@ fn run() {
124
124
}
125
125
}
126
126
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_" ) )
130
131
. and_then ( |s| s. strip_suffix ( ".dat" ) )
131
132
. and_then ( |s| s. parse :: < i32 > ( ) . ok ( ) )
132
133
}
@@ -143,7 +144,8 @@ fn simulate(setup: &SetupFile, swarm_filename: &str, steps: u32, method: Method)
143
144
} ;
144
145
145
146
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" ) ;
147
149
println ! ( "Swarm ID {:?}" , swarm_id) ;
148
150
let swarm_directory = format ! ( "swarm_{}" , swarm_id) ;
149
151
0 commit comments