Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
code.fromfile(file, 8)
if code.to01() != myBedTools.binaryseqfilegenome_code:
print "unexpected code for binary seq file genome!"
print "code: ", code
print "expected: ", myBedTools.binaryseqfilegenome_code
sys.exit(-1)
try:
chr_byte_start = self.chr_offset[exp_chr] * self.factor // 8
chr_partial_byte_start = (self.chr_offset[exp_chr] * self.factor) % 8
print 'starting at', chr_byte_start, 'bytes, with', chr_partial_byte_start, 'offset'
file.seek(chr_byte_start, 0)
ar.fromfile(file, self.chr_lens[exp_chr] * self.factor + 16)
print ar[0:100]
except EOFError:
pass
if ar.length() != bitarray_m.bits2bytes(self.chr_lens[exp_chr] * self.factor) * 8:
print "expected length of array to match given start and end!"
print filename
print ar.length(), bitarray_m.bits2bytes(self.genome_len * self.factor), self.genome_len * self.factor
sys.exit(-1)
pass
# shorten ar to genome_len
for i in xrange(ar.length() - self.genome_len * self.factor):
#print self.genome_len, ar.length(), 'popping'
ar.pop()
pass
self.bases = ar
pass
elif self.output_type == myBedTools.binaryseqfilegenome:
infile = myBedTools.open_file(filename, discard_header = header)
pass
code.fromfile(file, 8)
if code.to01() != myBedTools.binaryseqfilegenome_code:
print "unexpected code for binary seq file genome!"
print "code: ", code
print "expected: ", myBedTools.binaryseqfilegenome_code
sys.exit(-1)
try:
#ar.fromfile(file, self.genome_len * self.factor + 16)
ar.fromfile(file)
except EOFError:
pass
if ar.length() != bitarray_m.bits2bytes(self.genome_len * self.factor) * 8:
print "expected length of array to match given start and end!"
print filename
print ar.length(), bitarray_m.bits2bytes(self.genome_len * self.factor), self.genome_len * self.factor
sys.exit(-1)
pass
# shorten ar to genome_len
for i in xrange(ar.length() - self.genome_len * self.factor):
#print self.genome_len, ar.length(), 'popping'
ar.pop()
pass
self.bases = ar
pass
elif filetype == self.binaryseqfilegenomechr:
print "THIS DOESN'T WORK"
sys.exit(-1)
ar = bitarray()
code = bitarray()
file = gzip.open(filename, 'r')
else:
file = open(filename, 'r')
pass
code.fromfile(file, 8)
if code.to01() != myBedTools.binaryseqfilegenome_code:
print "unexpected code for binary seq file genome!"
print "code: ", code
print "expected: ", myBedTools.binaryseqfilegenome_code
sys.exit(-1)
try:
#ar.fromfile(file, self.genome_len * self.factor + 16)
ar.fromfile(file)
except EOFError:
pass
if ar.length() != bitarray_m.bits2bytes(self.genome_len * self.factor) * 8:
print "expected length of array to match given start and end!"
print filename
print ar.length(), bitarray_m.bits2bytes(self.genome_len * self.factor), self.genome_len * self.factor
sys.exit(-1)
pass
# shorten ar to genome_len
for i in xrange(ar.length() - self.genome_len * self.factor):
#print self.genome_len, ar.length(), 'popping'
ar.pop()
pass
self.bases = ar
pass
elif filetype == self.binaryseqfilegenomechr:
print "THIS DOESN'T WORK"
ar = bitarray()
code = bitarray()
file = open(filename, 'r')
#code.fromfile(file)
code.fromfile(file, 8)
if code.to01() != myBedTools.binarybedfilegenome_code:
print "unexpected code for binary bed file genome!"
print "code: ", code
print "expected: ", myBedTools.binarybedfilegenome_code
sys.exit(-1)
try:
#ar.fromfile(file, self.genome_len + 16)
ar.fromfile(file)
except EOFError:
pass
if ar.length() != bitarray_m.bits2bytes(self.genome_len) * 8:
print "expected length of array to match given start and end!"
print filename
print ar.length(), bitarray_m.bits2bytes(self.genome_len), self.genome_len
sys.exit(-1)
pass
# shorten ar to genome_len
for i in xrange(ar.length() - self.genome_len):
#print self.genome_len, ar.length(), 'popping'
ar.pop()
pass
#### COULD CHECK FNS FOR BITARRAY STUFF (AND, OR ETC)
if not self.initialize:
self.initialize = True
if fn == myBedTools.set_to_one:
self.bases = ar
elif fn == myBedTools.set_to_zero:
#code.fromfile(file)
code.fromfile(file, 8)
if code.to01() != myBedTools.binarybedfilegenome_code:
print "unexpected code for binary bed file genome!"
print "code: ", code
print "expected: ", myBedTools.binarybedfilegenome_code
sys.exit(-1)
try:
#ar.fromfile(file, self.genome_len + 16)
ar.fromfile(file)
except EOFError:
pass
if ar.length() != bitarray_m.bits2bytes(self.genome_len) * 8:
print "expected length of array to match given start and end!"
print filename
print ar.length(), bitarray_m.bits2bytes(self.genome_len), self.genome_len
sys.exit(-1)
pass
# shorten ar to genome_len
for i in xrange(ar.length() - self.genome_len):
#print self.genome_len, ar.length(), 'popping'
ar.pop()
pass
#### COULD CHECK FNS FOR BITARRAY STUFF (AND, OR ETC)
if not self.initialize:
self.initialize = True
if fn == myBedTools.set_to_one:
self.bases = ar
elif fn == myBedTools.set_to_zero:
self.bases = ~ar
else:
print "not initialized, and using fn other than set_to_one!"