Skip to content

Commit

Permalink
Fixes after rebase; address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhofer committed Oct 30, 2024
1 parent 9e1cb1b commit 063364f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/exports/gfa.rs
Original file line number Diff line number Diff line change
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
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
12 changes: 8 additions & 4 deletions src/models/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl Path {
false,
)
} else {
first_mapping.target_range.start
Ok(first_mapping.target_range.start)
};

let translated_end = if last_mapping.source_range.contains(end) {
Expand All @@ -484,13 +484,17 @@ impl Path {
false,
)
} else {
last_mapping.target_range.end
Ok(last_mapping.target_range.end)
};

if translated_start.is_err() || translated_end.is_err() {
return None;
}

Some(Annotation {
name: annotation.name,
start: translated_start,
end: translated_end,
start: translated_start.expect("Failed to translate start"),
end: translated_end.expect("Failed to translate end"),
})
}

Expand Down
10 changes: 7 additions & 3 deletions src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,17 @@ impl Range {
range2: &Range,
sequence_length: i64,
is_circular_contig: bool,
) -> i64 {
) -> Result<i64, &'static str> {
if !self.contains(index) {
panic!("Index {} is not contained in range {:?}", index, self);
return Err("Index is not contained in range");
}

let offset = index - self.start;
Range::circular_mod(range2.start + offset, sequence_length, is_circular_contig)
Ok(Range::circular_mod(
range2.start + offset,
sequence_length,
is_circular_contig,
))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/updates/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn update_with_library(
parts_list.push(parts_by_index.get(&index).unwrap());
}

let path_intervaltree = Path::intervaltree_for(conn, &path);
let path_intervaltree = path.intervaltree(conn);
let start_blocks: Vec<_> = path_intervaltree
.query_point(start_coordinate)
.map(|x| &x.value)
Expand Down

0 comments on commit 063364f

Please sign in to comment.