def order(self, meta=None, meta_ascending=None, meta_top=None, meta_k=None,
              regs=None, regs_ascending=None, region_top=None, region_k=None):
        """
        *Wrapper of* ``ORDER``

        The ORDER operator is used to order either samples, sample regions, or both,
        in a dataset according to a set of metadata and/or region attributes, and/or 
        region coordinates. The number of samples and their regions in the output dataset 
        is as in the input dataset, as well as their metadata and region attributes 
        and values, but a new ordering metadata and/or region attribute is added with 
        the sample or region ordering value, respectively. 
        
        :param meta: list of metadata attributes
        :param meta_ascending: list of boolean values (True = ascending, False = descending)
        :param meta_top: "top", "topq" or "topp" or None
        :param meta_k: a number specifying how many results to be retained
        :param regs: list of region attributes
        :param regs_ascending: list of boolean values (True = ascending, False = descending)
        :param region_top: "top", "topq" or "topp" or None
        :param region_k: a number specifying how many results to be retained
        :return: a new GMQLDataset


        Example of usage. We order Example_Dataset_1 metadata by ascending `antibody` and descending `antibody_class`
        keeping only the first sample. We also order the resulting regions based on the `score` field in descending
        order, keeping only the first one also in this case::

            import gmql as gl

            d1 = gl.get_example_dataset("Example_Dataset_1")

            result = d1.order(meta=["antibody", "antibody_targetClass"],
                              meta_ascending=[True, False], meta_top="top", meta_k=1,
                              regs=['score'], regs_ascending=[False],
                              region_top="top", region_k=1)
        """
        meta_exists = False
        meta_len = 0
        if isinstance(meta, list) and \
            all([isinstance(x, str) for x in meta]):
            meta_exists = True
            meta_len = len(meta)
            meta = Some(meta)
        elif meta is None:
            meta = none()
        else:
            raise TypeError("meta must be a list of strings. "
                            "{} was provided".format(type(meta)))

        if isinstance(meta_ascending, list) and \
            all([isinstance(x, bool) for x in meta_ascending]) and \
            meta_exists and meta_len == len(meta_ascending):
            meta_ascending = Some(meta_ascending)
        elif meta_ascending is None:
            if meta_exists:
                # by default meta_ascending is all True
                meta_ascending = Some([True for _ in range(meta_len)])
            else:
                meta_ascending = none()
        else:
            raise TypeError("meta ascending must be a list of booleans having the same size "
                            "of meta. {} was provided".format(type(meta_ascending)))

        regs_exists = False
        regs_len = 0
        if isinstance(regs, list) and \
                all([isinstance(x, str) for x in regs]):
            regs_exists = True
            regs_len = len(regs)
            regs = Some(regs)
        elif regs is None:
            regs = none()
        else:
            raise TypeError("regs must be a list of strings. "
                            "{} was provided".format(type(regs)))

        if isinstance(regs_ascending, list) and \
            all([isinstance(x, bool) for x in regs_ascending]) and \
                regs_exists and regs_len == len(regs_ascending):
            regs_ascending = Some(regs_ascending)
        elif regs_ascending is None:
            if regs_exists:
                # by default regs_ascending is all True
                regs_ascending = Some([True for _ in range(regs_len)])
            else:
                regs_ascending = none()
        else:
            raise TypeError("meta regs_ascending must be a list of booleans having the same size "
                            "of regs. {} was provided".format(type(regs_ascending)))

        meta_top_exists = False
        if isinstance(meta_top, str):
            if meta_exists:
                meta_top = Some(meta_top)
                meta_top_exists = True
            else:
                raise ValueError("meta_top must be defined only when meta is defined")
        elif meta_top is None:
            meta_top = none()
        else:
            raise TypeError("meta_top must be a string. {} was provided".format(type(meta_top)))

        if isinstance(meta_k, int) and \
                meta_top_exists:
            meta_k = Some(meta_k)
        elif meta_k is None and \
                not meta_top_exists:
            meta_k = none()
        else:
            raise TypeError("meta_k must be an integer and should be provided together with a "
                            "value of meta_top. {} was provided".format(type(meta_k)))

        region_top_exists = False
        if isinstance(region_top, str):
            if regs_exists:
                region_top = Some(region_top)
                region_top_exists = True
            else:
                raise ValueError("region_top must be defined only when regs is defined")
        elif region_top is None:
            region_top = none()
        else:
            raise TypeError("region_top must be a string. {} was provided".format(type(region_top)))

        if isinstance(region_k, int) and \
                region_top_exists:
            region_k = Some(region_k)
        elif region_k is None and \
                not region_top_exists:
            region_k = none()
        else:
            raise TypeError("region_k must be an integer and should be provided together with a "
                            "value of region_top. {} was provided".format(type(region_k)))

        new_index = self.opmng.order(self.__index, meta, meta_ascending, meta_top, meta_k,
                                     regs, regs_ascending, region_top, region_k)
        return GMQLDataset(index=new_index, location=self.location,
                           local_sources=self._local_sources,
                           remote_sources=self._remote_sources,
                           meta_profile=self.meta_profile)
