Skip to content

Commit

Permalink
Add QueryResultFilter module for filtering query results; Set lookup …
Browse files Browse the repository at this point in the history
…sep char to "\t"
  • Loading branch information
khb7840 committed Jan 6, 2025
1 parent 8e53d13 commit c96cb0e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
50 changes: 50 additions & 0 deletions src/controller/filter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Result Filtering module
use crate::controller::rank::QueryResult;

// NOTE: Limiting result with top N results is done in CLI
// This module is for filtering single query result

pub struct QueryResultFilter {
// Filtering parameters that doesn't require residue matching
pub total_hash_match_count: usize,
pub total_hash_match_ratio: f32,
pub node_covered_by_hash_count: usize,
pub node_covered_by_hash_ratio: f32,
pub edge_covered_by_hash_count: usize,
pub edge_covered_by_hash_ratio: f32,
pub idf: f32,
pub nres: usize,
pub plddt: f32,
// Filtering parameters that require residue matching
pub node_covered_by_graph_count: usize,
pub node_covered_by_graph_ratio: f32,
pub rmsd: f32,
}

impl QueryResultFilter {
pub fn new() -> Self {
QueryResultFilter {
total_hash_match_count: 0,
total_hash_match_ratio: 0.0,
node_covered_by_hash_count: 0,
node_covered_by_hash_ratio: 0.0,
edge_covered_by_hash_count: 0,
edge_covered_by_hash_ratio: 0.0,
idf: 0.0,
nres: 0,
plddt: 0.0,
node_covered_by_graph_count: 0,
node_covered_by_graph_ratio: 0.0,
rmsd: 0.0,
}
}
// Filter single query result
pub fn filter(&self, result: &QueryResult) -> bool {
// let mut pass = true;
// if self.total_hash_match_count > 0 {
// pass = pass && result.total_hash_match_count >= self.total_hash_match_count;
// }
todo!()
}

}
1 change: 1 addition & 0 deletions src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2024 Hyunbin Kim, All rights reserved

pub mod feature;
// pub mod filter;
pub mod graph;
pub mod io;
pub mod query;
Expand Down
2 changes: 1 addition & 1 deletion src/index/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn load_lookup_from_file(path: &str) -> Vec<(String, usize, usize, f32)> {
let mmap = unsafe { Mmap::map(&file).expect(&log_msg(FAIL, "Unable to mmap the lookup file")) };
let content = unsafe { std::str::from_utf8_unchecked(&mmap) };
let loaded_lookup = content.par_lines().map(|line| {
let mut split = line.split_whitespace();
let mut split = line.split("\t");
let id = split.next().unwrap().parse::<usize>().unwrap();
let name = split.next().unwrap().to_string();
let nres = split.next().unwrap().parse::<usize>().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/structure/io/fcz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub fn read_foldcomp_db_lookup(db_path: &str) -> Result<Vec<(usize, String)>, &'
let mmap = unsafe { Mmap::map(&lookup_file).unwrap() };
let content = unsafe { std::str::from_utf8_unchecked(&mmap) };
let output = content.par_lines().map(|line| {
let mut split = line.split_whitespace();
let mut split = line.split("\t");
let id = split.next().unwrap().parse::<usize>().unwrap();
let name = split.next().unwrap().to_string();
(id, name)
Expand All @@ -186,7 +186,7 @@ pub fn read_foldcomp_db_index(db_path: &str) -> Result<Vec<(usize, usize, usize)
let mmap = unsafe { Mmap::map(&index_file).unwrap() };
let content = unsafe { std::str::from_utf8_unchecked(&mmap) };
let output = content.par_lines().map(|line| {
let mut split = line.split_whitespace();
let mut split = line.split("\t");
let id = split.next().unwrap().parse::<usize>().unwrap();
let start = split.next().unwrap().parse::<usize>().unwrap();
let length = split.next().unwrap().parse::<usize>().unwrap();
Expand Down

0 comments on commit c96cb0e

Please sign in to comment.