Rcpp adding circular ranges to GRanges object in c++
0
0
Entering edit mode
@hauken_heyken-13992
Last seen 7 months ago
Bergen

Hey, I have the circular Ecoli genome, and I want to construct a GRanges object of all ORFs in the fasta file from ncbi.

I made a c++ function to do it, but of course since some of the orfs that starts just before the stop of the genome, and ends after the start, will make IRanges() constructor output error (negative widths not allowed), I want to something like in R where you can set the metacolumn of the GRangesobject to include isCircular() = vector(T,T,T,...),

Here is the sample from c++ and error:

#include <Rcpp.h>

Function GRangesC("GRanges", Environment::namespace_env("GenomicRanges"));
Function IRangesC("IRanges", Environment::namespace_env("IRanges"));

std::vector<int> ORFdef = orfs_as_vector(fastaSeq); // <- get all orfs from fasta

Seqnames.insert(Seqnames.end(), ORFdef.size() / 2, 1);
strands.insert(strands.end(),ORFdef.size() / 2,"+");

return(GRangesC(wrap(Seqnames),
IRangesC(wrap(result_value[0]),
wrap(result_value[1])),wrap(strands)));

Error in find_ORFs :
Evaluation error: solving row 149014: negative widths are not allowed.
GRanges circular rcpp IRanges • 673 views
0
Entering edit mode

In more simple terms, what I am saying is:

How do you allow negative widths on IRanges ?