bio-bigwig 0.0.3 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0585eab5aa345929c023943bafc6e27955be406f79379f056a9c45ec5d0b1933'
4
- data.tar.gz: 7ffd6b9bcce8e12382fad0fcfe26914f69da45a3db66b022c82007e9820abd9f
3
+ metadata.gz: 2a7c6f632a8789e179e25df4689ba33ea3afa6ab2e61eaa3eb4e2ec9aa83595b
4
+ data.tar.gz: d60bff195ccd4b53bce8c7cdc826e204d28df864bf6c564f23dea925e012b751
5
5
  SHA512:
6
- metadata.gz: 776424b2382940cc1b31242d527b3e468bc5abbfa7a98009fb662389cc79cd2693e49d365423263435db06ab09811d66e5634ca8c07b546ebd46ef1bfb243141
7
- data.tar.gz: d245494b5f68359d66fdb80250ab1de08dd9fc21db17f28436e90997b94ca6a5c90f72e9048bcbcf0a4906a274a2785074e57b896def130ab6ebccaa62943881
6
+ metadata.gz: bf0692a90f5dc3fd04d86f155360d4d917657dfd460fc93f44b49acf8669290d5b9c836b941b7723fdda3ad9afcf7ced19e0e73c5e81ad72df7bd46f8623e674
7
+ data.tar.gz: 3e9a81e355c12c6c161f46f66a16db12f707135f7b37b9459eb50e4824cf4739759bc346dede7237dafa4d181b0914317de9ccf0e3255df839edf9f2752fa2e3
@@ -89,12 +89,12 @@ bigwig_allocate(VALUE klass)
89
89
  return TypedData_Wrap_Struct(klass, &BigWig_type, bw);
90
90
  }
91
91
 
92
- //Return 1 if there are any entries at all
92
+ // Return 1 if there are any entries at all
93
93
  int hasEntries(bigWigFile_t *bw)
94
94
  {
95
95
  if (bw->hdr->indexOffset != 0)
96
96
  return 1; // No index, no entries pyBigWig issue #111
97
- //if(bw->hdr->nBasesCovered > 0) return 1; // Sometimes headers are broken
97
+ // if(bw->hdr->nBasesCovered > 0) return 1; // Sometimes headers are broken
98
98
  return 0;
99
99
  }
100
100
 
@@ -108,7 +108,7 @@ bigwig_init(VALUE self, VALUE rb_fname, VALUE rb_mode)
108
108
  fname = StringValueCStr(rb_fname);
109
109
  mode = StringValueCStr(rb_mode);
110
110
 
111
- //Open the local/remote file
111
+ // Open the local/remote file
112
112
  if (strchr(mode, 'w') != NULL || bwIsBigWig(fname, NULL))
113
113
  {
114
114
  bw = bwOpen(fname, NULL, mode);
@@ -130,7 +130,7 @@ bigwig_init(VALUE self, VALUE rb_fname, VALUE rb_mode)
130
130
  goto error;
131
131
  }
132
132
 
133
- //Set the data pointer
133
+ // Set the data pointer
134
134
  DATA_PTR(self) = bw;
135
135
 
136
136
  rb_ivar_set(self, rb_intern("@last_tid"), INT2NUM(-1));
@@ -162,6 +162,21 @@ bigwig_close(VALUE self)
162
162
  return Qnil;
163
163
  }
164
164
 
165
+ static VALUE
166
+ bigwig_is_closed(VALUE self)
167
+ {
168
+ bigWigFile_t *bw = get_bigWigFile(self);
169
+
170
+ if (bw)
171
+ {
172
+ return Qfalse;
173
+ }
174
+ else
175
+ {
176
+ return Qtrue;
177
+ }
178
+ }
179
+
165
180
  static VALUE
166
181
  bw_get_header(VALUE self)
