This method mapps traits from/to ...

        Triples created:

        :param limit:
        :return:
549012
def _process_trait_mappings(self, raw, limit=None):
        
        if self.test_mode:
            graph = self.testgraph
        else:
            graph = self.graph
        line_counter = 0
        model = Model(graph)

        with open(raw, 'r') as csvfile:
            filereader = csv.reader(csvfile, delimiter=',', quotechar='\"')
            next(filereader, None)  # skip header line
            for row in filereader:
                line_counter += 1
                # need to skip the last line
                if len(row) < 8:
                    LOG.info("skipping line %d: %s", line_counter, '\t'.join(row))
                    continue
                (vto_id, pto_id, cmo_id, ato_column, species, trait_class,
                 trait_type, qtl_count) = row

                ato_id = re.sub(
                    r'ATO #', 'AQTLTrait:', re.sub(
                        r'\].*', '', re.sub(r'\[', '', ato_column)))
                ato_id = ato_id.strip()

                ato_label = re.sub(r'.*\]\s*', '', ato_column)

                model.addClassToGraph(ato_id, ato_label.strip())

                if re.match(r'VT:.*', vto_id):
                    model.addClassToGraph(vto_id, None)
                    model.addEquivalentClass(ato_id, vto_id)
                if re.match(r'LPT:.*', pto_id):
                    model.addClassToGraph(pto_id, None)
                    model.addXref(ato_id, pto_id)
                if re.match(r'CMO:.*', cmo_id):
                    model.addClassToGraph(cmo_id, None)
                    model.addXref(ato_id, cmo_id)

        LOG.info("Done with trait mappings")
        return
525780
def compile(self):
        
        params = self.column_params + self.join_params + self.params
        if self.limit and self.limit >= 0:
            self.sql_limit = 'LIMIT ?'
            params += [self.limit]
        return (self.sql, params, self.keys)
209810
def _get_triplet_value_list(self, graph, identity, rdf_type):
        
        values = []
        for elem in graph.objects(identity, rdf_type):
            values.append(elem.toPython())
        return values
516742
def hydrate(cls, db, limit):
        

        # Extract the limit name from the keyword arguments
        cls_name = limit.pop('limit_class')

        # Is it in the registry yet?
        if cls_name not in cls._registry:
            utils.find_entrypoint(None, cls_name)

        # Look it up in the registry
        cls = cls._registry.get(cls_name)

        # Instantiate the thing
        return cls(db, **limit) if cls else None
239150
def getLimits(locations, current, sortResults=True, verbose=False):
    
    limit = {}
    for l in locations:
        a, b = current.common(l)
        if a is None:
            continue
        for name, value in b.items():
            f = a[name]
            if name not in limit:
                limit[name] = {}
                limit[name]['<'] = {}
                limit[name]['='] = {}
                limit[name]['>'] = {}
                if f > 0:
                    limit[name]['>'] = {0: [Location()]}
                elif f<0:
                    limit[name]['<'] = {0: [Location()]}
                else:
                    limit[name]['='] = {0: [Location()]}
            if current[name] < value - _EPSILON:
                if value not in limit[name]["<"]:
                    limit[name]["<"][value] = []
                limit[name]["<"][value].append(l)
            elif current[name] > value + _EPSILON:
                if value not in limit[name][">"]:
                    limit[name][">"][value] = []
                limit[name][">"][value].append(l)
            else:
                if value not in limit[name]["="]:
                    limit[name]["="][value] = []
                limit[name]["="][value].append(l)
    if not sortResults:
        return limit
    # now we have all the data, let's sort to the relevant values
    l = {}
    for name, lims in  limit.items():
        less = []
        more = []
        if lims[">"].keys():
            less = sorted(lims[">"].keys())
            lim_min = less[-1]
        else:
            lim_min = None
        if lims["<"].keys():
            more = sorted(lims["<"].keys())
            lim_max = more[0]
        else:
            lim_max = None
        if lim_min is None and lim_max is not None:
            # extrapolation < min
            if len(limit[name]['='])>0:
                l[name] = (None, list(limit[name]['='].keys())[0], None)
            elif len(more) > 1 and len(limit[name]['='])==0:
                # extrapolation
                l[name] = (None,  more[0], more[1])
        elif lim_min is not None and lim_max is None:
            # extrapolation < max
            if len(limit[name]['='])>0:
                # less > 0, M > 0, more = None
                # -> end of a limit
                l[name] = (None, limit[name]['='], None)
            elif len(less) > 1 and len(limit[name]['='])==0:
                # less > 0, M = None, more = None
                # extrapolation
                l[name] = (less[-2], less[-1], None)
        else:
            if len(limit[name]['=']) > 0:
                l[name] = (None, list(limit[name]['='].keys())[0], None)
            else:
                l[name] = (lim_min,  None, lim_max)
    return l
