Пример #1
0
    def children(self, **kwargs):

        attr_id = kwargs.get("attr_id", self.id(**kwargs))
        my_prefix = attr_id[:3]
        requested_prefix = kwargs.get("prefix", False)

        if kwargs.get("dataset",
                      False) == "chr" and my_prefix not in ["010", "040"]:
            attr_id = self.parents()[1]["id"]
            my_prefix = "040"

        if requested_prefix and "children" in SUMLEVELS["geo"][my_prefix]:
            if my_prefix in ("310", "160"):
                return attr_id
            requested_prefix = SUMLEVELS["geo"][my_prefix][
                "children"] if requested_prefix == "True" or requested_prefix is True else requested_prefix
            return "^{}".format(attr_id.replace(my_prefix, requested_prefix))
        if "children" in SUMLEVELS["geo"][my_prefix]:
            sumlevel = SUMLEVELS["geo"][my_prefix]["children"]
        else:
            sumlevel = False

        children = get_children(attr_id, self.attr_type, sumlevel)

        return u",".join([c["id"] for c in children])
Пример #2
0
    def children(self, **kwargs):

        attr_id = kwargs.get("attr_id", self.id(**kwargs))
        my_prefix = attr_id[:3]
        requested_prefix = kwargs.get("prefix", False)

        if kwargs.get("dataset", False) == "chr" and my_prefix not in ["010", "040"]:
            attr_id = self.parents()[1]["id"]
            my_prefix = "040"

        if requested_prefix and "children" in SUMLEVELS["geo"][my_prefix]:
            if my_prefix in ("310", "160"):
                return attr_id
            requested_prefix = (
                SUMLEVELS["geo"][my_prefix]["children"]
                if requested_prefix == "True" or requested_prefix is True
                else requested_prefix
            )
            return "^{}".format(attr_id.replace(my_prefix, requested_prefix))
        if "children" in SUMLEVELS["geo"][my_prefix]:
            sumlevel = SUMLEVELS["geo"][my_prefix]["children"]
        else:
            sumlevel = False

        children = get_children(attr_id, self.attr_type, sumlevel)

        return u",".join([c["id"] for c in children])
Пример #3
0
    def siblings(self, **kwargs):
        limit = kwargs.pop("limit", 5)
        # get immediate parents
        parent = get_parents(self.attr["id"], self.attr_type)
        parent = self.get_uniques(parent)
        parent = parent[-1]

        siblings = [c for c in get_children(parent["id"], self.attr_type, self.sumlevel()) if c['id'] != self.attr["id"]]
        siblings = siblings[:limit+1]

        return self.make_links(siblings)
Пример #4
0
    def siblings(self, **kwargs):
        limit = kwargs.pop("limit", 5)
        # get immediate parents
        parent = get_parents(self.attr["id"], self.attr_type)
        parent = self.get_uniques(parent)
        parent = parent[-1]

        siblings = [c for c in get_children(parent["id"], self.attr_type, self.sumlevel()) if c['id'] != self.attr["id"]]
        siblings = siblings[:limit+1]

        return self.make_links(siblings)