예제 #1
0
/**
 * Populate sequence names from files.
 * Searches headers first folllowed by tabix.
 */
void BCFSyncedStreamReader::add_interval(int32_t i)
{
    int32_t nseqs = 0;
    const char **seq_names = NULL;

    if (hdrs[i])
    {
        seq_names = bcf_hdr_seqnames(hdrs[i], &nseqs);
        for (uint32_t j=0; j<nseqs; ++j)
        {
            std::string seq(seq_names[j]);
            if (intervals_map.find(seq)==intervals_map.end())
            {
                intervals_map[seq] = intervals_map.size();
                intervals.push_back(GenomeInterval(seq));
            }
        }
        if(seq_names) free(seq_names);
    }

    if (tbxs[i])
    {
        seq_names = tbx_seqnames(tbxs[i], &nseqs);
        for (uint32_t j=0; j<nseqs; ++j)
        {
            std::string seq(seq_names[j]);
            if (intervals_map.find(seq)==intervals_map.end())
            {
                intervals_map[seq] = intervals_map.size();
                intervals.push_back(GenomeInterval(seq));
            }
        }
        if(seq_names) free(seq_names);
    }
}
예제 #2
0
/**
 * Populate sequence names from files.
 */
void BCFSyncedStreamReader::remove_interval(std::string& interval)
{
    if (intervals_map.find(interval)!=intervals_map.end())
    {
        intervals_map[interval] = intervals_map.size();
        intervals.push_back(GenomeInterval(interval));
    }
}
예제 #3
0
static
unsigned
testOverlap(
    SVLocusSet& locusSet,
    const int32_t tid,
    const int32_t beginPos,
    const int32_t endPos)
{
    std::set<SVLocusSet::NodeAddressType> intersect;
    locusSet.getRegionIntersect(GenomeInterval(tid,beginPos,endPos),intersect);
    return intersect.size();
}
예제 #4
0
static
void
runDSL(const DSLOptions& opt)
{

    SVLocusSet set;
    set.load(opt.graphFilename.c_str());

    const SVLocusSet& cset(set);

    std::ostream& os(std::cout);

    // add this handy map of chromosome id to chromosome label at the start of all output types:
    os << cset.header << "\n";

    if (! opt.region.empty())
    {
        int32_t tid,beginPos,endPos;
        parse_bam_region(set.header, opt.region, tid, beginPos, endPos); // parse the region

        set.dumpRegion(os,GenomeInterval(tid,beginPos,endPos));
    }
    else if (opt.isLocusIndex)
    {
        const SVLocus& locus(cset.getLocus(opt.locusIndex));
        if (opt.locusFilename.empty())
        {
            os << locus;
        }
        else
        {
            std::ofstream ofs(opt.locusFilename.c_str(), std::ios::binary);
            boost::archive::binary_oarchive oa(ofs);
            oa << locus;
        }
    }
    else
    {
        cset.dump(os);
    }
}