Read files and return study and population.
16773
def rd_files(self, study_fn, pop_fn):
        """"""
        study, pop = self._read_geneset(study_fn, pop_fn)
        print("Study: {0} vs. Population {1}\n".format(len(study), len(pop)))
        return study, pop
716551
def _get_data(self, read_size):
        """"""
        if NIX:
            return super(Mouse, self)._get_data(read_size)
        return self._pipe.recv_bytes()
272388
def read_file(fpath):
    """"""
    with io.open(os.path.join(PATH_BASE, fpath)) as f:
        return f.read()
1268493
def bytes(self, count):
        """"""

        if count < 0:
            raise ValueError

        # fast path
        if self._bits == 0:
            data = self._fileobj.read(count)
            if len(data) != count:
                raise BitReaderError("not enough data")
            return data

        return bytes(bytearray(self.bits(8) for _ in xrange(count)))
740414
def read_content(self):
        """"""
        buf = StringIO()
        data = self.read_content_chunk()
        while data:
            if buf.tell() + len(data) > self.aggregate.config["maxfilesizedownload"]:
                raise LinkCheckerError(_("File size too large"))
            buf.write(data)
            data = self.read_content_chunk()
        return buf.getvalue()
863096
def _reads_in_peaks(bam_file, peaks_file, sample):
    """"""
    if not peaks_file:
        return {}
    rip = number_of_mapped_reads(sample, bam_file, bed_file = peaks_file)
    return {"metrics": {"RiP": rip}}
461433
def read(fname):
    "  "
    if exists(fname):
        return open(join(dirname(__file__), fname)).read()
1180232
def read_in_chunks(file_object, chunk_size=CHUNK_SIZE):
    """"""
    while True:
        data = file_object.read(chunk_size)
        if not data:
            break
        yield data
154992
def parse_files(self, req, name, field):
        """"""
        return get_value(req.files, name, field)
915125
def read(self):
        """"""
        # Validate file path
        assert os.path.isfile(self.file_path), 'No such file exists: ' + str(self.file_path)

        # Open CSV file and read contents
        with open(self.file_path, 'r') as f:
            reader = csv_builtin.reader(f)
            loaded_data = list(reader)

        # Force digits to become integers
        return juggle_types(loaded_data)
