Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
7 changes: 4 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "lldb",
"request": "launch",
Expand All @@ -15,9 +16,9 @@
]
},
"program": "target/debug/d4tools",
"env": {"RUST_LOG": "info"},
"args": ["create", "-g", "/tmp/1.g", "/tmp/1.bedgraph"],
"cwd": "/tmp"
"env": {"RUST_LOG": "info", "RUST_BACKTRACE": "1"},
"args": ["view", "${workspaceFolder}/fdr.peaks.d4", "chr1:1-59999"],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
Expand Down
6 changes: 5 additions & 1 deletion d4/src/ssio/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ impl<R: Read + Seek> D4TrackReader<R> {
if table_ref.chrom_id == chrom_id {
let overlap_begin = table_ref.begin.max(begin);
let overlap_end = table_ref.end.min(end);

if overlap_begin < overlap_end {
if overlap_begin == table_ref.begin || self.sfi.is_none() {
//if overlap_begin + 1 == table_ref.begin || self.sfi.is_none() {
if self.sfi.is_none() {
secondary_view.push(table_ref.clone());
} else {
let sfi = self.sfi.as_ref().unwrap();
Expand All @@ -147,6 +149,8 @@ impl<R: Read + Seek> D4TrackReader<R> {
));
}
}
} else {
break;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this introduce new bug. Basically this is the part that creates a view to secondary table partitions that contains the data points that is related to the query.

If break at this point, I believe this will introduce bug in some query for large interval which is larger than a secondary table partition.

So I am a little bit confused if the issue is just change the interval convention, what is the problem that needs to be fixed at this point.

To help me understand the change better, could you please give me some data that triggers a buggy output.

Thanks,
Hao

Copy link
Copy Markdown
Contributor

@mrvollger mrvollger Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @38, in case it helps I link to data that appears to be bugged in issue #59 and walk through the example.

Edit: never mind I see this is unrelated to 59 which you have fixed. Thanks!

}
}
}
Expand Down
9 changes: 6 additions & 3 deletions d4tools/src/show/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ fn parse_region_spec<T: Iterator<Item = String>>(
for region_spec in regions {
if let Some(captures) = region_pattern.captures(&region_spec) {
let chr = captures.name("CHR").unwrap().as_str();
let start: u32 = captures
// since we are reading a region like chr:start-end which is 1-based, we subtract 1 from the start.
let start: u32 = std::cmp::max(1, captures
.name("FROM")
.map_or(0u32, |x| x.as_str().parse().unwrap_or(0));
.map_or(0u32, |x| x.as_str().parse().unwrap_or(0))) - 1;

let end: u32 = captures
.name("TO")
.map_or_else(|| {
Expand Down Expand Up @@ -311,7 +313,8 @@ pub fn entry_point(args: Vec<String>) -> Result<(), Box<dyn std::error::Error>>
if raw_chr.is_some() && raw_beg.is_some() && raw_end.is_some() {
if let Ok(begin) = raw_beg.unwrap().parse::<u32>() {
if let Ok(end) = raw_end.unwrap().parse::<u32>() {
region_list.push(format!("{}:{}-{}", raw_chr.unwrap(), begin, end));
// region-file is bed format so we add 1 to start to get to chr:start-end
region_list.push(format!("{}:{}-{}", raw_chr.unwrap(), begin + 1, end));
}
}
buf.clear();
Expand Down