bio-bigwig 0.0.2 → 0.0.4

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: f41aa1f4b018bb4e095d971cff0aa56e82ff4e0e9b1be3f542c2479c10d5a8da
4
- data.tar.gz: 84de77c8c84d1542e14b34066f26fd969bb009dd94c7f6e9ed52a9b37d01a849
3
+ metadata.gz: 9fc197bd8ffd3edcbecd7c74e632b9b44d180b30540194e083aa23245822322d
4
+ data.tar.gz: 52075f2eccf948d9017e4b94ba5b4380cd66729610f8fbabe1a16732649ec5f6
5
5
  SHA512:
6
- metadata.gz: 940906811fbe9f4500e8ffaeaee6828482e90ecf2d4842bcc3b7521c5a3202b09c6e05e06448dbabc798ee45a148de0a6264a2a3b5deae4a00976684b6807b64
7
- data.tar.gz: cf77bebe39c40252a9aa0c6f62b2457bb143c380128fc5dae75f6628a0109fb93336d005c3e4e1d30cec716f8ed152e25324eb5f849e5fdcc402390a5f9346c6
6
+ metadata.gz: 27b8667fabdc77ef6e66544af79ccf9c2ea67c7a661649f7add0590f739ed82b0cc57026a6ffd23c7923faa1d9154146213d51fd6f2b56d6f43681b7f6fb00fb
7
+ data.tar.gz: 7a580a0ef61afdbcdb6eb56507de67c6a91bc610558e36892fae6ebca7b049aaec749012488613e40890a88d25d3c7370e467cbf691b47dca389caf278a69294
@@ -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));
@@ -498,7 +498,7 @@ bw_get_intervals(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end)
498
498
 
499
499
  tid = bwGetTid(bw, chrom);
500
500
 
501
- //Sanity check
501
+ // Sanity check
502
502
  if (endl == (unsigned long)-1 && tid != (uint32_t)-1)
503
503
  endl = bw->cl->len[tid];
504
504
 
@@ -522,7 +522,7 @@ bw_get_intervals(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end)
522
522
  return rb_ary_new2(0);
523
523
  }
524
524
 
525
- //Get the intervals
525
+ // Get the intervals
526
526
  intervals = bwGetOverlappingIntervals(bw, chrom, start, end);
527
527
  if (!intervals)
528
528
  {
@@ -589,7 +589,7 @@ bb_get_entries(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end, VALUE r
589
589
 
590
590
  tid = bwGetTid(bw, chrom);
591
591
 
592
- //Sanity check
592
+ // Sanity check
593
593
  if (endl == (unsigned long)-1 && tid != (uint32_t)-1)
594
594
  endl = bw->cl->len[tid];
595
595
  if (tid == (uint32_t)-1 || startl > end || endl > end)
@@ -641,7 +641,8 @@ bb_get_entries(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end, VALUE r
641
641
  return ret;
642
642
 
643
643
  error:
644
- bbDestroyOverlappingEntries(o);
644
+ if (o)
645
+ bbDestroyOverlappingEntries(o);
645
646
  rb_raise(rb_eRuntimeError, "An error occurred while constructing the output!\n");
646
647
  return Qnil;
647
648
  }
@@ -696,11 +697,17 @@ bw_get_file_type(VALUE self)
696
697
  }
697
698
 
698
699
  static VALUE
699
- bw_is_bigwig_q(VALUE self)
700
+ bw_is_file_type(VALUE self, int type_check)
700
701
  {
701
702
  bigWigFile_t *bw = get_bigWigFile(self);
702
703
 
703
- if (bw->type == 0)
704
+ if (!bw)
705
+ {
706
+ rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!");
707
+ return Qnil;
708
+ }
709
+
710
+ if (bw->type == type_check)
704
711
  {
705
712
  return Qtrue;
706
713
  }
@@ -711,18 +718,15 @@ bw_is_bigwig_q(VALUE self)
711
718
  }
712
719
 
713
720
  static VALUE
714
- bw_is_bigbed_q(VALUE self)
721
+ bw_is_bigwig_q(VALUE self)
715
722
  {
716
- bigWigFile_t *bw = get_bigWigFile(self);
723
+ return bw_is_file_type(self, 0); // 0 = BigWig
724
+ }
717
725
 
718
- if (bw->type == 1)
719
- {
720
- return Qtrue;
721
- }
722
- else
723
- {
724
- return Qfalse;
725
- }
726
+ static VALUE
727
+ bw_is_bigbed_q(VALUE self)
728
+ {
729
+ return bw_is_file_type(self, 1); // 1 = BigBed
726
730
  }
727
731
 
728
732
  void Init_bigwigext()
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Devon Ryan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+