685366
def _process_feature_dbxref(self, limit):
        
        if self.test_mode:
            graph = self.testgraph
        else:
            graph = self.graph
        model = Model(graph)
        line_counter = 0
        raw = '/'.join((self.rawdir, 'feature_dbxref'))
        LOG.info("processing feature_dbxref mappings")
        with open(raw, 'r') as f:
            f.readline()  # read the header row; skip
            filereader = csv.reader(f, delimiter='\t', quotechar='\"')
            for line in filereader:

                (feature_dbxref_id, feature_id, dbxref_id, is_current) = line

                # 431890	3091292	596211	t
                # 2	9	55044	t
                # 3	9	55045	t
                # 437595	4551668	277309	t
                # 437596	4551662	277307	t

                if is_current == 'f':
                    # not sure what to do with it?
                    continue

                feature_key = feature_id

                if self.test_mode and int(feature_key) not in \
                        self.test_keys['gene'] + self.test_keys['allele']:
                    continue

                if feature_key not in self.idhash['feature']:
                    # some features may not be found in the hash
                    # if they are "analysis features"
                    # LOG.debug("Feature %s not found in hash", feature_key)
                    continue
                feature_id = self.idhash['feature'][feature_key]
                dbxref_key = dbxref_id
                dbxrefs = self.dbxrefs.get(dbxref_key)

                if dbxrefs is not None:
                    for d in dbxrefs:
                        # need to filter based on db ?
                        # TODO make other species' identifiers primary??
                        # instead of flybase?
                        did = dbxrefs.get(d)
                        if did.endswith('&class=protein'):
                            did = did[0:len(dbxrefs)-15]
                        # don't make something sameAs itself
                        if did == feature_id:
                            continue
                        dlabel = self.label_hash.get(did)
                        if re.search(r'FB(gn|og)', feature_id):
                            # only want to add equivalences for fly things
                            if not re.match(r'OMIM', did):
                                # these are only omim diseases, not genes;
                                # we shouldn't be adding these here anyway
                                # model.addClassToGraph(did, dlabel)
                                # model.addXref(feature_id, did)
                                pass  # True  # that
                        elif did is not None and dlabel is not None \
                                and feature_id is not None:
                            model.addIndividualToGraph(did, dlabel)
                            model.addXref(feature_id, did)
                        line_counter += 1

                if not self.test_mode \
                        and limit is not None and line_counter > limit:
                    break

                # FIXME - some flybase genes are xrefed to OMIM diseases!!!!!!
                # for example,
                # FBog0000375495 xref to omim 601181 (gene)
                # and 608033 (phenotype)

        return
1257884
def adjust_container_limits_for_variadic_sequences(headerDir, containers, maxElements):
    """"""
    for container in containers:
        headerFile = os.path.join( headerDir, "limits", container + ".hpp" )
        regexMatch   = r'(define\s+BOOST_MPL_LIMIT_' + container.upper() + r'_SIZE\s+)[0-9]+'
        regexReplace = r'\g<1>' + re.escape( str(maxElements) )
        for line in fileinput.input( headerFile, inplace=1, mode="rU" ):
            line = re.sub(regexMatch, regexReplace, line.rstrip())
            print(line)
1026594
def iter_work_specs(self, limit=None, start=None):
        '''
        
        '''
        count = 0
        ws_list, start = self.list_work_specs(limit, start)
        while True:
            for name_spec in ws_list:
                yield name_spec[1]
                count += 1
                if (limit is not None) and (count >= limit):
                    break
            if not start:
                break
            if limit is not None:
                limit -= count
            ws_list, start = self.list_work_specs(limit, start)
1367826
public boolean validateTriplet(Triplet triplet, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(triplet, diagnostics, context);
	}
445920
def expand
      unless @expanded
        resources.values.each(&:apply_resource_type)
        resources.values.each(&:apply_traits)
        inline_reference SchemaReference, schemas, @children
        @expanded = true
      end
    end
261913
def add_limit(self, label='0_0', **props):
        

        if label not in self.leaf_labels:
            raise ValueError('No model node named {} (must be in {}). Maybe define models first?'.format(label, self.leaf_labels))
        for k,v in props.items():
            if k not in self.spec_props:
                raise ValueError('Illegal property {} (only {} allowed).'.format(k, self.spec_props))
            if len(v) != 2:
                raise ValueError('Must provide (min, max) for {}. (`None` is allowed value)'.format(k))

        if label not in self.limits:
            self.limits[label] = {}

        for k,v in props.items():
            vmin, vmax = v
            if vmin is None:
                vmin = -np.inf
            if vmax is None:
                vmax = np.inf
            self.limits[label][k] = (vmin, vmax)

        self._clear_cache()
1007005
def limit options = {}
      # Remove this key if we come from limit_page method.
      page = options.delete :page
      query = options.dup
      collection = new_collection scoped_query( options = {
        :limit => options[:limit],
        :offset => options[:offset],
        :order => [options[:order]]
      }.merge( query ) )
      options.merge! :count => calculate_total_records( query ), :page => page
      collection.paginator = DataMapper::Paginator::Main.new options
      collection
    end
