%prog parents gffile models.ids

    Find the parents given a list of IDs in "models.ids".
163942
def parents(args):
    
    p = OptionParser(parents.__doc__)

    opts, args = p.parse_args(args)

    if len(args) != 2:
        sys.exit(not p.print_help())

    gff_file, idsfile = args
    g = make_index(gff_file)
    fp = open(idsfile)
    for row in fp:
        cid = row.strip()
        b = next(g.parents(cid, 1))
        print("\t".join((cid, b.id)))
654894
def parents(self, id, level=None, featuretype=None, order_by=None,
                reverse=False, completely_within=False, limit=None):
        
        return self._relation(
            id, join_on='parent', join_to='child', level=level,
            featuretype=featuretype, order_by=order_by, reverse=reverse,
            limit=limit, completely_within=completely_within)
305922
def get_parents_for(self, child_ids):
        
        self._cache_init()
        parent_candidates = []
        for parent, children in self._cache_get_entry(self.CACHE_NAME_PARENTS).items():
            if set(children).intersection(child_ids):
                parent_candidates.append(parent)
        return set(parent_candidates)
816347
def find_parents(name, parents=None):
    
    template = loader.get_template(name)
    source, origin = find_template_source(name)
    if parents is None:
        parents = []
    else:
        parents.append({'name': name, 'file': origin})
    for node in template:
        if isinstance(node, ExtendsNode):
            parent_name = node.parent_name.token.strip('"')
            return find_parents(parent_name, parents)
    return parents
1357242
def get_models(args):
    
    if args:
        models = []
        for arg in args:
            match_found = False
            for model in registry.get_models():
                if model._meta.app_label == arg:
                    models.append(model)
                    match_found = True
                elif '%s.%s' % (model._meta.app_label, model._meta.model_name) == arg:
                    models.append(model)
                    match_found = True

            if not match_found:
                raise ValueError("No model or app named %s" % arg)
    else:
        models = registry.get_models()

    return set(models)
957812
def parents(self):
        
        if self._parents is None:
            bottomups = tuple(Relationship.bottomup())

            self._parents = TermList()
            self._parents.extend(
                [ other
                    for rship,others in six.iteritems(self.relations)
                        for other in others
                            if rship in bottomups
                ]

            )

        return self._parents
163604
def handle_parent(repo, **kwargs):
    """"""
    log.info('parent: %s %s' %(repo, kwargs))
    _parent = repo.parent()
    if _parent:
        return [_parent.serialize()]
445497
def get_children(parent, idx):
  """"""
  if isinstance(parent, dict):
    if idx in parent:
      yield parent[idx]
    else:
      raise JSONPathError("Invalid path at {0}".format(idx))

  elif isinstance(parent, list):
    if idx == "*":
      yield from parent
    else:
      is_int, i = try_parse_int(idx)

      if is_int and i >= 0 and i < len(parent):
        yield parent[i]
      else:
        raise JSONPathError("Invalid list index: {0}".format(i))

  else:
    raise JSONPathError("Type {0} does not have children".format(type(parent).__name__))
47956
def _get_parents_from_parts(kwargs):
    
    parent_builder = []
    if kwargs['last_child_num'] is not None:
        parent_builder.append('{type}/{name}/'.format(**kwargs))
        for index in range(1, kwargs['last_child_num']):
            child_namespace = kwargs.get('child_namespace_{}'.format(index))
            if child_namespace is not None:
                parent_builder.append('providers/{}/'.format(child_namespace))
            kwargs['child_parent_{}'.format(index)] = ''.join(parent_builder)
            parent_builder.append(
                '{{child_type_{0}}}/{{child_name_{0}}}/'
                .format(index).format(**kwargs))
        child_namespace = kwargs.get('child_namespace_{}'.format(kwargs['last_child_num']))
        if child_namespace is not None:
            parent_builder.append('providers/{}/'.format(child_namespace))
        kwargs['child_parent_{}'.format(kwargs['last_child_num'])] = ''.join(parent_builder)
    kwargs['resource_parent'] = ''.join(parent_builder) if kwargs['name'] else None
    return kwargs
752097
def _find_parent_path_names(self):
        """"""
        parent, dot, me = self._name.rpartition('.')
        if dot == '':
            # This is a top-level module. sys.path contains the parent path.
            return 'sys', 'path'
        # Not a top-level module. parent-module.__path__ contains the
        #  parent path.
        return parent, '__path__'
262310
def parents(self) -> List["Collection"]:
        
        p = self.parent
        parents = []
        while p is not None:
            parents.append(p)
            p = p.parent
        return parents
