shaq_lib 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/shaq_lib/shaq_lib.c +20 -30
- data/lib/shaq_lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6983dfff11ad58d69b2ec28cf964e24cd7ce0ed
|
4
|
+
data.tar.gz: 77bf99e586699ff6563171382fbea1fbd341f7ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc9fe0259c78bb427323ac47b27644782c89d72e8ad5860c3655a20158b3bb8e29a73f3ef112dafc3d336725f6a0ab4766601b890f531564dd1357491a057708
|
7
|
+
data.tar.gz: c7666b414eadd48950542468fc2edd8bcccda592559b852579c9f341d77d35d287bf2c28178517588e21cdb9f6ec723239c03a067d85c7cd20983dfc8e7130ee
|
data/ext/shaq_lib/shaq_lib.c
CHANGED
@@ -3,22 +3,11 @@
|
|
3
3
|
static VALUE kmers(VALUE klass, VALUE str, VALUE ksize)
|
4
4
|
{
|
5
5
|
long i = 0;
|
6
|
-
long j = 0;
|
7
6
|
long k = NUM2LONG(ksize);
|
8
7
|
long num_kmers = RSTRING_LEN(str) - k + 1;
|
9
8
|
|
10
|
-
char *c_str = RSTRING_PTR(str);
|
11
|
-
|
12
9
|
for (i = 0; i < num_kmers; ++i) {
|
13
|
-
|
14
|
-
|
15
|
-
for (j = 0; j < k; ++j) {
|
16
|
-
substr[j] = c_str[i+j];
|
17
|
-
}
|
18
|
-
substr[j] = '\0';
|
19
|
-
|
20
|
-
/* for this, put the length without the null char */
|
21
|
-
rb_yield(rb_str_new(substr, k));
|
10
|
+
rb_yield(rb_str_substr(str, i, k));
|
22
11
|
}
|
23
12
|
|
24
13
|
return str;
|
@@ -26,34 +15,35 @@ static VALUE kmers(VALUE klass, VALUE str, VALUE ksize)
|
|
26
15
|
|
27
16
|
static VALUE submers(VALUE klass, VALUE str)
|
28
17
|
{
|
29
|
-
long
|
30
|
-
|
18
|
+
long strlen = RSTRING_LEN(str);
|
19
|
+
VALUE s1, s2;
|
31
20
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
char *c_str = RSTRING_PTR(str);
|
36
|
-
|
37
|
-
for (i = 0; i < ksize; ++i) {
|
38
|
-
k1[i] = c_str[i];
|
39
|
-
k2[i] = c_str[i+1];
|
40
|
-
}
|
41
|
-
k1[i] = '\0';
|
42
|
-
k2[i] = '\0';
|
43
|
-
|
44
|
-
VALUE k1_r = rb_str_new(k1, ksize);
|
45
|
-
VALUE k2_r = rb_str_new(k2, ksize);
|
21
|
+
s1 = rb_str_substr(str, 0, strlen-1);
|
22
|
+
s2 = rb_str_substr(str, 1, strlen-1);
|
46
23
|
|
47
24
|
VALUE ary = rb_ary_new2(2);
|
48
|
-
|
49
|
-
rb_ary_push(ary,
|
25
|
+
|
26
|
+
rb_ary_push(ary, s1);
|
27
|
+
rb_ary_push(ary, s2);
|
50
28
|
|
51
29
|
return ary;
|
52
30
|
}
|
53
31
|
|
32
|
+
/* static VALUE count(VALUE klass, VALUE ary) */
|
33
|
+
/* { */
|
34
|
+
/* long len = RARRAY_LEN(ary); */
|
35
|
+
|
36
|
+
/* VALUE hash = rb_hash_new(); */
|
37
|
+
|
38
|
+
/* rb_hash_aset(hash, rb_str_new2("mykey"), rb_str_new2("myvalue")); */
|
39
|
+
|
40
|
+
/* return len; */
|
41
|
+
/* } */
|
42
|
+
|
54
43
|
void Init_shaq_lib(void)
|
55
44
|
{
|
56
45
|
VALUE ModuleShaqLib = rb_define_module("ShaqLib");
|
57
46
|
rb_define_singleton_method(ModuleShaqLib, "kmers", kmers, 2);
|
58
47
|
rb_define_singleton_method(ModuleShaqLib, "submers", submers, 1);
|
48
|
+
/* rb_define_singleton_method(ModuleShaqLib, "count", count, 1); */
|
59
49
|
}
|
data/lib/shaq_lib/version.rb
CHANGED