shaq_lib 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb132b1dbcc0e5a2bad94e9b8ec73f83bbad068e
4
- data.tar.gz: c953f84542a7b4c89dd8c0afb096e0cb95ae892c
3
+ metadata.gz: c6983dfff11ad58d69b2ec28cf964e24cd7ce0ed
4
+ data.tar.gz: 77bf99e586699ff6563171382fbea1fbd341f7ce
5
5
  SHA512:
6
- metadata.gz: 2a0820198df89944c0590054b8c291c3bf7c48d5952f79ea1cea81a74b34b0bebe1642bee16f13b497c9eb634e8c0b538dd08d6868e5f12aa1f7f1dec80ed952
7
- data.tar.gz: a7aa47731d8ebf3a51a89c73c9e369e2853adbdc27e4ca0a0136da7b4e0da5690a51d1a7c26b593d3ddf9b49b13d6eaec29b1858c612f4993106f93cf2b03677
6
+ metadata.gz: cc9fe0259c78bb427323ac47b27644782c89d72e8ad5860c3655a20158b3bb8e29a73f3ef112dafc3d336725f6a0ab4766601b890f531564dd1357491a057708
7
+ data.tar.gz: c7666b414eadd48950542468fc2edd8bcccda592559b852579c9f341d77d35d287bf2c28178517588e21cdb9f6ec723239c03a067d85c7cd20983dfc8e7130ee
@@ -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
- char substr[k+1];
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 ksize = RSTRING_LEN(str) - 1;
30
- long i = 0;
18
+ long strlen = RSTRING_LEN(str);
19
+ VALUE s1, s2;
31
20
 
32
- char k1[ksize+1];
33
- char k2[ksize+1];
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
- rb_ary_push(ary, k1_r);
49
- rb_ary_push(ary, k2_r);
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
  }
@@ -1,3 +1,3 @@
1
1
  module ShaqLib
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shaq_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moore