pick an appropriate kmer size based off of https://www.biostars.org/p/201474/
    tl;dr version: pick 31 unless the reads are very small, if not then guess
    that readlength / 2 is about right.
439689
def pick_kmersize(fq):
    
    if bam.is_bam(fq):
        readlength = bam.estimate_read_length(fq)
    else:
        readlength = fastq.estimate_read_length(fq)
    halfread = int(round(readlength / 2))
    if halfread >= 31:
        kmersize = 31
    else:
        kmersize = halfread
    if kmersize % 2 == 0:
        kmersize += 1
    return kmersize
112817
def Read(self, length):
    """"""
    result = b""

    # The total available size in the file
    length = int(length)
    length = min(length, self.size - self.offset)

    while length > 0:
      data = self._ReadPartial(length)
      if not data:
        break

      length -= len(data)
      result += data
    return result
775719
def _ReadEncodedData(self, read_size):
    
    encoded_data = self._file_object.read(read_size)

    read_count = len(encoded_data)

    self._encoded_data = b''.join([self._encoded_data, encoded_data])

    self._decoded_data, self._encoded_data = (
        self._decoder.Decode(self._encoded_data))

    self._decoded_data_size = len(self._decoded_data)

    return read_count
598980
def _heuristic_bin_width(obs):
    """"""
    IQR = sp.percentile(obs, 75) - sp.percentile(obs, 25)
    N = len(obs)
    return 2*IQR*N**(-1/3)
712288
private int determineSize(List<Match> t) {
        Match firstMatch = t.get(0);
        if (!(firstMatch.token instanceof SimpleToken)) {
            return t.size();
        }
        int charLength = 0;
        for (Match m : t) {
            SimpleToken token = (SimpleToken) m.token;
            charLength += token.getNormalized().length();
        }
        return charLength;
    }
281345
def read(self, size=-1):
        
        logger.debug("reading with size: %d", size)
        if self.response is None:
            return b''

        if size == 0:
            return b''
        elif size < 0 and len(self._read_buffer) == 0:
            retval = self.response.raw.read()
        elif size < 0:
            retval = self._read_buffer.read() + self.response.raw.read()
        else:
            while len(self._read_buffer) < size:
                logger.debug("http reading more content at current_pos: %d with size: %d", self._current_pos, size)
                bytes_read = self._read_buffer.fill(self._read_iter)
                if bytes_read == 0:
                    # Oops, ran out of data early.
                    retval = self._read_buffer.read()
                    self._current_pos += len(retval)

                    return retval

            # If we got here, it means we have enough data in the buffer
            # to return to the caller.
            retval = self._read_buffer.read(size)

        self._current_pos += len(retval)
        return retval
1175612
def slice_by_size(seq, size):
    """"""
    filling = null
    for it in zip(*(itertools_chain(seq, [filling] * size),) * size):
        if filling in it:
            it = tuple(i for i in it if i is not filling)
        if it:
            yield it
1210206
private int readerLength(File file, InputStreamReader isr)
	{
		String name = file.getName();

		if (name.endsWith(".docx"))
		{
			return ((DocxStreamReader) isr).length();
		} else if (name.endsWith(".odt"))
		{
			return ((ODFStreamReader) isr).length();
		} else
		{
			return (int) (file.length() + 1);
		}
	}
84803
def find_readlength(args):
    # type: (Namespace) -> int
    """"""

    try:
        bed_file = args.treatment[0]
    except AttributeError:
        bed_file = args.infiles[0]

    filereader = "cat "
    if bed_file.endswith(".gz") and search("linux", platform, IGNORECASE):
        filereader = "zcat "
    elif bed_file.endswith(".gz") and search("darwin", platform, IGNORECASE):
        filereader = "gzcat "
    elif bed_file.endswith(".bz2"):
        filereader = "bzgrep "

    command = filereader + "{} | head -10000".format(bed_file)
    output = check_output(command, shell=True)

    df = pd.read_table(
        BytesIO(output),
        header=None,
        usecols=[1, 2],
        sep="\t",
        names=["Start", "End"])

    readlengths = df.End - df.Start
    mean_readlength = readlengths.mean()
    median_readlength = readlengths.median()
    max_readlength = readlengths.max()
    min_readlength = readlengths.min()

    logging.info((
        "Used first 10000 reads of {} to estimate a median read length of {}\n"
        "Mean readlength: {}, max readlength: {}, min readlength: {}.").format(
            bed_file, median_readlength, mean_readlength, max_readlength,
            min_readlength))

    return median_readlength
