Browse Source

optional cigar_before/cigar_after in basesWith

remotes/georgeg/no_streams
lomereiter 9 years ago
parent
commit
6dda861117
  1. 66
      bio/bam/baseinfo.d
  2. 13
      bio/bam/fz/flowcall.d
  3. 2
      bio/core/sequence.d
  4. 2
      bio/core/utils/range.d
  5. 2
      bio/core/utils/roundbuf.d

66
bio/bam/baseinfo.d

@ -179,9 +179,9 @@ struct PerBaseInfo(R, Tags...) {
}
private {
bool _rev = void;
R _read = void;
ReversableRange!(complementBase, typeof(_read.sequence)) _seq = void;
bool _rev = void;
}
}
@ -414,38 +414,67 @@ template FZbaseInfo(R) {
template CIGARbaseInfo(R) {
mixin template resultProperties() {
/// Current CIGAR operation
CigarOperation cigar_operation() @property const {
return _cigar_operation;
version(CigarExtra)
{
/// Current CIGAR operation
CigarOperation cigar_operation() @property {
return _cigar[_operation_index];
}
/// CIGAR operations before current one
auto cigar_before() @property {
return _cigar[0 .. _operation_index];
}
/// CIGAR operations after current one
auto cigar_after() @property {
return _cigar[_operation_index + 1 .. _cigar.length];
}
}
else
{
/// Current CIGAR operation
CigarOperation cigar_operation() @property const {
return _current_cigar_op;
}
}
/// Position of the corresponding base on the reference.
/// If current CIGAR operation is not one of 'M', '=', 'X',
/// returns the position of the previous valid base.
ulong position() @property const {
uint position() @property const {
return _reference_position;
}
/// Offset in current CIGAR operation, starting from 0.
ulong cigar_operation_offset() @property const {
uint cigar_operation_offset() @property const {
return _cigar_operation_offset;
}
private {
CigarOperation _cigar_operation = void;
ulong _reference_position = void;
ulong _cigar_operation_offset = void;
int _operation_index = void;
uint _reference_position = void;
uint _cigar_operation_offset = void;
version (CigarExtra)
{
ReversableRange!(identity, const(CigarOperation)[]) _cigar = void;
}
else
{
CigarOperation _current_cigar_op;
}
}
}
mixin template rangeMethods() {
private {
ReversableRange!(identity, const(CigarOperation)[]) _cigar = void;
long _index = void;
CigarOperation _current_cigar_op = void;
ulong _at = void;
ulong _ref_pos = void;
int _index = void;
uint _at = void;
uint _ref_pos = void;
ReversableRange!(identity, const(CigarOperation)[]) _cigar = void;
}
/// Current CIGAR operation, available to all extensions
@ -462,12 +491,21 @@ template CIGARbaseInfo(R) {
: read.position;
_moveToNextCigarOperator();
assert(_index >= 0);
}
void populate(Result)(ref Result result) {
result._cigar_operation = _current_cigar_op;
result._reference_position = _ref_pos;
result._cigar_operation_offset = _at;
version (CigarExtra)
{
result._cigar = _cigar;
result._operation_index = _index;
}
else
{
result._current_cigar_op = _current_cigar_op;
}
}
void update(const ref R read)

13
bio/bam/fz/flowcall.d

@ -57,11 +57,11 @@ struct FlowCall {
/// Flow call associated with a read
struct ReadFlowCall {
private {
Base _base;
ushort _signal_intensity;
ushort _offset;
ushort _called_len;
Base _base;
size_t _flow_index;
ushort _flow_index;
}
/// Called nucleotide
@ -192,8 +192,13 @@ struct ReadFlowCallRange(S)
ReadFlowCall front() @property const {
auto intensity = cast(ushort)(_intensities[_current_flow_index] - _overlap);
return ReadFlowCall(intensity, _current_offset, _current_length,
_current_base, _current_flow_index + _zf);
ReadFlowCall rfc = void;
rfc._signal_intensity = intensity;
rfc._offset = _current_offset;
rfc._called_len = _current_length;
rfc._flow_index = cast(ushort)(_current_flow_index + _zf);
rfc._base = _current_base;
return rfc;
}
void popFront() {

2
bio/core/sequence.d

@ -40,8 +40,8 @@ struct ReversableRange(alias reverseTransform=identity, R)
{
private
{
R _range = void;
bool _rev = void;
R _range = void;
}
/// Construct reversable range.

2
bio/core/utils/range.d

@ -60,7 +60,7 @@ auto prefetch(Range)(Range r, size_t amount) {
return _range.empty && _roundbuf.empty;
}
auto ref E front() @property {
auto ref front() @property {
return _roundbuf.front;
}

2
bio/core/utils/roundbuf.d

@ -41,7 +41,7 @@ struct RoundBuf(T) {
}
/// ditto
auto ref T front() @property {
auto ref front() @property {
enforce(!empty, "buffer is empty");
return _items[_taken % $];
}

Loading…
Cancel
Save