Deserialize ``fp`` to a BioC collection object.

        Args:
            fp: a ``.read()``-supporting file-like object containing a BioC collection

        Returns:
            an object of BioCollection
356887
def decode(self, fp: TextIO) -> BioCCollection:
        
        # utf8_parser = etree.XMLParser(encoding='utf-8')
        tree = etree.parse(fp)
        collection = self.__parse_collection(tree.getroot())
        collection.encoding = tree.docinfo.encoding
        collection.standalone = tree.docinfo.standalone
        collection.version = tree.docinfo.xml_version
        return collection
891346
def to_python(fname, *args):
    
    [node] = read(fname)
    return node_to_obj(node, fname, *args)
455137
def _read_metadata(self):
        

        filetype = self.fp.readline().strip()
        filetitle = self.fp.readline().strip()
        # Decode to UTF string, if possible
        try:
            filetype = str(filetype, 'utf-8')
            filetitle = str(filetitle, 'utf-8')
        except:
            # TODO: Handle this edge-case of converting file metadata more elegantly.
            pass

        self.__setattr__('filetype', filetype)
        self.__setattr__('filetitle', filetitle)
871449
def set_metadata(self, fp):
        
        base_url = self._client.get_url('SET', 'GET', 'single', {'id': self.id})
        self._manager._metadata.set(base_url, fp)

        # reload myself
        r = self._client.request('GET', base_url)
        return self._deserialize(r.json(), self._manager)
663348
def parseProfileLine(fp):
    '''
    
    '''
    nextLine = fp.readline()
    if nextLine == None or nextLine == '':
        return (None, None)
    else:
        pieces = nextLine.strip('\n').split(',')
        return (pieces[0], int(pieces[1]))
1348481
def parse_gene_set(gene_set_fp):
    
    group_gene_set_dict = OrderedDict()

    with open(gene_set_fp) as inFile:
        for line in inFile.readlines():
            tokens = line.strip().split('\t')
            group = tokens[0]
            gene_set = set(tokens[1:])

            group_gene_set_dict[group] = gene_set

    return group_gene_set_dict
1088753
def Deserialize(self, reader):
        
        self.Script = reader.ReadVarBytes()
        self.ParameterList = reader.ReadVarBytes()
        self.ReturnType = reader.ReadByte()
1289300
def read(self, f):
        
        self.clear_document()

        g = Graph()
        g.parse(f, format='xml')

        for n in g.namespaces():
            ns = n[1].toPython()
            if not ns.endswith(('#', '/', ':')):
                ns = ns + '/'
            self._namespaces[n[0]] = ns
            # Extend the existing namespaces available
            XML_NS[n[0]] = ns

        self._read_sequences(g)
        self._read_component_definitions(g)
        self._extend_component_definitions(g)
        self._read_models(g)
        self._read_module_definitions(g)
        self._extend_module_definitions(g)
        self._read_annotations(g)
        # Last as this needs all other top level objects created
        self._read_collections(g)
253809
def file_chunks(self, fp):
        
        fsize = utils.file_size(fp)
        offset = 0
        if hasattr(fp, 'readinto'):
            while offset < fsize:
                nb = fp.readinto(self._internal)
                yield self.buf[:nb]
                offset += nb
        else:
            while offset < fsize:
                nb = min(self.chunk_size, fsize - offset)
                yield fp.read(nb)
                offset += nb
808386
def read(cls, proto):
    
    regionImpl = proto.regionImpl.as_struct(cls.getSchema())
    return cls.readFromProto(regionImpl)
445455
def read_fmt(fmt, fp):
    
    fmt = str(">" + fmt)
    fmt_size = struct.calcsize(fmt)
    data = fp.read(fmt_size)
    assert len(data) == fmt_size, 'read=%d, expected=%d' % (
        len(data), fmt_size
    )
    return struct.unpack(fmt, data)
450952
def load(self, fpath):
        
        def is_microscopy_item(fpath):
            """Return True if the fpath is likely to be microscopy data.

            :param fpath: file path to image
            :returns: :class:`bool`
            """
            l = fpath.split('.')
            ext = l[-1]
            pre_ext = l[-2]
            if ( (ext == 'tif' or ext == 'tiff')
                and pre_ext != 'ome' ):
                return False
            return True

        if not self.convert.already_converted(fpath):
            path_to_manifest = self.convert(fpath)
        else:
            path_to_manifest = os.path.join(self.backend.directory,
                                            os.path.basename(fpath),
                                            'manifest.json')

        
        collection = None
        if is_microscopy_item(fpath):
            collection = MicroscopyCollection()
        else:
            collection = ImageCollection()
        collection.parse_manifest(path_to_manifest)
        self.append(collection)

        return collection
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
142391
def readFd(fd, URL, encoding, options):
    
    ret = libxml2mod.xmlReadFd(fd, URL, encoding, options)
    if ret is None:raise treeError('xmlReadFd() failed')
    return xmlDoc(_obj=ret)
1290038
def dump(obj, fp, **kwargs):
    
    return json.dump(obj, fp, cls=BioCJSONEncoder, **kwargs)
573615
def load(fp):
    '''
    
    '''
    reader = reading.Reader(fp)
    keys = reader.fields
    columns = {k: [] for k in keys}
    for row in reader:
        for key, value in zip(keys, row):
            columns[key].append(value)
    return columns
1135553
def _read_dict(self, f):
        
        d = {}
        for k, item in f.items():
            if type(item) == h5py._hl.dataset.Dataset:
                v = item.value
                if type(v) == np.string_:
                    v = str(v)
                if type(v) == str and v == "NONE":
                    d[k] = None
                elif type(v) == str and v == "EMPTYARR":
                    d[k] = np.array([])
                elif isinstance(v, bytes):
                    d[k] = v.decode('utf-8')
                else:
                    d[k] = v

            elif k[:5] == "DICT_":
                d[k[5:]] = self._read_dict(item)
            elif k[:5] == "LIST_":
                tmpD = self._read_dict(item)
                d[k[5:]] = [tmpD[str(i)] for i in range(len(tmpD))]
        return d