663735
function checkLengths(k, n) {
  if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
}
638030
def ab_read(self, start, size):
        
        wordlen = snap7.snap7types.S7WLByte
        type_ = snap7.snap7types.wordlen_to_ctypes[wordlen]
        data = (type_ * size)()
        logger.debug("ab_read: start: %s: size %s: " % (start, size))
        result = self.library.Cli_ABRead(self.pointer, start, size,
                                         byref(data))
        check_error(result, context="client")
        return bytearray(data)
272012
function getSizeUnit(size) {
        var kbFactor = 1024;
        var mbFactor = kbFactor * 1024;
        var gbFactor = mbFactor * 1024;
        var tbFactor = gbFactor * 1024;

        if ((size / kbFactor) < 1024) {
            var r = (size / kbFactor).toFixed(2) + ' KB';
        }
        else if ((size / mbFactor) < 1024) {
            var r = (size / mbFactor).toFixed(2) + ' MB';
        }
        else if ((size / gbFactor) < 1024) {
            var r = (size / gbFactor).toFixed(2) + ' GB';
        }
        else if ((size / tbFactor) < 1024) {
            var r = (size / tbFactor).toFixed(2) + ' TB';
        }
        else {
            var r = (size).toFixed(2) + ' B';
        }

        return r;

    }
190342
def human_size(bytes, units=[' bytes','KB','MB','GB','TB', 'PB', 'EB']):
    
    return str(bytes) + units[0] if bytes < 1024 else human_size(bytes>>10, units[1:])
670207
def blksize(self):
        """"""
        self._blksize = self.lib.iperf_get_test_blksize(self._test)
        return self._blksize
429922
def fit_size(min_length: int = 0, max_length: int = None,
             message=None) -> Filter_T:
    

    def validate(value):
        length = len(value) if value is not None else 0
        if length < min_length or \
                (max_length is not None and length > max_length):
            _raise_failure(message)
        return value

    return validate
1102040
def read(self, length=None):
        
        if not length is None:
            if not isinstance(length, inttype) :
                raise TypeError("length to read should be number")
            buf = create_string_buffer(length)
            readbytes = libcrypto.BIO_read(self.bio, buf, length)
            if readbytes == -2:
                raise NotImplementedError("Function is not supported by" +
                                          "this BIO")
            if readbytes == -1:
                raise IOError
            if readbytes == 0:
                return b""
            return buf.raw[:readbytes]
        else:
            buf = create_string_buffer(1024)
            out = b""
            readbytes = 1
            while readbytes > 0:
                readbytes = libcrypto.BIO_read(self.bio, buf, 1024)
                if readbytes == -2:
                    raise NotImplementedError("Function is not supported by " +
                                              "this BIO")
                if readbytes == -1:
                    raise IOError
                if readbytes > 0:
                    out += buf.raw[:readbytes]
            return out
945137
def calc_intsize(self):
        

        # assume first cross blob starts after headxml and second is one int of bytes later
        for k in self.binarychunks.iterkeys():
            if int(k.split('/')[3]) == 1 and 'cross' in k.split('/')[-1]:
                headsize = self.binarychunks[k]
                break
        for k in self.binarychunks.iterkeys():
            if int(k.split('/')[3]) == 2 and 'cross' in k.split('/')[-1]:
                intsize = self.binarychunks[k] - headsize
                break

        return (headsize, intsize)