Giter Club home page Giter Club logo

cgranges's People

Contributors

jiazhen-rong avatar lh3 avatar nh13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cgranges's Issues

Question: Is `overlap` more tight in collision detection than `contain` ?

I noticed a difference in behaviour when calling the contain and overlap functions.

First, adds the interval cr_add(cr, "chr1", 10, 10, 0);

overlap ("chr1", 10, 20) finds nothing.
contain ("chr1", 10, 20) finds this interval.

#include <stdio.h>
#include <stdlib.h>
#include "cgranges.h"

int main(void)
{
	cgranges_t *cr = cr_init();
	cr_add(cr, "chr1", 10, 10, 0);
	cr_index(cr);

	int64_t i, n, *b = 0, max_b = 0;
	n = cr_overlap(cr, "chr1", 10, 11, &b, &max_b);
	for (i = 0; i < n; ++i)
		printf("%d\t%d\t%d\n", cr_start(cr, b[i]), cr_end(cr, b[i]), cr_label(cr, b[i]));
	free(b);

	cr_destroy(cr);
	return 0;
}
# no output
#include <stdio.h>
#include <stdlib.h>
#include "cgranges.h"

int main(void)
{
	cgranges_t *cr = cr_init();
	cr_add(cr, "chr1", 10, 10, 0);
	cr_index(cr);

	int64_t i, n, *b = 0, max_b = 0;
	n = cr_contain(cr, "chr1", 10, 11, &b, &max_b);
	for (i = 0; i < n; ++i)
		printf("%d\t%d\t%d\n", cr_start(cr, b[i]), cr_end(cr, b[i]), cr_label(cr, b[i]));
	free(b);

	cr_destroy(cr);
	return 0;
}
10	10	0

This behaviour was somewhat surprising. Is this normal behaviour? I'm not very familiar with genomics, so I don't know exactly how it should behave.

Preprint/paper on CRanges planned?

I am very interested in wrapping this library in Cython and implementing functionality to avoid the Python overhead by allowing for batch queries. This is because I might want to use CRanges in my PyRanges library.

  1. is that okay with you?
  2. if so, how should I cite cranges?

Ruby bindings

Hi!

I am pleased to inform you that I have created a Ruby language binding for cgranges.
This is a native Ruby C extension, unlike ruby-minimap2, which uses ffi.
Understanding the algorithm is difficult for me, but I can call it anyway.

Have a nice day!

https://github.com/ruby-on-bioc/bio-cgranges

Shadowing

Getting a warning about variable shadowing.

../src/third-party/cgranges/IITree.h:48:35: warning: declaration shadows a field of 'IITree<S, T>' [-Wshadow]
                bool operator()(const Interval &a, const Interval &b) const { return a.st < b.st; }
                                                ^
../src/third-party/cgranges/IITree.h:50:24: note: previous declaration is here
        std::vector<Interval> a;
                              ^
../src/third-party/cgranges/IITree.h:52:40: warning: declaration shadows a field of 'IITree<S, T>' [-Wshadow]
        int index_core(std::vector<Interval> &a) {
                                              ^
../src/third-party/cgranges/IITree.h:50:24: note: previous declaration is here
        std::vector<Interval> a;

Undefined behavior

Dear @lh3,

While running sanitation (address,undefined), I hit errors in IITree. I attempted debugging, but was unable to figure out the shifts. I would really appreciate it if you could take a look at this undefined behavior, and variable name masking. Let me know if I can help in any way.

Best wishes,

Zev

+  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/third-party/cgranges/IITree.h:84:41 in
+  ../src/third-party/cgranges/IITree.h:84:54: runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long long'
+  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/third-party/cgranges/IITree.h:84:54 in
+  ../src/third-party/cgranges/IITree.h:88:24: runtime error: shift exponent -1 is negative
+  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/third-party/cgranges/IITree.h:88:24 in
+  ../src/third-party/cgranges/IITree.h:88:31: runtime error: shift exponent -1 is negative
+  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/third-party/cgranges/IITree.h:88:31 in

6da723's change prevents bedcov-iitree-bfs from compiling

Hi,

6da723 (fixes #7) introduced if (max_level < 0) return false; into cpp/IITreeBFS.h , but max_level is only defined & used in the IITree class of cpp/IITree.h ...?

On current head (2fb5a2):

$ make
g++ -g -Wall -O3 -D_USE_BFS -std=c++98 -I.. -I../cpp bedcov-iitree.cpp -lz -o bedcov-iitree-bfs
In file included from bedcov-iitree.cpp:6:
../cpp/IITreeBFS.h: In member function ‘bool IITree<S, T>::overlap(const S&, const S&, std::vector<long unsigned int>&) const’:
../cpp/IITreeBFS.h:65:7: error: ‘max_level’ was not declared in this scope
   65 |   if (max_level < 0) return false;
      |       ^~~~~~~~~
make: *** [bedcov-iitree-bfs] Error 1

Thank you!

speed

hi, thanks for the nice library. I wrapped it for nim-lang thinking it would be faster than my naive library.
See timings here:
https://github.com/brentp/nim-cgranges

My library (here: https://github.com/brentp/nim-lapper) has horrible worst-case performance given some huge intervals, because it's just sorted by start, with knowledge of longest interval. But, it does seem to work well for most genomic data-types which often do not have huge intervals.

I wonder if you could see if a simple datastructure like the one in nim-lapper holds up in your timings. (Or if you see something wrong with my code that would result in slowing down cgranges-- I was surprised at the result).

current timings here: https://github.com/brentp/nim-cgranges#speed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.