reference::ReferencePosition getAlignmentPositionFromName(const std::size_t readNumber, const FragmentMetadata &fragment) { // numbers are 1-based const auto name = getReadName(readNumber - 1, fragment); if (name.second == name.first) { return reference::ReferencePosition(reference::ReferencePosition::TooManyMatch); } if ('u' == *name.first) { ISAAC_ASSERT_MSG(false, common::makeFastIoString(fragment.getCluster().nameBegin(), fragment.getCluster().nameEnd()) << " " << fragment); return reference::ReferencePosition(reference::ReferencePosition::NoMatch); } return reference::ReferencePosition( std::atol(&*name.first + 2), std::atol(&*std::find(name.first + 2, name.second, ':') + 1), false, 'r' == *name.first); }
std::pair<BclClusters::const_iterator, BclClusters::const_iterator> getReadName(const std::size_t readIndex, const FragmentMetadata &fragment) { std::pair<BclClusters::const_iterator, BclClusters::const_iterator> ret = {fragment.getCluster().nameBegin(), fragment.getCluster().nameEnd()}; if (ret.second == ret.first) { return ret; } if (!readIndex) { ret.first = fragment.getCluster().nameBegin(); ret.second = std::find(fragment.getCluster().nameBegin(), fragment.getCluster().nameEnd(), '-'); } else { ret.first = std::find(fragment.getCluster().nameBegin(), fragment.getCluster().nameEnd(), '-') + 1; ret.second = fragment.getCluster().nameEnd(); } return ret; }