314618
def get_templates(self, limit=100, offset=0):
        
        url = self.TEMPLATES_URL + "?limit=%s&offset=%s" % (limit, offset)

        connection = Connection(self.token)

        connection.set_url(self.production, url)

        return connection.get_request()
446902
def _process_pubs(self, limit):
        
        if self.test_mode:
            graph = self.testgraph
        else:
            graph = self.graph
        model = Model(graph)
        line_counter = 0

        raw = '/'.join((self.rawdir, 'pub'))
        LOG.info("building labels for pubs")
        with open(raw, 'r') as f:
            f.readline()  # read the header row; skip
            filereader = csv.reader(f, delimiter='\t', quotechar='\"')
            for line in filereader:
                (pub_id, title, volumetitle, volume, series_name, issue, pyear,
                 pages, miniref, type_id, is_obsolete, publisher, pubplace,
                 uniquename) = line
# 2       12153979        1       2       FBst0000002     w[*]; betaTub60D[2] Kr[If-1]/CyO        10670
                # if self.test_mode is True:
                #     if int(object_key) not in self.test_keys.get('genotype'):
                #         continue

                pub_num = pub_id
                pub_id = 'FlyBase:'+uniquename.strip()
                self.idhash['publication'][pub_num] = pub_id

                # TODO figure out the type of pub by type_id
                if not re.match(r'(FBrf|multi)', uniquename):
                    continue
                line_counter += 1

                reference = Reference(graph, pub_id)
                if title != '':
                    reference.setTitle(title)
                if pyear != '':
                    reference.setYear(str(pyear))
                if miniref != '':
                    reference.setShortCitation(miniref)

                if not self.test_mode and limit is not None and line_counter > limit:
                    pass
                else:
                    if self.test_mode and int(pub_num) not in self.test_keys['pub']:
                        continue

                    if is_obsolete == 't':
                        model.addDeprecatedIndividual(pub_id)
                    else:
                        reference.addRefToGraph()
        return
1296323
def check_limit(self, limit):
        
        if limit > 0:
            self.limit = limit
        else:
            raise ValueError("Rule limit must be strictly > 0 ({0} given)"
                             .format(limit))

        return self
251733
function traits() {
    for (var _len = arguments.length, traitList = Array(_len), _key = 0; _key < _len; _key++) {
        traitList[_key] = arguments[_key];
    }

    return function (target) {
        traitList.forEach(function (trait) {
            _addTrait.call(target, trait);
        });
    };
}
172556
def es_mapping(cls, base_class, **kwargs):
        

        es_map = {}
        ranges = cls.rdfs_range # pylint: disable=no-member
        rng_defs = get_prop_range_defs(cls.class_names, cls.kds_rangeDef)
        rng_def = get_prop_range_def(rng_defs)
        if rng_def.get("kds_esIndexClass"):
            ranges = rng_def['kds_esIndexClass'].copy()
        # pdb.set_trace()
        # if cls._prop_name == "bf_partOf":
        #     pdb.set_trace()
        idx_types = get_idx_types(rng_def, ranges)
        if 'es_Ignored' in idx_types:
            return {'type': 'text',
                    'index': es_idx_types['es_NotIndexed']}
        if 'es_Nested' in idx_types:
            if (kwargs.get('depth', 0) >= 1 and \
                    kwargs.get('class') == ranges[0]) or \
                    kwargs.get('depth', 0) > 2:
                return {"type" : "keyword"}
            nested_map = getattr(MODULE.rdfclass,
                                 ranges[0]).es_mapping(base_class,
                                                       'es_Nested',
                                                       **kwargs)
            es_map['properties'] = nested_map
            es_map['type'] = "nested"
        elif len(idx_types) > 1:
            fields = {}
            for idx in idx_types:
                fields.update(es_idx_types[idx])
            es_map['fields'] = fields
        elif len(idx_types) == 1:
            if cls._prop_name == 'rdf_type': # pylint: disable=no-member
                es_map['type'] = 'keyword'
            elif idx_types[0] == 'es_NotIndexed':
                es_map['index'] = False
            else:
                es_map['type'] = es_idx_types[idx_types[0]]
        try:
            if not es_map.get('type'):
                fld_type = BaseRdfDataType[ranges[0]].es_type
                es_map['type'] = fld_type
                if cls._prop_name == 'rdf_type':
                    es_map['type'] = 'keyword'
        except (KeyError, AttributeError):
            if cls._prop_name == 'rdf_type': # pylint: disable=no-member
                es_map['type'] = 'keyword'
            else:
                es_map['type'] = 'text'
        if es_map['type'] == "nested":
            del es_map['type']
        try:
            fld_format = BaseRdfDataType[ranges[0]].es_format
            es_map['format'] = fld_format
        except (KeyError, AttributeError):
            pass
        return es_map