167
182
  {
@@ -170,7 +185,7 @@ bw_get_header(VALUE self)
170
185
 
171
186
  if (!bw)
172
187
  {
173
- rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!");
188
+ rb_raise(rb_eIOError, "The bigWig file handle is not opened!");
174
189
  return Qnil;
175
190
  }
176
191
 
@@ -210,7 +225,7 @@ bw_get_chroms(int argc, VALUE *argv, VALUE self)
210
225
 
211
226
  if (!bw)
212
227
  {
213
- rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!");
228
+ rb_raise(rb_eIOError, "The bigWig file handle is not opened!");
214
229
  return Qnil;
215
230
  }
216
231
 
@@ -284,7 +299,7 @@ bw_get_stats(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end, VALUE rb_
284
299
 
285
300
  if (!bw)
286
301
  {
287
- rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!");
302
+ rb_raise(rb_eIOError, "The bigWig file handle is not opened!");
288
303
  return Qnil;
289
304
  }
290
305
 
@@ -397,7 +412,7 @@ bw_get_values(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end)
397
412
 
398
413
  if (!bw)
399
414
  {
400
- rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!");
415
+ rb_raise(rb_eIOError, "The bigWig file handle is not opened!");
401
416
  return Qnil;
402
417
  }
403
418
 
@@ -469,7 +484,7 @@ bw_get_intervals(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end)
469
484
 
470
485
  if (!bw)
471
486
  {
472
- rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!");
487
+ rb_raise(rb_eIOError, "The bigWig file handle is not opened!");
473
488
  return Qnil;
474
489
  }
475
490
 
@@ -498,7 +513,7 @@ bw_get_intervals(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end)
498
513
 
499
514
  tid = bwGetTid(bw, chrom);
500
515
 
501
- //Sanity check
516
+ // Sanity check
502
517
  if (endl == (unsigned long)-1 && tid != (uint32_t)-1)
503
518
  endl = bw->cl->len[tid];
504
519
 
@@ -522,7 +537,7 @@ bw_get_intervals(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end)
522
537
  return rb_ary_new2(0);
523
538
  }
524
539
 
525
- //Get the intervals
540
+ // Get the intervals
526
541
  intervals = bwGetOverlappingIntervals(bw, chrom, start, end);
527
542
  if (!intervals)
528
543
  {
@@ -558,7 +573,7 @@ bb_get_entries(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end, VALUE r
558
573
 
559
574
  if (!bw)
560
575
  {
561
- rb_raise(rb_eRuntimeError, "The bigBed file handle is not opened!");
576
+ rb_raise(rb_eIOError, "The bigBed file handle is not opened!");
562
577
  return Qnil;
563
578
  }
564
579
 
@@ -589,7 +604,7 @@ bb_get_entries(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end, VALUE r
589
604
 
590
605
  tid = bwGetTid(bw, chrom);
591
606
 
592
- //Sanity check
607
+ // Sanity check
593
608
  if (endl == (unsigned long)-1 && tid != (uint32_t)-1)
594
609
  endl = bw->cl->len[tid];
595
610
  if (tid == (uint32_t)-1 || startl > end || endl > end)
@@ -641,7 +656,8 @@ bb_get_entries(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end, VALUE r
641
656
  return ret;
642
657
 
643
658
  error:
644
- bbDestroyOverlappingEntries(o);
659
+ if (o)
660
+ bbDestroyOverlappingEntries(o);
645
661
  rb_raise(rb_eRuntimeError, "An error occurred while constructing the output!\n");
646
662
  return Qnil;
647
663
  }
@@ -655,7 +671,7 @@ bb_get_sql(VALUE self)
655
671
 
656
672
  if (!bw)
657
673
  {
658
- rb_raise(rb_eRuntimeError, "The bigBed file handle is not opened!");
674
+ rb_raise(rb_eIOError, "The bigBed file handle is not opened!");
659
675
  return Qnil;
660
676
  }
661
677
 
@@ -683,6 +699,12 @@ bw_get_file_type(VALUE self)
683
699
  {
684
700
  bigWigFile_t *bw = get_bigWigFile(self);
685
701
 
702
+ if (!bw)
703
+ {
704
+ rb_raise(rb_eIOError, "The bigWig file handle is not opened!");
705
+ return Qnil;
706
+ }
707
+
686
708
  if (bw->type == 0)
687
709
  {
688
710
  return rb_str_new2("BigWig");
@@ -696,11 +718,17 @@ bw_get_file_type(VALUE self)
696
718
  }
697
719
 
698
720
  static VALUE
699
- bw_is_bigwig_q(VALUE self)
721
+ bw_is_file_type(VALUE self, int type_check)
700
722
  {
701
723
  bigWigFile_t *bw = get_bigWigFile(self);
702
724
 
703
- if (bw->type == 0)
725
+ if (!bw)
726
+ {
727
+ rb_raise(rb_eIOError, "The bigWig file handle is not opened!");
728
+ return Qnil;
729
+ }
730
+
731
+ if (bw->type == type_check)
704
732
  {
705
733
  return Qtrue;
706
734
  }
@@ -711,18 +739,15 @@ bw_is_bigwig_q(VALUE self)
711
739
  }
712
740
 
713
741
  static VALUE
714
- bw_is_bigbed_q(VALUE self)
742
+ bw_is_bigwig_q(VALUE self)
715
743
  {
716
- bigWigFile_t *bw = get_bigWigFile(self);
744
+ return bw_is_file_type(self, 0); // 0 = BigWig
745
+ }
717
746
 
718
- if (bw->type == 1)
719
- {
720
- return Qtrue;
721
- }
722
- else
723
- {
724
- return Qfalse;
725
- }
747
+ static VALUE
748
+ bw_is_bigbed_q(VALUE self)
749
+ {
750
+ return bw_is_file_type(self, 1); // 1 = BigBed
726
751
  }
727
752
 
728
753
  void Init_bigwigext()
@@ -734,6 +759,7 @@ void Init_bigwigext()
734
759
 
735
760
  rb_define_private_method(rb_BigWig, "initialize_raw", bigwig_init, 2);
736
761
  rb_define_method(rb_BigWig, "close", bigwig_close, 0);
762
+ rb_define_method(rb_BigWig, "closed?", bigwig_is_closed, 0);
737
763
  rb_define_method(rb_BigWig, "header", bw_get_header, 0);
738
764
  rb_define_method(rb_BigWig, "chroms", bw_get_chroms, -1);
739
765
  rb_define_private_method(rb_BigWig, "stats_raw", bw_get_stats, 6);
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bio
4
4
  class BigWig
5
- VERSION = "0.0.3"
5
+ VERSION = "0.0.5"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-bigwig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-20 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a Ruby binding for libBigWig (https://github.com/dpryan79/libBigWig),
14
14
  which provides high-speed access to bigWig or bigBed files.