670074
def _subgroup(group, *args, **kwargs):
    
    def decorator(f):
        f.required = kwargs.pop('required', True)
        if 'parents' in kwargs:
            if not hasattr(f, '_argnames'):  # pragma: no cover
                f._argnames = []
            for p in kwargs['parents']:
                f._argnames += p._argnames if hasattr(p, '_argnames') else []
            kwargs['parents'] = [p.parser for p in kwargs['parents']]
        if 'help' not in kwargs:
            kwargs['help'] = f.__doc__
        if args == ():
            f.parser = group._subparsers.add_parser(f.__name__, **kwargs)
        else:
            f.parser = group._subparsers.add_parser(*args, **kwargs)
        f.parser.set_defaults(**{'_func_' + group.__name__: f})
        f.climax = True
        for arg in getattr(f, '_arguments', []):
            f.parser.add_argument(*arg[0], **arg[1])
        f._subparsers = f.parser.add_subparsers()
        f.command = partial(_subcommand, f)
        f.group = partial(_subgroup, f)
        return f
    return decorator
535864
def _check_args(args):
    
    logger.info("Checking parameters and files")
    args.dir_out = args.out
    args.samplename = "pro"
    global decision_cluster
    global similar
    if not os.path.isdir(args.out):
        logger.warning("the output folder doens't exists")
        os.mkdirs(args.out)
    if args.bed and args.gtf:
        logger.error("cannot provide -b and -g at the same time")
        raise SyntaxError
    if args.debug:
        logger.info("DEBUG messages will be showed in file.")
    if args.bed:
        args.list_files = args.bed
        args.type_ann = "bed"
    if args.gtf:
        args.list_files = args.gtf
        args.type_ann = "gtf"
    logger.info("Output dir will be: %s" % args.dir_out)
    if not all([file_exists(args.ffile), file_exists(args.afile)]):
        logger.error("I/O error: Seqs.ma or Seqs.bam. ")
        raise IOError("Seqs.ma or/and Seqs.bam doesn't exists.")
    if hasattr(args, 'list_files'):
        beds = args.list_files.split(",")
        for filebed in beds:
            if not file_exists(filebed):
                logger.error("I/O error: {0}".format(filebed))
                raise IOError("%s  annotation files doesn't exist" % filebed)
    param.decision_cluster = args.method
    if args.similar:
        param.similar = float(args.similar)
    if args.min_seqs:
        param.min_seqs = int(args.min_seqs)
    return args
1119456
def get_parent_id(self):
        ''''''
        parent_id = parsers.get_parent_id(self.__chebi_id)
        return None if math.isnan(parent_id) else 'CHEBI:' + str(parent_id)
592226
def addparent(args):
    
    p = OptionParser(addparent.__doc__)
    p.add_option("--childfeat", default="CDS", help="Type of children feature")
    p.add_option("--parentfeat", default="mRNA", help="Type of merged feature")
    p.set_outfile()
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    gff_file, = args
    gff = Gff(gff_file)
    data = defaultdict(list)
    for g in gff:
        if g.type != opts.childfeat:
            continue
        data[g.parent].append(g)

    logging.debug("A total of {0} {1} features clustered".\
                    format(len(data), opts.childfeat))

    parents = []
    for parent, dd in data.items():
        d = dd[0]
        start, end = min(x.start for x in dd), max(x.end for x in dd)
        gffline = "\t".join(str(x) for x in \
                        (d.seqid, d.source, opts.parentfeat, start, end,
                         ".", d.strand, ".", "ID={0};Name={0}".format(parent)))
        parents.append(GffLine(gffline))
    parents.sort(key=lambda x: (x.seqid, x.start))
    logging.debug("Merged feature sorted")

    fw = must_open(opts.outfile, "w")
    for parent in parents:
        print(parent, file=fw)
        parent_id = parent.id
        for d in data[parent_id]:
            if d.accn == parent_id:
                new_id = "{0}.{1}1".format(parent_id, opts.childfeat)
                d.set_attr("ID", new_id)
                d.set_attr("Name", new_id, update=True)
            print(d, file=fw)
    fw.close()
566152
def execute(self, parents=None):
        
        results = OrderedDict()
        for row in self.query(parents=parents).execute(self.context.graph):
            data = {k: v.toPython() for (k, v) in row.asdict().items()}
            id = data.get(self.id)
            if id not in results:
                results[id] = self.base_object(data)

            for child in self.children:
                if child.id in data:
                    name = child.get_name(data)
                    value = data.get(child.id)
                    if child.node.many and \
                            child.node.op not in [OP_IN, OP_NIN]:
                        if name not in results[id]:
                            results[id][name] = [value]
                        else:
                            results[id][name].append(value)
                    else:
                        results[id][name] = value
        return results
168090
def get_parent_lookup_kwargs(parent_object):
    
    if parent_object is None:
        return dict(
            parent_type__isnull=True,
            parent_id=0
        )
    elif isinstance(parent_object, models.Model):
        return dict(
            parent_type=ContentType.objects.get_for_model(parent_object),
            parent_id=parent_object.pk
        )
    else:
        raise ValueError("parent_object is not a model!")