def order ( self , meta = None , meta_ascending = None , meta_top = None , meta_k = None , regs = None , regs_ascending = None , region_top = None , region_k = None ) : meta_exists = False meta_len = 0 if isinstance ( meta , list ) and all ( [ isinstance ( x , str ) for x in meta ] ) : meta_exists = True meta_len = len ( meta ) meta = Some ( meta ) elif meta is None : meta = none ( ) else : raise TypeError ( "meta must be a list of strings. " "{} was provided" . format ( type ( meta ) ) ) if isinstance ( meta_ascending , list ) and all ( [ isinstance ( x , bool ) for x in meta_ascending ] ) and meta_exists and meta_len == len ( meta_ascending ) : meta_ascending = Some ( meta_ascending ) elif meta_ascending is None : if meta_exists : meta_ascending = Some ( [ True for _ in range ( meta_len ) ] ) else : meta_ascending = none ( ) else : raise TypeError ( "meta ascending must be a list of booleans having the same size " "of meta. {} was provided" . format ( type ( meta_ascending ) ) ) regs_exists = False regs_len = 0 if isinstance ( regs , list ) and all ( [ isinstance ( x , str ) for x in regs ] ) : regs_exists = True regs_len = len ( regs ) regs = Some ( regs ) elif regs is None : regs = none ( ) else : raise TypeError ( "regs must be a list of strings. " "{} was provided" . format ( type ( regs ) ) ) if isinstance ( regs_ascending , list ) and all ( [ isinstance ( x , bool ) for x in regs_ascending ] ) and regs_exists and regs_len == len ( regs_ascending ) : regs_ascending = Some ( regs_ascending ) elif regs_ascending is None : if regs_exists : regs_ascending = Some ( [ True for _ in range ( regs_len ) ] ) else : regs_ascending = none ( ) else : raise TypeError ( "meta regs_ascending must be a list of booleans having the same size " "of regs. {} was provided" . format ( type ( regs_ascending ) ) ) meta_top_exists = False if isinstance ( meta_top , str ) : if meta_exists : meta_top = Some ( meta_top ) meta_top_exists = True else : raise ValueError ( "meta_top must be defined only when meta is defined" ) elif meta_top is None : meta_top = none ( ) else : raise TypeError ( "meta_top must be a string. {} was provided" . format ( type ( meta_top ) ) ) if isinstance ( meta_k , int ) and meta_top_exists : meta_k = Some ( meta_k ) elif meta_k is None and not meta_top_exists : meta_k = none ( ) else : raise TypeError ( "meta_k must be an integer and should be provided together with a " "value of meta_top. {} was provided" . format ( type ( meta_k ) ) ) region_top_exists = False if isinstance ( region_top , str ) : if regs_exists : region_top = Some ( region_top ) region_top_exists = True else : raise ValueError ( "region_top must be defined only when regs is defined" ) elif region_top is None : region_top = none ( ) else : raise TypeError ( "region_top must be a string. {} was provided" . format ( type ( region_top ) ) ) if isinstance ( region_k , int ) and region_top_exists : region_k = Some ( region_k ) elif region_k is None and not region_top_exists : region_k = none ( ) else : raise TypeError ( "region_k must be an integer and should be provided together with a " "value of region_top. {} was provided" . format ( type ( region_k ) ) ) new_index = self . opmng . order ( self . __index , meta , meta_ascending , meta_top , meta_k , regs , regs_ascending , region_top , region_k ) return GMQLDataset ( index = new_index , location = self . location , local_sources = self . _local_sources , remote_sources = self . _remote_sources , meta_profile = self . meta_profile )
*Wrapper of* ``ORDER``

        The ORDER operator is used to order either samples, sample regions, or both,
        in a dataset according to a set of metadata and/or region attributes, and/or 
        region coordinates. The number of samples and their regions in the output dataset 
        is as in the input dataset, as well as their metadata and region attributes 
        and values, but a new ordering metadata and/or region attribute is added with 
        the sample or region ordering value, respectively. 
        
        :param meta: list of metadata attributes
        :param meta_ascending: list of boolean values (True = ascending, False = descending)
        :param meta_top: "top", "topq" or "topp" or None
        :param meta_k: a number specifying how many results to be retained
        :param regs: list of region attributes
        :param regs_ascending: list of boolean values (True = ascending, False = descending)
        :param region_top: "top", "topq" or "topp" or None
        :param region_k: a number specifying how many results to be retained
        :return: a new GMQLDataset


        Example of usage. We order Example_Dataset_1 metadata by ascending `antibody` and descending `antibody_class`
        keeping only the first sample. We also order the resulting regions based on the `score` field in descending
        order, keeping only the first one also in this case::

            import gmql as gl

            d1 = gl.get_example_dataset("Example_Dataset_1")

            result = d1.order(meta=["antibody", "antibody_targetClass"],
                              meta_ascending=[True, False], meta_top="top", meta_k=1,
                              regs=['score'], regs_ascending=[False],
                              region_top="top", region_k=1)