Filters request for phenotype search requests
961310
def _filterSearchPhenotypesRequest(self, request):
        
        filters = []
        if request.id:
            filters.append("?phenotype = <{}>".format(request.id))

        if request.description:
            filters.append(
                'regex(?phenotype_label, "{}")'.format(request.description))
        # OntologyTerms
        # TODO: refactor this repetitive code
        if hasattr(request.type, 'id') and request.type.id:
            ontolgytermsClause = self._formatOntologyTermObject(
                request.type, 'phenotype')
            if ontolgytermsClause:
                filters.append(ontolgytermsClause)
        if len(request.qualifiers) > 0:
            ontolgytermsClause = self._formatOntologyTermObject(
                request.qualifiers, 'phenotype_quality')
            if ontolgytermsClause:
                filters.append(ontolgytermsClause)
        if hasattr(request.age_of_onset, 'id') and request.age_of_onset.id:
            ontolgytermsClause = self._formatOntologyTermObject(
                request.age_of_onset, 'phenotype_quality')
            if ontolgytermsClause:
                filters.append(ontolgytermsClause)
        return filters
728395
def search_queryset(self):
        """"""
        queryset = self.get_model_class().objects.get_queryset()

        if self.get_model_config().list_select_related:
            queryset = queryset.select_related(*self.get_model_config().list_select_related)

        return watson.filter(queryset, self.get_search(), ranking=False)
276216
def search(self, filters):
        
        records = self.__model__.search(self.__five9__, filters)
        return self.__class__(
            self.__five9__, self.__model__, records,
        )
841573
def filter(self, table, vg_snapshots, filter_string):
        """"""
        query = filter_string.lower()
        return [vg_snapshot for vg_snapshot in vg_snapshots
                if query in vg_snapshot.name.lower()]
1321978
def variant_filtration(call_file, ref_file, vrn_files, data, items):
    
    caller = data["config"]["algorithm"].get("variantcaller")
    if "gvcf" not in dd.get_tools_on(data):
        call_file = ploidy.filter_vcf_by_sex(call_file, items)
    if caller in ["freebayes"]:
        return vfilter.freebayes(call_file, ref_file, vrn_files, data)
    elif caller in ["platypus"]:
        return vfilter.platypus(call_file, data)
    elif caller in ["samtools"]:
        return vfilter.samtools(call_file, data)
    elif caller in ["gatk", "gatk-haplotype", "haplotyper"]:
        if dd.get_analysis(data).lower().find("rna-seq") >= 0:
            from bcbio.rnaseq import variation as rnaseq_variation
            return rnaseq_variation.gatk_filter_rnaseq(call_file, data)
        else:
            return gatkfilter.run(call_file, ref_file, vrn_files, data)
    # no additional filtration for callers that filter as part of call process
    else:
        return call_file
253332
def genotypesPhenotypesGenerator(self, request):
        
        # TODO make paging work using SPARQL?
        compoundId = datamodel.PhenotypeAssociationSetCompoundId.parse(
            request.phenotype_association_set_id)
        dataset = self.getDataRepository().getDataset(compoundId.dataset_id)
        phenotypeAssociationSet = dataset.getPhenotypeAssociationSet(
            compoundId.phenotypeAssociationSetId)
        featureSets = dataset.getFeatureSets()
        annotationList = phenotypeAssociationSet.getAssociations(
            request, featureSets)
        return self._protocolListGenerator(request, annotationList)
793683
def search_tags_as_filters(tags):
    """"""
    # set dicts
    actions = {}
    contacts = {}
    formats = {}
    inspire = {}
    keywords = {}
    licenses = {}
    md_types = dict()
    owners = defaultdict(str)
    srs = {}
    unused = {}
    # 0/1 values
    compliance = 0
    type_dataset = 0
    # parsing tags
    print(len(tags.keys()))
    i = 0
    for tag in sorted(tags.keys()):
        i += 1
        # actions
        if tag.startswith("action"):
            actions[tags.get(tag, tag)] = tag
            continue
        # compliance INSPIRE
        elif tag.startswith("conformity"):
            compliance = 1
            continue
        # contacts
        elif tag.startswith("contact"):
            contacts[tags.get(tag)] = tag
            continue
        # formats
        elif tag.startswith("format"):
            formats[tags.get(tag)] = tag
            continue
        # INSPIRE themes
        elif tag.startswith("keyword:inspire"):
            inspire[tags.get(tag)] = tag
            continue
        # keywords
        elif tag.startswith("keyword:isogeo"):
            keywords[tags.get(tag)] = tag
            continue
        # licenses
        elif tag.startswith("license"):
            licenses[tags.get(tag)] = tag
            continue
        # owners
        elif tag.startswith("owner"):
            owners[tags.get(tag)] = tag
            continue
        # SRS
        elif tag.startswith("coordinate-system"):
            srs[tags.get(tag)] = tag
            continue
        # types
        elif tag.startswith("type"):
            md_types[tags.get(tag)] = tag
            if tag in ("type:vector-dataset", "type:raster-dataset"):
                type_dataset += 1
            else:
                pass
            continue
        # ignored tags
        else:
            unused[tags.get(tag)] = tag
            continue

    # override API tags to allow all datasets filter - see #
    if type_dataset == 2:
        md_types["Donnée"] = "type:dataset"
    else:
        pass
    # printing
    # print("There are:"
    #       "\n{} actions"
    #       "\n{} contacts"
    #       "\n{} formats"
    #       "\n{} INSPIRE themes"
    #       "\n{} keywords"
    #       "\n{} licenses"
    #       "\n{} owners"
    #       "\n{} SRS"
    #       "\n{} types"
    #       "\n{} unused".format(len(actions),
    #                            len(contacts),
    #                            len(formats),
    #                            len(inspire),
    #                            len(keywords),
    #                            len(licenses),
    #                            len(owners),
    #                            len(srs),
    #                            len(md_types),
    #                            len(unused)
    #                            ))
    # storing dicts
    tags_parsed = {
        "actions": actions,
        "compliance": compliance,
        "contacts": contacts,
        "formats": formats,
        "inspire": inspire,
        "keywords": keywords,
        "licenses": licenses,
        "owners": owners,
        "srs": srs,
        "types": md_types,
        "unused": unused,
    }

    # method ending
    return tags_parsed
