Skip to content

Commit

Permalink
Merge pull request #1 from Ladme/v1.2.0
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
Ladme authored Jan 13, 2024
2 parents 1b2eea6 + d6785e0 commit 5253886
Show file tree
Hide file tree
Showing 27 changed files with 2,341 additions and 208 deletions.
118 changes: 103 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "gcenter"
authors = ["Ladislav Bartos <ladmeb@gmail.com>"]
description = "Center Any Group in a Gromacs Trajectory"
version = "1.1.1"
version = "1.2.0"
license = "MIT"
edition = "2021"
repository = "https://github.com/Ladme/gcenter"
Expand All @@ -16,7 +16,7 @@ exclude = ["/tests"]
backitup = "0.1.1"
clap = { version = "4.4.3", features = ["derive"] }
colored = "2.0.4"
groan_rs = "0.4.1"
groan_rs = "0.6.1"
thiserror = "1.0.48"

[dev-dependencies]
Expand Down
25 changes: 22 additions & 3 deletions src/argparse.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Released under MIT License.
// Copyright (c) 2023 Ladislav Bartos
// Copyright (c) 2023-2024 Ladislav Bartos

//! Implementation of a command line argument parser.
Expand Down Expand Up @@ -66,7 +66,8 @@ If the simulation steps coincide, only the first of these frames is centered and
long = "reference",
help = "Group to center",
default_value = "Protein",
long_help = "Specify the group to be centered. Use VMD-like 'groan selection language' to define the group. This language also supports ndx group names."
long_help = "Specify the group to be centered. Use VMD-like 'groan selection language' to define the group. This language also supports ndx group names.",
value_parser = validate_reference
)]
pub reference: String,

Expand Down Expand Up @@ -125,6 +126,15 @@ If the simulation steps coincide, only the first of these frames is centered and
)]
pub zdimension: bool,

#[arg(
long = "com",
action,
help = "Center frames using center of mass",
default_value_t = false,
long_help = "Use center of mass instead of center of geometry when centering the reference group. This requires information about atom masses. If not explicitely provided, the masses are guessed."
)]
pub com: bool,

#[arg(
long = "silent",
action,
Expand Down Expand Up @@ -161,6 +171,15 @@ fn validate_trajectory_type(s: &str) -> Result<String, String> {
}
}

/// Validate that the GSL query does not contain any unsupported keywords.
fn validate_reference(s: &str) -> Result<String, String> {
if s.contains("molecule with") || s.contains("mol with") {
Err(String::from("gcenter does not employ connectivity and therefore does not support GSL keyword `molecule with`"))
} else {
Ok(s.to_owned())
}
}

/// Perform various sanity checks:
/// a) Check that the input and output files are not identical.
/// This protects the user from accidentaly overwriting their data.
Expand Down Expand Up @@ -214,7 +233,7 @@ fn sanity_check_inputs(args: &Args) -> Result<(), RunError> {
}
}

pub fn parse() -> Result<Args, Box<dyn std::error::Error>> {
pub fn parse() -> Result<Args, Box<dyn std::error::Error + Send + Sync>> {
let args = Args::parse();
sanity_check_inputs(&args)?;

Expand Down
Loading

0 comments on commit 5253886

Please sign in to comment.