Пример #1
0
void Dedup_LowMem::handleMissingMate(int32_t refID, int32_t mateRefID)
{
    static bool firstDifferChrom = true;
    static bool firstSameChrom = true;

    ++myNumMissingMate;

    // Passed the mate, but it was not found.
    if(refID != mateRefID)
    {
        if(firstDifferChrom)
        {
            std::cerr << "Mate on different chromosome was not found.\n"
                      << "If you are running single chromosome, consider "
                      << "using --oneChrom to treat reads with mates on "
                      << "different chromosomes as single-ended.\n";
            firstDifferChrom = false;
        }
    }
    else if(firstSameChrom)
    {
        std::cerr << "ERROR: Records with missing mate can't be checked for "
                  << "duplicates.\n";
        firstSameChrom = false;
    }

    // Don't consider this record to be a duplicate.
    handleNonDuplicate();
}
Пример #2
0
void Dedup::handleMissingMate(SamRecord* recordPtr)
{
    static bool firstDifferChrom = true;
    static bool firstSameChrom = true;

    if(recordPtr == NULL)
    {
        return;
    }

    // Passed the mate, but it was not found.
    if(recordPtr->getMateReferenceID() != recordPtr->getReferenceID())
    {
        if(firstDifferChrom)
        {
            std::cerr << "Mate on different chromosome was not found.\n"
                      << "If you are running single chromosome, consider "
                      << "using --oneChrom to treat reads with mates on "
                      << "different chromosomes as single-ended.\n";
            firstDifferChrom = false;
        }
    }
    else if(firstSameChrom)
    {
        std::cerr << "ERROR: Records with missing mate can't be checked for "
                  << "duplicates.\n";
        firstSameChrom = false;
    }

    // Don't consider this record to be a duplicate.
    // Release this record since there is nothing more to do with it.
    ++myNumMissingMate;
    handleNonDuplicate(recordPtr);
}
Пример #3
0
// Now that we've reached coordinate on chromosome reference, look back and
// clean up any previous positions from being tracked.
void Dedup_LowMem::cleanupPriorReads(SamRecord* record)
{
    static DupKey emptyKey;
    static DupKey tempKey2;

    // Set where to stop cleaning out the structures.
    // Initialize to the end of the structures.
    FragmentMap::iterator fragmentFinish = myFragmentMap.end();
    PairedMap::iterator pairedFinish = myPairedMap.end();
    uint64_t mateStopPos = 0;

    // If a record was specified, stop before this record.
    if(record != NULL)
    {
        int32_t reference = record->getReferenceID();
        int32_t coordinate = record->get0BasedPosition();
        tempKey2.cleanupKey(reference, coordinate);
        fragmentFinish = myFragmentMap.lower_bound(tempKey2);
        // Now do the same thing with the paired reads
        PairedKey pairedKey(emptyKey, tempKey2);
        pairedFinish = myPairedMap.lower_bound(pairedKey);
        mateStopPos =
            SamHelper::combineChromPos(reference,
                                       coordinate);
    }

    // For each key k < fragmentFinish, release the record since we are
    // done with that position and it is not a duplicate.
    for(FragmentMap::iterator iter = myFragmentMap.begin();
            iter != fragmentFinish; iter++)
    {
        // If it is not paired, we are done with this record.
        // If it is paired, it will be handled separately.
        if(!iter->second.paired)
        {
            // Unpaired, non-duplicate, so perform any additional handling.
            handleNonDuplicate();
        }
    }
    // Erase the entries from the map.
    if(fragmentFinish != myFragmentMap.begin())
    {
        myFragmentMap.erase(myFragmentMap.begin(), fragmentFinish);
    }

    // Now do the same thing with the paired reads
    for(PairedMap::iterator iter = myPairedMap.begin();
            iter != pairedFinish; iter++)
    {
        // These are not duplicates, but we are done with them,
        // so perform any additional handling.
        handleNonDuplicatePair();
    }
    // Erase the entries.
    if (pairedFinish != myPairedMap.begin())
    {
        myPairedMap.erase(myPairedMap.begin(), pairedFinish);
    }

    // Clean up the Mate map from any reads whose mates were not found.
    // Loop through the mate map and release records prior to this position.
    MateMap::iterator mateIter;
    for(mateIter = myMateMap.begin(); mateIter != myMateMap.end(); mateIter++)
    {
        // stop if a record was specified and we have gone past the mate
        // stop position.  If no record was specified, we want to clean
        // it all out.
        if((record != NULL) && (mateIter->first >= mateStopPos))
        {
            break;
        }
        // Passed the mate, but it was not found.
        handleMissingMate(mateIter->second.key.reference,
                          mateIter->first >> 32);
    }
    // Erase the entries.
    if(mateIter != myMateMap.begin())
    {
        myMateMap.erase(myMateMap.begin(), mateIter);
    }
    return;
}