// ----------------------------------------------------------------------------
// CNATFWUNSAFHostResolver::RunL
// ----------------------------------------------------------------------------
//
void CNATFWUNSAFHostResolver::RunL()
    {
    NATFWUNSAF_INTLOG("CNATFWUNSAFHostResolver::RunL: status", iStatus.Int())
    NATFWUNSAF_INTLOG("CNATFWUNSAFHostResolver::RunL: observerCancel",
        iObserverCancel)

    iFailed = EFalse;
    TBool subquery = EFalse;
    TInt status = iStatus.Int();
    MNATFWUNSAFServerResolverObserver* observer =
        iQuery->ServerResolverObserver();
    if ( !iObserverCancel )
        {
        subquery = iQuery->HandleQueryResultL( iStatus.Int() );
        }

    NATFWUNSAF_INTLOG("CNATFWUNSAFHostResolver::RunL: subquery", subquery);

    if ( subquery )
        {
        iQuery->Query( *this );
        SetActive();
        }
    else
        {
        if ( iObserverCancel )
            {
            iObserverCancel = EFalse;
            NextQuery();
            }
        else
            {
            if ( status == KErrNone )
                {
                NextQuery();
                observer->CompletedL();
                }
            else
                {//status _ne_ KErrNone || iFailed
                NextQuery();
                observer->ErrorOccured( status );
                }
            }
        }
    }
Esempio n. 2
0
/*
    Constructor with filenames
*/
ChromSweep::ChromSweep(string &queryFile, string &dbFile) 
{
    _hits.reserve(100000);

    _query = new BedFile(queryFile);
    _db = new BedFile(dbFile);
    
    _query->Open();
    _db->Open();
    
    NextQuery();
    NextDatabase();
}
Esempio n. 3
0
/*
    // constructor using existing BedFile pointers
*/
ChromSweep::ChromSweep(BedFile *query, BedFile *db, 
                       bool sameStrand, bool diffStrand, 
                       float overlapFraction, bool reciprocal,
                       bool useMergedIntervals, bool printHeader)


: _query(query)
, _db(db)
, _overlapFraction(overlapFraction)
, _sameStrand(sameStrand)
, _diffStrand(diffStrand)
, _reciprocal(reciprocal)
, _useMergedIntervals(useMergedIntervals)
{
    _hits.reserve(100000);

    _query->Open();
    if (printHeader) _query->PrintHeader();
    _db->Open();
    
    NextQuery();
    NextDatabase();
}
Esempio n. 4
0
bool ChromSweep::ChromChange()
{
    // the files are on the same chrom
    if (_curr_qy.chrom == _curr_db.chrom) {
        return false;
    }
    // the query is ahead of the database. 
	// fast-forward the database to catch-up.
    else if ((_curr_qy.chrom > _curr_db.chrom) && (!_db->Empty())) {

        while (NextDatabase() && 
               _curr_db.chrom < _curr_qy.chrom)
        {
        }
        _cache.clear();
        return false;
    }
    // the database is ahead of the query.
    else {
        // 1. scan the cache for remaining hits on the query's current chrom.
        if (_curr_qy.chrom == _curr_chrom)
        {
            ScanCache();
            _results.push(make_pair(_curr_qy, _hits));
            _hits.clear();
        }
        // 2. fast-forward until we catch up and report 0 hits until we do.
        else if (_curr_qy.chrom < _curr_db.chrom)
        {
            _results.push(make_pair(_curr_qy, _no_hits));
            _cache.clear();
        }
        NextQuery();
        _curr_chrom = _curr_qy.chrom;
        return true;
    }
}
Esempio n. 5
0
bool ChromSweep::Next(pair<BED, vector<BED> > &next) {
    if (!_query->Empty()) {
        // have we changed chromosomes?
        if (ChromChange() == false) {
            // scan the database cache for hits
            ScanCache();
            // advance the db until we are ahead of the query. 
            // update hits and cache as necessary
            while (!_db->Empty() && 
                   _curr_qy.chrom == _curr_db.chrom && 
                   !(after(_curr_db, _curr_qy)))
            {
                if (IsValidHit(_curr_qy, _curr_db)) {
                    _hits.push_back(_curr_db);
                }
                _cache.push_back(_curr_db);
                NextDatabase();
            }
            // add the hits for this query to the pump
            _results.push(make_pair(_curr_qy, _hits));
            // reset for the next query
            _hits.clear();
            NextQuery();
            _curr_chrom = _curr_qy.chrom;
        }
    }
    // report the next set if hits if there are still overlaps in the pump
    if (!_results.empty()) {
        next = _results.front();
        _results.pop();
        return true;
    }
    else {
        return false;
    }
}