Skip to content

Commit

Permalink
[TEMP] Allow connected components with node_count==2
Browse files Browse the repository at this point in the history
  • Loading branch information
khb7840 committed May 28, 2024
1 parent 89f01f0 commit 4a75581
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
1 change: 1 addition & 0 deletions NOTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ QUERYING
- [x] DONE: Matching query and reference positions
- [x] DONE: rayon based parallelization
- [ ] TODO: For partial match, fill in with "_" in the output where the query does not match
- [ ] TODO: Rename features --> default goes to PDBTrRosetta

DEV
- [ ] Write rustdoc
Expand Down
5 changes: 3 additions & 2 deletions src/cli/workflows/query_pdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub fn query_pdb(env: AppArgs) {
);
if retrieve {
// match_count_filter[1] = residue_count;
match_count_filter[1] = if match_count_filter[1] < 3 { 3 } else { match_count_filter[1] };
// match_count_filter[1] = if match_count_filter[1] < 3 { 3 } else { match_count_filter[1] };
}
let mut query_count_vec: Vec<(usize, QueryResult)> = query_count_map.into_iter().filter(|(_k, v)| {
v.total_match_count >= match_count_filter[0] && v.node_count >= match_count_filter[1] &&
Expand Down Expand Up @@ -201,7 +201,7 @@ pub fn query_pdb(env: AppArgs) {
);
if retrieve {
// match_count_filter[1] = residue_count;
match_count_filter[1] = if match_count_filter[1] < 3 { 3 } else { match_count_filter[1] };
// match_count_filter[1] = if match_count_filter[1] < 3 { 3 } else { match_count_filter[1] };
}
let mut query_count_vec: Vec<(usize, QueryResult)> = query_count_map.into_iter().filter(|(_k, v)| {
v.total_match_count >= match_count_filter[0] && v.node_count >= match_count_filter[1] &&
Expand All @@ -220,6 +220,7 @@ pub fn query_pdb(env: AppArgs) {
v.matching_residues = retrieval_result;
});
query_count_vec.retain(|(_, v)| v.matching_residues.len() > 0);
println!("{:?}", query_count_vec.len());
drop(mmap);
drop(match_count_filter);
return query_count_vec;
Expand Down
3 changes: 2 additions & 1 deletion src/controller/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ pub fn connected_components_with_given_node_count(
scc.append(&mut wcc);
// Filter components with the same node count
// scc.retain(|component| component.len() == node_count);
scc.retain(|component| component.len() >= 3);
// Filter components with the node count greater than or equal to the given node count
// scc.retain(|component| component.len() >= 3);

// Uniqueness cheking. Sort all inner vectors and dedup
scc.iter_mut().for_each(|component| component.sort());
Expand Down
40 changes: 29 additions & 11 deletions src/controller/retrieve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,35 @@ pub fn retrieve_with_prefilter(
compact: &CompactStructure, hash: &GeometricHash, prefilter: &Vec<(usize, usize)>, nbin_dist: usize, nbin_angle: usize
) -> Vec<(usize, usize)> {
let mut output: Vec<(usize, usize)> = Vec::new();
for (i, j) in prefilter {
let feature = get_single_feature(*i, *j, compact, hash.hash_type());
if feature.is_some() {
let feature = feature.unwrap();
let curr_hash = if nbin_dist == 0 || nbin_angle == 0 {
GeometricHash::perfect_hash_default(feature, hash.hash_type())
} else {
GeometricHash::perfect_hash(feature, hash.hash_type(), nbin_dist, nbin_angle)
};
if curr_hash == *hash {
output.push((*i, *j));
if prefilter.is_empty() {
let comb = CombinationIterator::new(compact.num_residues);
comb.for_each(|(i, j)| {
let feature = get_single_feature(i, j, compact, hash.hash_type());
if feature.is_some() {
let feature = feature.unwrap();
let curr_hash = if nbin_dist == 0 || nbin_angle == 0 {
GeometricHash::perfect_hash_default(feature, hash.hash_type())
} else {
GeometricHash::perfect_hash(feature, hash.hash_type(), nbin_dist, nbin_angle)
};
if curr_hash == *hash {
output.push((i, j));
}
}
});
} else {
for (i, j) in prefilter {
let feature = get_single_feature(*i, *j, compact, hash.hash_type());
if feature.is_some() {
let feature = feature.unwrap();
let curr_hash = if nbin_dist == 0 || nbin_angle == 0 {
GeometricHash::perfect_hash_default(feature, hash.hash_type())
} else {
GeometricHash::perfect_hash(feature, hash.hash_type(), nbin_dist, nbin_angle)
};
if curr_hash == *hash {
output.push((*i, *j));
}
}
}
}
Expand Down

0 comments on commit 4a75581

Please sign in to comment.