bool HDFBaseCallsWriter::_WritePulseIndex(const SMRTSequence & read) {
    if (HasPulseIndex()) {
        if (read.copiedFromBam) {
            const PacBio::BAM::BamRecord & record = read.bamRecord;
            if (record.HasPulseCall()) {
                const std::string & pulsecall = record.PulseCall();
                std::vector<uint16_t> data(read.length, 0);
                size_t indx = 0;
                for(size_t i = 0; i < pulsecall.size(); i++) {
                    const char base = pulsecall[i];
                    if (base == 'A' or base == 'C' or base == 'G' or base == 'T') {
                        assert(indx < read.length);
                        data[indx] = static_cast<uint16_t>(i);
                        indx ++;
                    } else {
                        assert(base == 'a' or base == 'c' or base == 'g' or base == 't');
                    }
                }
                assert(indx == read.length);
                pulseIndexArray_.Write(&data[0], read.length);
                return true;
            }
        }
        AddErrorMessage(std::string(PacBio::GroupNames::pulseindex) + " absent in read " + read.GetTitle());
        return false;
    }
    return true;
}
bool HDFBaseCallsWriter::_WritePulseWidth(const SMRTSequence & read) {
    if (HasPulseWidth()) {
        if (read.widthInFrames == nullptr) {
            AddErrorMessage(std::string(PacBio::GroupNames::widthinframes) + " absent in read " + read.GetTitle());
            return false;
        } else {
            pulseWidthArray_.Write(read.widthInFrames, read.length);
            return true;
        }
    }
    return true;
}
bool HDFBaseCallsWriter::_WriteMergeQV(const SMRTSequence & read) {
    if (HasMergeQV()) {
        if (read.mergeQV.Empty()) {
            AddErrorMessage(std::string(PacBio::GroupNames::mergeqv) + " absent in read " + read.GetTitle());
            return false;
        } else {
			mergeQVArray_.Write(read.mergeQV.data, read.length);
            return true;
        }
    }
    return true;
}
bool HDFBaseCallsWriter::_WriteIPD(const SMRTSequence & read) {
     if (HasIPD()) {
        if (read.preBaseFrames == nullptr) {
            AddErrorMessage(std::string(PacBio::GroupNames::prebaseframes) + " absent in read " + read.GetTitle());
            return false;
        } else {
            ipdArray_.Write(read.preBaseFrames, read.length);
            return true;
        }
    }
    return true;
}
bool HDFBaseCallsWriter::_WriteSubstitutionTag(const SMRTSequence & read) {
    if (HasSubstitutionTag()) {
        if (read.substitutionTag == nullptr) {
            AddErrorMessage(std::string(PacBio::GroupNames::substitutiontag) + " absent in read " + read.GetTitle());
            return false;
        } else {
			substitutionTagArray_.Write(read.substitutionTag, read.length);
            return true;
        }
    }
    return true;
}