-
Notifications
You must be signed in to change notification settings - Fork 10
Read CSI region #48
base: master
Are you sure you want to change the base?
Read CSI region #48
Conversation
internal/csi/csi.go
Outdated
@@ -71,3 +82,73 @@ func BinsForRange(start, end uint32, minShift, depth int32) []uint16 { | |||
func maximumBinWidth(minShift, depth int32) uint32 { | |||
return uint32(1 << uint32(minShift+depth*3)) | |||
} | |||
|
|||
// Read reads index data from csi and returns a set of BGZF chunks covering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anamanolache This is hard to read. Just say Reads a CSI formatted index file.
internal/csi/csi.go
Outdated
@@ -71,3 +82,73 @@ func BinsForRange(start, end uint32, minShift, depth int32) []uint16 { | |||
func maximumBinWidth(minShift, depth int32) uint32 { | |||
return uint32(1 << uint32(minShift+depth*3)) | |||
} | |||
|
|||
// Read reads index data from csi and returns a set of BGZF chunks covering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
csiFile -> csi (it's a Reader, not a file)
Or just 'r' is fine too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
internal/csi/csi.go
Outdated
|
||
var minShift int32 | ||
if err := binary.Read(gzr, &minShift); err != nil { | ||
return nil, fmt.Errorf("reading # bits for the minimal interval (min_shift): %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"reading minimum interval width: %v"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
N/A, refactored code
internal/csi/csi.go
Outdated
return nil, fmt.Errorf("checking magic: %v", err) | ||
} | ||
|
||
var minShift int32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minShift is a detail of the implementation - it's best to talk about widths outside the implementation of the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
internal/csi/csi.go
Outdated
return nil, fmt.Errorf("checking magic: %v", err) | ||
} | ||
|
||
var minShift int32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd typically suggest you use a structure and read:
var header struct {
minimumWidth int32
depth int32
auxilaryLength int32
}
if err := binary.Read(gzr, &header) {
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
internal/csi/csi.go
Outdated
if err := binary.Read(gzr, &depth); err != nil { | ||
return nil, fmt.Errorf("reading depth of binary index: %v", err) | ||
} | ||
bins := BinsForRange(region.Start, region.End, minShift, depth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move closer to use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
internal/csi/csi.go
Outdated
@@ -71,3 +82,68 @@ func BinsForRange(start, end uint32, minShift, depth int32) []uint16 { | |||
func maximumBinWidth(minShift, depth int32) uint32 { | |||
return uint32(1 << uint32(minShift+depth*3)) | |||
} | |||
|
|||
// Read reads index data from CSI and returns a set of BGZF chunks covering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read reads CSI formatted index data from r and returns a set of ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
internal/csi/csi.go
Outdated
if err := binary.Read(csi, &refCount); err != nil { | ||
return nil, fmt.Errorf("reading the number of reference sequences: %v", err) | ||
} | ||
bins := BinsForRange(region.Start, region.End, csiHeader.MinimumWidth, csiHeader.Depth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we'd factor out the common code between here and the BAM reader. The difficulty is the Offset field. It's OK to submit this now, but maybe file an issue about it. We could have some common function that takes a flag, for example, that would cover both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done it now so I don't commit duplicate code to begin with.
No description provided.