const std::vector<std::vector<unsigned > > SeedMemoryManager<KmerT>::getNotFoundMatchesCount(
    const flowcell::TileMetadataList &unprocessedTiles,
    const flowcell::BarcodeMetadataList &barcodeMetadataList,
    const ReadMetadataList &readMetadataList,
    const matchFinder::TileClusterInfo &foundMatches) const
{
    ISAAC_ASSERT_MSG(unprocessedTiles.front().getIndex() <= unprocessedTiles.back().getIndex(),
                     "Expected tiles ordered by index");
    std::vector<std::vector<unsigned > > ret(readMetadataList.size(), std::vector<unsigned>(
        unprocessedTiles.back().getIndex() + 1));

    BOOST_FOREACH(const flowcell::ReadMetadata &readMetadata, readMetadataList_)
    {
        const unsigned readIndex = readMetadata.getIndex();
        BOOST_FOREACH(const flowcell::TileMetadata &tileMetadata, unprocessedTiles)
        {
            const unsigned tileIndex = tileMetadata.getIndex();
            const std::vector<matchFinder::ClusterInfo> &oneTileInfo = foundMatches.at(tileIndex);
            // match only clusters where no matches were found so far
            ISAAC_ASSERT_MSG(oneTileInfo.size() == tileMetadata.getClusterCount(), "allTiles and foundMatches geometries must match");
            ret.at(readIndex).at(tileIndex) =
                std::count_if(oneTileInfo.begin(), oneTileInfo.end(),
                              boost::bind(&willLoadSeeds,
                                          boost::ref(barcodeMetadataList), _1, readIndex));
        }
    }
    return ret;
}
Example #2
0
void ParallelSeedLoader<ReaderT, KmerT>::loadTileCycle(
    const matchFinder::TileClusterInfo &tileClusterBarcode,
    rta::SingleCycleBclMapper<ReaderT> &threadBclMapper,
    std::vector<typename std::vector<Seed<KmerT> >::iterator> &destinationBegins,
    const flowcell::TileMetadata &tile,
    const unsigned cycle,
    std::vector<SeedMetadata>::const_iterator cycleSeedsBegin,
    const std::vector<SeedMetadata>::const_iterator cycleSeedsEnd)
{
    ISAAC_ASSERT_MSG(cycleSeedsEnd > cycleSeedsBegin, "Seed list cannot be empty");
    ISAAC_ASSERT_MSG((cycleSeedsEnd -1)->getReadIndex() == cycleSeedsBegin->getReadIndex(), "All seeds must belong to the same read");
    const unsigned readIndex = cycleSeedsBegin->getReadIndex();

    const std::vector<matchFinder::ClusterInfo> &clustersToDiscard = tileClusterBarcode.at(tile.getIndex());
    ISAAC_ASSERT_MSG(tile.getClusterCount() == clustersToDiscard.size(), "Found matches from a wrong tile/read");

    threadBclMapper.mapTileCycle(BaseT::flowcellLayout_, tile, cycle);

    while (cycleSeedsEnd != cycleSeedsBegin)
    {
        for (unsigned int clusterId = 0; tile.getClusterCount() > clusterId; ++clusterId)
        {
            const unsigned barcodeIndex = clustersToDiscard.at(clusterId).getBarcodeIndex();
            const unsigned referenceIndex = BaseT::barcodeMetadataList_.at(barcodeIndex).getReferenceIndex();
            char base = 0;
            threadBclMapper.get(clusterId, &base);
            if (flowcell::BarcodeMetadata::UNMAPPED_REFERENCE_INDEX != referenceIndex)
            {
                if (!clustersToDiscard.at(clusterId).isReadComplete(readIndex))
                {
                    Seed<KmerT> & forwardSeed = *destinationBegins[referenceIndex]++;
                    // skip those previously found to contain Ns
                    if (!forwardSeed.isNSeed())
                    {
                        if (oligo::getQuality(base) >= seedBaseQualityMin_)
                        {
                            KmerT forward = forwardSeed.getKmer();
                            const KmerT forwardBaseValue(base & oligo::BITS_PER_BASE_MASK);

                            forward <<= oligo::BITS_PER_BASE;
                            forward |= forwardBaseValue;

                            forwardSeed = Seed<KmerT>(forward, SeedId(tile.getIndex(), barcodeIndex, clusterId, cycleSeedsBegin->getIndex(), 0));
                        }
                        else
                        {
                            // we can't have holes. The Ns must be stored in such a way that
                            // they will be easy to remove later (after sorting)
                            forwardSeed = makeNSeed<KmerT>(tile.getIndex(), barcodeIndex, clusterId, 0 == cycleSeedsBegin->getIndex());
                        }
                    }
                }
            }
        }
        ++cycleSeedsBegin;
    }
}