-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df0ad98
commit 2017cbf
Showing
5 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pub mod math; | ||
pub mod molecule; | ||
mod bingo; | ||
mod ringo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
mod index; | ||
mod search; | ||
mod index_item; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
use std::fs::File; | ||
use std::io::{BufRead}; | ||
|
||
use crate::ringo::molecule::smiles::reader::molecule::parse_molecule; | ||
use crate::ringo::ringo::index_item::IndexItem; | ||
|
||
fn index(smiles_file: &str) { | ||
fn index(smiles_file: &str) -> Vec<IndexItem> { | ||
// open file for reading | ||
let fi = File::open(smiles_file).expect("Could not open file"); | ||
|
||
let mut result = Vec::new(); | ||
// open binary file for index | ||
|
||
let mut offset = 0; | ||
// let mut fo = File::create(smiles_file.to_owned() + ".fp"); | ||
for line in std::io::BufReader::new(fi).lines() { | ||
let line = line.unwrap(); | ||
let molecule = parse_molecule(&line).unwrap().1; | ||
// let ecfp = molecule.ecfp(2, 512); | ||
// write ecfp and offset to binary file | ||
result.push(IndexItem::new(offset, molecule.ecfp(2, 512))); | ||
|
||
offset += line.len() + 1; | ||
} | ||
return result; | ||
} | ||
|
||
#[test] | ||
fn test_index() { | ||
index("molecules.smi"); | ||
let result = index("molecules.smi"); | ||
assert_eq!(result.len(), 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use bit_vec::BitVec; | ||
|
||
pub struct IndexItem { | ||
pub position: usize, | ||
pub fingerprint: Vec<u8> | ||
} | ||
|
||
impl IndexItem { | ||
pub fn new(position: usize, fingerprint: BitVec) -> IndexItem { | ||
IndexItem { | ||
position, | ||
fingerprint: fingerprint.to_bytes() | ||
} | ||
} | ||
} |
File renamed without changes.