718695
function requestFilter() {
  return function(req, res, next) {
    if (!_isJsonRequest(req) && !_isVoidFilterRoute(req)) {
      return _renderAppShell(res);
    }
    next();
  };
}
294019
def filter_by(self, types=(), units=()):
        """"""
        if not (isinstance(types, Sequence) and isinstance(units, Sequence)):
            raise TypeError('types/units must be a sequence')
        empty = frozenset()

        if types:
            type_names = set()
            for type_ in types:
                type_names |= self.by_type.get(type_, empty)
            if not units:
                return type_names

        if units:
            unit_names = set()
            for unit in units:
                unit_names |= self.by_unit.get(unit, empty)
            if not types:
                return unit_names

        return (type_names & unit_names) if (types and units) else empty
179690
def _filterSearchFeaturesRequest(self, reference_name, gene_symbol, name,
                                     start, end):
        
        filters = []
        query = self._baseQuery()
        filters = []
        location = self._findLocation(reference_name, start, end)
        if location:
            filters.append("?feature = <{}>".format(location))
        if gene_symbol:
            filters.append('regex(?feature_label, "{}")')
        if name:
            filters.append(
                'regex(?feature_label, "{}")'.format(name))
        # apply filters
        filter = "FILTER ({})".format(' && '.join(filters))
        if len(filters) == 0:
            filter = ""
        query = query.replace("#%FILTER%", filter)
        return query
268561
def describe_filter(f):
    """"""
    if f.__class__ is logging.Filter:  # using type() breaks in Python <= 2.6
        return 'name=%r' % f.name
    return repr(f)
1324874
function filterParameters(request) {
    const data = Object.assign({}, config);
    Object.keys(request).forEach((key) => {
      data[key] = request[key];
    });

    return data;
  }
49152
def filter_keep_phenotype_entry_ids(self, entry):
        '''
            
        '''
        omim_id = str(entry['mimNumber'])
        otype = self.globaltt['obsolete']
        if omim_id in self.omim_type:
            otype = self.omim_type[omim_id]
            if otype == self.globaltt['obsolete'] and omim_id in self.omim_replaced:
                omim_id = self.omim_replaced[omim_id]
                otype = self.omim_type[omim_id]
            # else:  # removed or multiple

        if otype not in (
                self.globaltt['Phenotype'], self.globaltt['has_affected_feature']):
            omim_id = None
        return omim_id
1035424
def search(self, terms, prelim=True):
        """"""
        # TODO: There are now lots of additional data sources, make additional
        # searching optional (11/01/2017)
        if prelim:  # preliminary search
            res = self._resolve(terms, self.Id)
            self._write(res)
            return res
        else:  # search other DSs for alt names, search DS with these
            # quick fix: https://github.com/DomBennett/TaxonNamesResolver/issues/5
            # seems to be due to limit on number of ids in single request
            # switiching to a for loop for each data source
            # appending all results into single res
            res = []
            for ds_id in self.otherIds:
                tmp = self._resolve(terms, [ds_id])
                res.append(tmp[0])
            self._write(res)
            alt_terms = self._parseNames(res)
            if len(alt_terms) == 0:
                return False
            else:
                # search the main source again with alt_terms
                # replace names in json
                terms = [each[1] for each in alt_terms]  # unzip
                res = self._resolve(terms, self.Id)
                self._write(res)
                alt_res = self._replaceSupStrNames(res, alt_terms)
                return alt_res
1094913
function querySearch (query) {
      var results = query ? self.vegetables.filter(createFilterFor(query)) : [];
      return results;
    }
1037627
def _do_high_depth_filter(data):
    
    is_genome = tz.get_in(["config", "algorithm", "coverage_interval"], data, "").lower() == "genome"
    is_paired = vcfutils.get_paired_phenotype(data)
    return is_genome and not is_paired
430909
def _query_filter(search, urlkwargs, definitions):
    """"""
    filters, urlkwargs = _create_filter_dsl(urlkwargs, definitions)

    for filter_ in filters:
        search = search.filter(filter_)

    return (search, urlkwargs)