Skip to content

Commit

Permalink
undo weird naming
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhofer committed Aug 19, 2024
1 parent c25098b commit 2392595
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ mod tests {
HashSet::from_iter(vec!["ATCGATCGATCGATCGATCGGGAACACACAGAGA".to_string()])
);
assert_eq!(
Path::get_sequence(&conn, 1),
Path::sequence(&conn, 1),
"ATCGATCGATCGATCGATCGGGAACACACAGAGA".to_string()
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl BlockGroup {
.values()
.map(|block| format!("\"{id}\"", id = block.sequence_hash))
.collect::<Vec<_>>();
let sequence_map = Sequence::get_sequences_by_hash(conn, sequence_hashes);
let sequence_map = Sequence::sequences_by_hash(conn, sequence_hashes);
let block_ids = block_map
.keys()
.map(|id| format!("{id}"))
Expand Down
10 changes: 5 additions & 5 deletions src/models/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl Path {
paths
}

pub fn get_sequence(conn: &Connection, path_id: i32) -> String {
pub fn sequence(conn: &Connection, path_id: i32) -> String {
let block_ids = PathBlock::get_blocks(conn, path_id);
let mut sequence = "".to_string();
for block_id in block_ids {
Expand All @@ -166,7 +166,7 @@ impl Path {
sequence
}

pub fn new_get_sequence(conn: &Connection, path: Path) -> String {
pub fn new_sequence(conn: &Connection, path: Path) -> String {
let blocks = Path::blocks_for(conn, path);
blocks
.into_iter()
Expand Down Expand Up @@ -235,7 +235,7 @@ impl Path {
sequence_hashes.insert(edge.target_hash.clone().unwrap());
}
}
let sequences_by_hash = Sequence::get_sequences_by_hash(
let sequences_by_hash = Sequence::sequences_by_hash(
conn,
sequence_hashes
.into_iter()
Expand Down Expand Up @@ -443,7 +443,7 @@ mod tests {
block_group.id,
vec![block1.id, block2.id, block3.id],
);
assert_eq!(Path::get_sequence(conn, path.id), "ATCGATCGAAAAAAACCCCCCC");
assert_eq!(Path::sequence(conn, path.id), "ATCGATCGAAAAAAACCCCCCC");
}

#[test]
Expand All @@ -469,7 +469,7 @@ mod tests {
block_group.id,
vec![block3.id, block2.id, block1.id],
);
assert_eq!(Path::get_sequence(conn, path.id), "GGGGGGGTTTTTTTCGATCGAT");
assert_eq!(Path::sequence(conn, path.id), "GGGGGGGTTTTTTTCGATCGAT");
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/models/path_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ mod tests {
vec![edge1.id, edge2.id, edge3.id, edge4.id, edge5.id],
);
assert_eq!(
Path::new_get_sequence(conn, path),
Path::new_sequence(conn, path),
"ATCGATCGAAAAAAACCCCCCCGGGGGGG"
);
}
Expand Down Expand Up @@ -236,7 +236,7 @@ mod tests {
vec![edge1.id, edge2.id, edge3.id, edge4.id, edge5.id],
);
assert_eq!(
Path::new_get_sequence(conn, path),
Path::new_sequence(conn, path),
"CCCCCCCGGGGGGGTTTTTTTCGATCGAT"
);
}
Expand Down
13 changes: 3 additions & 10 deletions src/models/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ impl Sequence {
obj_hash
}

pub fn get_sequences(
conn: &Connection,
query: &str,
placeholders: Vec<Value>,
) -> Vec<Sequence> {
pub fn sequences(conn: &Connection, query: &str, placeholders: Vec<Value>) -> Vec<Sequence> {
let mut stmt = conn.prepare_cached(query).unwrap();
let rows = stmt
.query_map(params_from_iter(placeholders), |row| {
Expand All @@ -69,12 +65,9 @@ impl Sequence {
objs
}

pub fn get_sequences_by_hash(
conn: &Connection,
hashes: Vec<String>,
) -> HashMap<String, Sequence> {
pub fn sequences_by_hash(conn: &Connection, hashes: Vec<String>) -> HashMap<String, Sequence> {
let joined_hashes = &hashes.join(",");
let sequences = Sequence::get_sequences(
let sequences = Sequence::sequences(
conn,
&format!("select * from sequence where hash in ({0})", joined_hashes),
vec![],
Expand Down

0 comments on commit 2392595

Please sign in to comment.