Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate mappings of common ranges from one path to another #73

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/exports/gfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ mod tests {

let paths = Path::get_paths_for_collection(&conn, "test collection 2");
assert_eq!(paths.len(), 1);
assert_eq!(Path::sequence(&conn, paths[0].clone()), "AAAATTTTGGGGCCCC");
assert_eq!(paths[0].sequence(&conn), "AAAATTTTGGGGCCCC");
dkhofer marked this conversation as resolved.
Show resolved Hide resolved
}

#[test]
Expand Down Expand Up @@ -477,7 +477,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let edges = BlockGroupEdge::edges_for_block_group(&conn, block_group_id);
Expand Down
4 changes: 2 additions & 2 deletions src/imports/fasta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod tests {

let path = Path::get(&conn, 1);
assert_eq!(
Path::sequence(&conn, path),
path.sequence(&conn),
"ATCGATCGATCGATCGATCGGGAACACACAGAGA".to_string()
);
}
Expand Down Expand Up @@ -180,7 +180,7 @@ mod tests {

let path = Path::get(&conn, 1);
assert_eq!(
Path::sequence(&conn, path),
path.sequence(&conn),
"ATCGATCGATCGATCGATCGGGAACACACAGAGA".to_string()
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/imports/gfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ mod tests {
)[0]
.clone();

let result = Path::sequence(conn, path);
let result = path.sequence(conn);
assert_eq!(result, "ATCGATCGATCGATCGATCGGGAACACACAGAGA");

let node_count = Node::query(conn, "select * from nodes", vec![]).len() as i64;
Expand Down Expand Up @@ -288,7 +288,7 @@ mod tests {
)[0]
.clone();

let result = Path::sequence(conn, path);
let result = path.sequence(conn);
assert_eq!(result, "ACCTACAAATTCAAAC");

let node_count = Node::query(conn, "select * from nodes", vec![]).len() as i64;
Expand All @@ -314,7 +314,7 @@ mod tests {
)[0]
.clone();

let result = Path::sequence(conn, path);
let result = path.sequence(conn);
assert_eq!(result, "TATGCCAGCTGCGAATA");

let node_count = Node::query(conn, "select * from nodes", vec![]).len() as i64;
Expand Down Expand Up @@ -343,7 +343,7 @@ mod tests {
)[0]
.clone();

let result = Path::sequence(conn, path);
let result = path.sequence(conn);
let big_part = "TGCTAGCTACTAGTGAAAGAGGAGAAATACTAGATGGCTTCCTCCGAAGACGTTATCAAAGAGTTCATGCGTTTCAAAGTTCGTATGGAAGGTTCCGTTAACGGTCACGAGTTCGAAATCGAAGGTGAAGGTGAAGGTCGTCCGTACGAAGGTACCCAGACCGCTAAACTGAAAGTTACCAAAGGTGGTCCGCTGCCGTTCGCTTGGGACATCCTGTCCCCGCAGTTCCAGTACGGTTCCAAAGCTTACGTTAAACACCCGGCTGACATCCCGGACTACCTGAAACTGTCCTTCCCGGAAGGTTTCAAATGGGAACGTGTTATGAACTTCGAAGACGGTGGTGTTGTTACCGTTACCCAGGACTCCTCCCTGCAAGACGGTGAGTTCATCTACAAAGTTAAACTGCGTGGTACCAACTTCCCGTCCGACGGTCCGGTTATGCAGAAAAAAACCATGGGTTGGGAAGCTTCCACCGAACGTATGTACCCGGAAGACGGTGCTCTGAAAGGTGAAATCAAAATGCGTCTGAAACTGAAAGACGGTGGTCACTACGACGCTGAAGTTAAAACCACCTACATGGCTAAAAAACCGGTTCAGCTGCCGGGTGCTTACAAAACCGACATCAAACTGGACATCACCTCCCACAACGAAGACTACACCATCGTTGAACAGTACGAACGTGCTGAAGGTCGTCACTCCACCGGTGCTTAATAACGCTGATAGTGCTAGTGTAGATCGCTACTAGAGCCAGGCATCAAATAAAACGAAAGGCTCAGTCGAAAGACTGGGCCTTTCGTTTTATCTGTTGTTTGTCGGTGAACGCTCTCTACTAGAGTCACACTGGCTCACCTTCGGGTGGGCCTTTCTGCGTTTATATACTAGAAGCGGCCGCTGCAGGCTTCCTCGCTCACTGACTCGCTGCGCTCGGTCGTTCGGCTGCGGCGAGCGGTATCAGCTCACTCAAAGGCGGTAATACGGTTATCCACAGAATCAGGGGATAACGCAGGAAAGAACATGTGAGCAAAAGGCCAGCAAAAGGCCAGGAACCGTAAAAAGGCCGCGTTGCTGGCGTTTTTCCATAGGCTCCGCCCCCCTGACGAGCATCACAAAAATCGACGCTCAAGTCAGAGGTGGCGAAACCCGACAGGACTATAAAGATACCAGGCGTTTCCCCCTGGAAGCTCCCTCGTGCGCTCTCCTGTTCCGACCCTGCCGCTTACCGGATACCTGTCCGCCTTTCTCCCTTCGGGAAGCGTGGCGCTTTCTCATAGCTCACGCTGTAGGTATCTCAGTTCGGTGTAGGTCGTTCGCTCCAAGCTGGGCTGTGTGCACGAACCCCCCGTTCAGCCCGACCGCTGCGCCTTATCCGGTAACTATCGTCTTGAGTCCAACCCGGTAAGACACGACTTATCGCCACTGGCAGCAGCCACTGGTAACAGGATTAGCAGAGCGAGGTATGTAGGCGGTGCTACAGAGTTCTTGAAGTGGTGGCCTAACTACGGCTACACTAGAAGGACAGTATTTGGTATCTGCGCTCTGCTGAAGCCAGTTACCTTCGGAAAAAGAGTTGGTAGCTCTTGATCCGGCAAACAAACCACCGCTGGTAGCGGTGGTTTTTTTGTTTGCAAGCAGCAGATTACGCGCAGAAAAAAAGGATCTCAAGAAGATCCTTTGATCTTTTCTACGGGGTCTGACGCTCAGTGGAACGAAAACTCACGTTAAGGGATTTTGGTCATGAGATTATCAAAAAGGATCTTCACCTAGATCCTTTTAAATTAAAAATGAAGTTTTAAATCAATCTAAAGTATATATGAGTAAACTTGGTCTGACAGTTACCAATGCTTAATCAGTGAGGCACCTATCTCAGCGATCTGTCTATTTCGTTCATCCATAGTTGCCTGACTCCCCGTCGTGTAGATAACTACGATACGGGAGGGCTTACCATCTGGCCCCAGTGCTGCAATGATACCGCGAGACCCACGCTCACCGGCTCCAGATTTATCAGCAATAAACCAGCCAGCCGGAAGGGCCGAGCGCAGAAGTGGTCCTGCAACTTTATCCGCCTCCATCCAGTCTATTAATTGTTGCCGGGAAGCTAGAGTAAGTAGTTCGCCAGTTAATAGTTTGCGCAACGTTGTTGCCATTGCTACAGGCATCGTGGTGTCACGCTCGTCGTTTGGTATGGCTTCATTCAGCTCCGGTTCCCAACGATCAAGGCGAGTTACATGATCCCCCATGTTGTGCAAAAAAGCGGTTAGCTCCTTCGGTCCTCCGATCGTTGTCAGAAGTAAGTTGGCCGCAGTGTTATCACTCATGGTTATGGCAGCACTGCATAATTCTCTTACTGTCATGCCATCCGTAAGATGCTTTTCTGTGACTGGTGAGTACTCAACCAAGTCATTCTGAGAATAGTGTATGCGGCGACCGAGTTGCTCTTGCCCGGCGTCAATACGGGATAATACCGCGCCACATAGCAGAACTTTAAAAGTGCTCATCATTGGAAAACGTTCTTCGGGGCGAAAACTCTCAAGGATCTTACCGCTGTTGAGATCCAGTTCGATGTAACCCACTCGTGCACCCAACTGATCTTCAGCATCTTTTACTTTCACCAGCGTTTCTGGGTGAGCAAAAACAGGAAGGCAAAATGCCGCAAAAAAGGGAATAAGGGCGACACGGAAATGTTGAATACTCATACTCTTCCTTTTTCAATATTATTGAAGCATTTATCAGGGTTATTGTCTCATGAGCGGATACATATTTGAATGTATTTAGAAAAATAAACAAATAGGGGTTCCGCGCACATTTCCCCGAAAAGTGCCACCTGACGTCTAAGAAACCATTATTATCATGACATTAACCTATAAAAATAGGCGTATCACGAGGCAGAATTTCAGATAAAAAAAATCCTTAGCTTTCGCTAAGGATGATTTCTGGAATTCGCGGCCGCATCTAGAG";
let expected_sequence_parts = vec![
"T",
Expand Down Expand Up @@ -446,7 +446,7 @@ mod tests {
)[0]
.clone();

let result = Path::sequence(conn, path);
let result = path.sequence(conn);
assert_eq!(result, "AA");

let all_sequences = BlockGroup::get_all_sequences(conn, block_group_id);
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod imports;
pub mod migrations;
pub mod models;
pub mod operation_management;
pub mod range;
pub mod test_helpers;
pub mod updates;

Expand Down
44 changes: 22 additions & 22 deletions src/models/block_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl PathCache<'_> {
.clone();

path_cache.cache.insert(path_key, new_path.clone());
let tree = Path::intervaltree_for(path_cache.conn, &new_path);
let tree = new_path.intervaltree(path_cache.conn);
path_cache.intervaltree_cache.insert(new_path.clone(), tree);
new_path
}
Expand Down Expand Up @@ -721,7 +721,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -760,7 +760,7 @@ mod tests {
phased: 0,
};
// take out an entire block.
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);
let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
assert_eq!(
Expand Down Expand Up @@ -803,7 +803,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -845,7 +845,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -887,7 +887,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -929,7 +929,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -971,7 +971,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1013,7 +1013,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1055,7 +1055,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1097,7 +1097,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1142,7 +1142,7 @@ mod tests {
};

// take out an entire block.
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);
let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
assert_eq!(
Expand Down Expand Up @@ -1183,7 +1183,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand All @@ -1195,7 +1195,7 @@ mod tests {
])
);

let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1237,7 +1237,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1280,7 +1280,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1322,7 +1322,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1364,7 +1364,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1406,7 +1406,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1448,7 +1448,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1490,7 +1490,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down Expand Up @@ -1532,7 +1532,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);

let all_sequences = BlockGroup::get_all_sequences(&conn, block_group_id);
Expand Down
2 changes: 1 addition & 1 deletion src/models/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ mod tests {
chromosome_index: 1,
phased: 0,
};
let tree = Path::intervaltree_for(&conn, &path);
let tree = path.intervaltree(&conn);
BlockGroup::insert_change(&conn, &change, &tree);
let mut edges = BlockGroupEdge::edges_for_block_group(&conn, block_group_id);

Expand Down
Loading