Skip to content

Commit

Permalink
add command interface to extract list of residues that are in a giv…
Browse files Browse the repository at this point in the history
…en interface (#4)

* add `list_interface`

* add `test_get_true_interface`

* chore: Update regex dependencies to latest versions

* update README.md
  • Loading branch information
rvhonorato authored Jun 12, 2024
1 parent e949f20 commit 899e481
Show file tree
Hide file tree
Showing 5 changed files with 1,029 additions and 7 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

A standalone command-line application to generate restraints to be used in HADDOCK.

## Commands

- [`tbl`: Generate TBL file from input file](#tbl-command)
- [`ti`: Generate true-interface restraints from a PDB file](#ti-command)
- [`restraint`: Generate Unambiguous restraints to keep molecules together during docking](#restraint-command)
- [`interface`: List residues in the interface](#interface-command)

## Planned features

- [x] Generate `.tbl` files from an input file
Expand All @@ -16,7 +23,7 @@ A standalone command-line application to generate restraints to be used in HADDO
- [x] Generate _true-interface_ restraints for benchmarking
- [x] Create unambiguous restraints to keep molecules together during docking
- [x] Filter out buried residues
- [ ] List residues in the interface
- [x] List residues in the interface
- [ ] Specify atom subsets
- [ ] ~Generate random-restraints~ done via CNS

Expand All @@ -40,10 +47,12 @@ Commands:
tbl Generate TBL file from input file
ti Generate true-interface restraints from a PDB file
restraint Generate Unambiguous restraints to keep molecules together during docking
interface List residues in the interface
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help
-V, --version Print version
```

### `ti` command
Expand Down Expand Up @@ -170,6 +179,31 @@ Example:
./haddock-restraints restraint examples/2oob_w_gaps.pdb > unambiguous.tbl
```

### `interface` command

```bash
$ ./haddock-restraints interface -h
List residues in the interface

Usage: haddock-restraints interface <INPUT> <CUTOFF>

Arguments:
<INPUT> PDB file
<CUTOFF> Cutoff distance for interface residues

Options:
-h, --help Print help
```

Example:

```bash
./haddock-restraints interface examples/2oob.pdb 5.0

Chain A: [931, 933, 934, 936, 937, 938, 940, 941, 946, 950]
Chain B: [6, 8, 42, 44, 45, 46, 47, 48, 49, 66, 68, 69, 70]
```

***

## Troubleshooting
Expand Down
30 changes: 30 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ enum Commands {
#[arg(help = "PDB file")]
input: String,
},
#[command(about = "List residues in the interface")]
Interface {
#[arg(help = "PDB file")]
input: String,
#[arg(help = "Cutoff distance for interface residues")]
cutoff: f64,
},
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -51,6 +58,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Commands::Restraint { input } => {
let _ = restraint_bodies(input);
}
Commands::Interface { input, cutoff } => {
let _ = list_interface(input, cutoff);
}
}

Ok(())
Expand Down Expand Up @@ -180,3 +190,23 @@ fn restraint_bodies(input_file: &str) -> Result<(), Box<dyn Error>> {

Ok(())
}

fn list_interface(input_file: &str, cutoff: &f64) -> Result<(), Box<dyn Error>> {
let pdb = match pdbtbx::open_pdb(input_file, pdbtbx::StrictnessLevel::Loose) {
Ok((pdb, _warnings)) => pdb,
Err(e) => {
panic!("Error opening PDB file: {:?}", e);
}
};

let true_interface = structure::get_true_interface(&pdb, *cutoff);

for (chain_id, residues) in true_interface.iter() {
let mut sorted_res = residues.iter().collect::<Vec<_>>();
sorted_res.sort();

println!("Chain {}: {:?}", chain_id, sorted_res);
}

Ok(())
}
34 changes: 34 additions & 0 deletions src/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,37 @@ pub fn find_structural_gaps(pdb: &pdbtbx::PDB) -> Vec<Gap> {

gaps
}

#[cfg(test)]
mod tests {

use std::env;

use super::*;

#[test]
fn test_get_true_interface() {
let pdb_path = env::current_dir().unwrap().join("tests/data/complex.pdb");

let pdb = pdbtbx::open_pdb(pdb_path.to_str().unwrap(), pdbtbx::StrictnessLevel::Loose)
.unwrap()
.0;

let observed_true_interface = get_true_interface(&pdb, 5.0);

let mut expected_true_interface: HashMap<String, HashSet<isize>> = HashMap::new();
let chain_a = "A".to_string();
let res_a: HashSet<isize> = vec![934, 936, 933, 946, 950, 938, 940, 941, 937, 931]
.into_iter()
.collect();
let chain_b = "B";
let res_b: HashSet<isize> = vec![66, 48, 68, 49, 46, 45, 44, 47, 69, 6, 70, 8, 42]
.into_iter()
.collect();

expected_true_interface.insert(chain_a, res_a);
expected_true_interface.insert(chain_b.to_string(), res_b);

assert_eq!(observed_true_interface, expected_true_interface);
}
}
Loading

0 comments on commit 899e481

Please sign in to comment.