1167146
def file_reader(self):
        """"""
        self.update_config()
        path = self.config['path']
        fourcc = self.metadata.get('fourcc')
        xlen, ylen = self.metadata.image_size()
        # set bits per pixel and component dimensions
        if fourcc in ('BGR[24]',):
            bpp = 24
            Y_shape = (ylen, xlen)
        elif fourcc in ('RGB[24]',):
            bpp = 24
            Y_shape = (ylen, xlen, 3)
        elif fourcc in ('IYU2',):
            bpp = 24
            Y_shape = (ylen, xlen, 1)
            UV_shape = (ylen, xlen)
        elif fourcc in ('UYVY', 'UYNV', 'Y422', 'HDYC', 'YVYU', 'YUYV',
                        'YV16', 'YUY2', 'YUNV', 'V422'):
            bpp = 16
            Y_shape = (ylen, xlen, 1)
            UV_shape = (ylen, xlen // 2)
        elif fourcc in ('IYUV', 'I420', 'YV12'):
            bpp = 12
            Y_shape = (ylen, xlen, 1)
            UV_shape = (ylen // 2, xlen // 2)
        elif fourcc in ('YVU9',):
            bpp = 9
            Y_shape = (ylen, xlen, 1)
            UV_shape = (ylen // 4, xlen // 4)
        else:
            self.logger.critical("Can't open %s files", fourcc)
            return
        bytes_per_frame = (xlen * ylen * bpp) // 8
        zlen = os.path.getsize(path) // bytes_per_frame
        if zlen < 1:
            self.logger.critical("Zero length file %s", path)
            return
        # set raw array slice parameters
        if fourcc in ('BGR[24]',):
            Y_slice = ((2, None, 3), (1, None, 3), (0, None, 3))
            UV_slice = None
        elif fourcc in ('RGB[24]',):
            Y_slice = ((0, None, 1),)
            UV_slice = None
        elif fourcc in ('IYU2',):
            Y_slice = ((1, None, 3),)
            UV_slice = ((0, None, 3), (2, None, 3))
        elif fourcc in ('UYVY', 'UYNV', 'Y422', 'HDYC'):
            # packed format, UYVY order
            Y_slice = ((1, None, 2),)
            UV_slice = ((0, None, 4), (2, None, 4))
        elif fourcc in ('YVYU',):
            # packed format, YVYU order
            Y_slice = ((0, None, 2),)
            UV_slice = ((3, None, 4), (1, None, 4))
        elif fourcc in ('YUYV', 'YUY2', 'YUNV', 'V422'):
            # packed format, YUYV order
            Y_slice = ((0, None, 2),)
            UV_slice = ((1, None, 4), (3, None, 4))
        elif fourcc in ('IYUV', 'I420'):
            # planar format, YUV order
            Y_size = xlen * ylen
            UV_size = UV_shape[0] * UV_shape[1]
            Y_slice = ((0,                Y_size,                 1),)
            UV_slice = ((Y_size,           Y_size + UV_size,       1),
                        (Y_size + UV_size, Y_size + (UV_size * 2), 1))
        elif fourcc in ('YV16', 'YV12', 'YVU9'):
            # planar format, YVU order
            Y_size = xlen * ylen
            UV_size = UV_shape[0] * UV_shape[1]
            Y_slice = ((0,                Y_size,                 1),)
            UV_slice = ((Y_size + UV_size, Y_size + (UV_size * 2), 1),
                        (Y_size,           Y_size + UV_size,       1))
        else:
            self.logger.critical("Can't open %s files", fourcc)
            return
        # set frame type
        if fourcc in ('BGR[24]', 'RGB[24]'):
            self.Y_type = 'RGB'
        else:
            self.Y_type = 'Y'
            self.UV_type = 'CbCr'
        file_frame = 0
        direction = 1
        with io.open(path, 'rb', 0) as raw_file:
            while True:
                self.update_config()
                if file_frame >= zlen:
                    if self.config['looping'] == 'off':
                        break
                    elif self.config['looping'] == 'repeat':
                        file_frame = 0
                        raw_file.seek(0)
                    else:
                        file_frame = zlen - 2
                        direction = -1
                elif file_frame < 0:
                    file_frame = 1
                    direction = 1
                if direction != 1:
                    raw_file.seek((direction - 1) * bytes_per_frame, io.SEEK_CUR)
                file_frame += direction
                raw_data = raw_file.read(bytes_per_frame)
                # convert to numpy arrays
                raw_array = numpy.frombuffer(raw_data, numpy.uint8)
                Y_data = []
                for start, end, step in Y_slice:
                    raw_data = raw_array[start:end:step]
                    Y_data.append(raw_data.reshape(Y_shape))
                if len(Y_data) > 1:
                    Y_data = numpy.dstack(Y_data)
                else:
                    Y_data = Y_data[0]
                if UV_slice:
                    UV_data = []
                    for start, end, step in UV_slice:
                        raw_data = raw_array[start:end:step]
                        UV_data.append(raw_data.reshape(UV_shape))
                    UV_data = numpy.dstack(UV_data)
                    # remove offset
                    UV_data = UV_data.astype(pt_float) - pt_float(128.0)
                else:
                    UV_data = None
                yield Y_data, UV_data
857505
def read(self):
        """"""
        if self._is_initialized:
            return
        self._is_initialized = True

        if not isinstance(self._file_or_files, (tuple, list)):
            files_to_read = [self._file_or_files]
        else:
            files_to_read = list(self._file_or_files)
        # end assure we have a copy of the paths to handle

        seen = set(files_to_read)
        num_read_include_files = 0
        while files_to_read:
            file_path = files_to_read.pop(0)
            fp = file_path
            file_ok = False

            if hasattr(fp, "seek"):
                self._read(fp, fp.name)
            else:
                # assume a path if it is not a file-object
                try:
                    with open(file_path, 'rb') as fp:
                        file_ok = True
                        self._read(fp, fp.name)
                except IOError:
                    continue

            # Read includes and append those that we didn't handle yet
            # We expect all paths to be normalized and absolute (and will assure that is the case)
            if self._has_includes():
                for _, include_path in self.items('include'):
                    if include_path.startswith('~'):
                        include_path = osp.expanduser(include_path)
                    if not osp.isabs(include_path):
                        if not file_ok:
                            continue
                        # end ignore relative paths if we don't know the configuration file path
                        assert osp.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
                        include_path = osp.join(osp.dirname(file_path), include_path)
                    # end make include path absolute
                    include_path = osp.normpath(include_path)
                    if include_path in seen or not os.access(include_path, os.R_OK):
                        continue
                    seen.add(include_path)
                    # insert included file to the top to be considered first
                    files_to_read.insert(0, include_path)
                    num_read_include_files += 1
                # each include path in configuration file
            # end handle includes
        # END for each file object to read

        # If there was no file included, we can safely write back (potentially) the configuration file
        # without altering it's meaning
        if num_read_include_files == 0:
            self._merge_includes = False
30821
function aggregateCoverage(files) {
  var i, len, file, content, results;
  var resultsObj = getEmptyResultObject();

  for (i = 0, len = files.length; i < len; i++) {
    file = files[i];
    content = JSON.parse(fs.readFileSync(file).toString());
    resultsObj = populateCoverage(resultsObj, content);
  }

  return resultsObj;
}
39706
def get_study_items(results):
        """"""
        study_items = set()
        for obj in results:
            study_items.update(obj.study_items)
        return study_items
90067
def read(self):
        """"""
        if 'r' == self._mode:
            return self._read_response.text
        elif 'rb' == self._mode:
            return self._read_response.content
        else:
            raise IOError("File not opened in read mode.")
1203411
def read_datafiles(files, dtype, column):
    '''
    '''
    pha = []
    pha_fpi = []
    for filename, filetype in zip(files, dtype):
        if filetype == 'cov':
            cov = load_cov(filename)
        elif filetype == 'mag':
            mag = load_rho(filename, column)
        elif filetype == 'pha':
            pha = load_rho(filename, 2)
        elif filetype == 'pha_fpi':
            pha_fpi = load_rho(filename, 2)

    return cov, mag, pha, pha_fpi
1361887
def _collect_data(directory, input_ext, target_ext):
  """"""
  # Directory from string to tuple pair of strings
  # key: the filepath to a datafile including the datafile's basename. Example,
  #   if the datafile was "/path/to/datafile.wav" then the key would be
  #   "/path/to/datafile"
  # value: a pair of strings (input_filepath, target_filepath)
  data_files = {}
  for root, _, filenames in os.walk(directory):
    input_files = [filename for filename in filenames if input_ext in filename]
    for input_filename in input_files:
      basename = input_filename.strip(input_ext)
      input_file = os.path.join(root, input_filename)
      target_file = os.path.join(root, basename + target_ext)
      key = os.path.join(root, basename)
      assert os.path.exists(target_file)
      assert key not in data_files
      data_files[key] = (input_file, target_file)
  return data_files