mirror of
https://github.com/dnlbauer/WHAM.git
synced 2026-09-10 22:25:31 +00:00
fix multidimensional io
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#x Free Energy Probability
|
#coord1 Free Energy Probability
|
||||||
-3.108600 7.118166 0.003561
|
-3.108600 7.118166 0.003561
|
||||||
-3.045800 5.331290 0.007290
|
-3.045800 5.331290 0.007290
|
||||||
-2.983000 3.879241 0.013048
|
-2.983000 3.879241 0.013048
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#x Free Energy Probability
|
#coord1 coord2 Free Energy Probability
|
||||||
-3.109590 -3.109590 10.330312 0.000095
|
-3.109590 -3.109590 10.330312 0.000095
|
||||||
-3.046770 -3.109590 8.907360 0.000168
|
-3.046770 -3.109590 8.907360 0.000168
|
||||||
-2.983950 -3.109590 7.431969 0.000303
|
-2.983950 -3.109590 7.431969 0.000303
|
||||||
|
|||||||
@@ -176,16 +176,18 @@ fn read_window_file(window_file: &str, cfg: &Config) -> Option<Histogram> {
|
|||||||
Some(Histogram::new(num_points as u32, hist))
|
Some(Histogram::new(num_points as u32, hist))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO multidimensional output
|
|
||||||
pub fn write_results(out_file: &str, ds: &Dataset, free: &Vec<f64>, prob: &Vec<f64>) -> Result<(), Box<Error>> {
|
pub fn write_results(out_file: &str, ds: &Dataset, free: &Vec<f64>, prob: &Vec<f64>) -> Result<(), Box<Error>> {
|
||||||
let output = File::create(out_file)?;
|
let output = File::create(out_file)?;
|
||||||
let mut buf = BufWriter::new(output);
|
let mut buf = BufWriter::new(output);
|
||||||
writeln!(buf, "#{}\t{}\t{}", "x", "Free Energy", "Probability"); // TODO better format (coord1, coord2..)
|
|
||||||
|
|
||||||
|
let header: String = (0..ds.dimens_lengths.len()).map(|d| {format!("coord{}", d+1)}).collect::<Vec<String>>().join(" ");
|
||||||
|
writeln!(buf, "#{} {} {}", header, "Free Energy", "Probability");
|
||||||
for bin in 0..free.len() {
|
for bin in 0..free.len() {
|
||||||
let coords = ds.get_coords_for_bin(bin);
|
let coords = ds.get_coords_for_bin(bin);
|
||||||
let coords_str: String = coords.iter().map(|c| {format!("{:8.6} ", c)})
|
let coords_str: String = coords.iter().map(|c| {format!("{:8.6} ", c)})
|
||||||
.collect::<Vec<String>>().join("\t");
|
.collect::<Vec<String>>().join("\t");
|
||||||
writeln!(buf, "{}\t{:8.6}\t{:8.6}", coords_str, free[bin], prob[bin])?;
|
writeln!(buf, "{}{:8.6} {:8.6}", coords_str, free[bin], prob[bin])?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user