The queryset is filtered by measurements of animals which are part of that strain.
162861
def get_queryset(self):
        ''''''
        strain = get_object_or_404(Strain, Strain_slug=self.kwargs['strain_slug'])
        animals = Animal.objects.filter(Strain=strain)
        return Measurement.objects.filter(animal=animals)
535617
def queryset(self, request, queryset):
        
        if self.value() is not None:
            if self.value() > 0:
                return queryset.filter(parent_process_id=self.value())
54522
def get(self, request, *args, **kwargs):
        ''''''
        measurements = Measurement.objects.all()    
        return data_csv(self.request, measurements)
1116370
def get_context_data(self, **kwargs):
        """"""
        
        context = super(StrainList, self).get_context_data(**kwargs)
        context['strain_list_alive'] = Strain.objects.filter(animal__Alive=True).annotate(alive=Count('animal'))
        context['cages'] = Animal.objects.filter(Alive=True).values("Cage")        
        return context
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
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
474933
async def filter(self, request):
        """"""
        collection = self.collection
        self.filter_form.process(request.query)
        data = self.filter_form.data
        self.filter_form.active = any(o and o is not DEFAULT for o in data.values())
        for flt in self.columns_filters:
            try:
                collection = flt.apply(collection, data)
            # Invalid filter value
            except ValueError:
                continue
        return collection
288047
def search_datasets(self):
        
        request = protocol.SearchDatasetsRequest()
        request.page_size = pb.int(self._page_size)
        return self._run_search_request(
            request, "datasets", protocol.SearchDatasetsResponse)
1267406
def queryset(self, request, queryset):
        
        if self.value() is not None:
            return queryset.filter(information__type__pk=self.value())
        else:
            return queryset
730794
private BitSet parseQuery(FilterQuery filterQuery, DataSchema schema) {
        BitSet queryBitSet = new BitSet();
        if(filterQuery instanceof MatchAllQuery || filterQuery.getFilterQueries().size() < 1) return queryBitSet;

        //facet drill down happens here
        for (String filterField : filterQuery.getFilterQueries().keySet()) {

            final int columnIndex = schema.getColumnIndex(filterField);
            final Map<String, BitSet> map = fieldInvertedIndex.get(columnIndex);

            final FilterQuery.FilterQueryElement filterQueryElement = filterQuery.getFilterQueries().get(filterField);
            DataType type = schema.getType(columnIndex);
            switch (type) {
                case CoordinateLat:
                case CoordinateLon:
                case String:
                case Boolean:
                case Integer:
                    // if range query
                    if (filterQueryElement instanceof FilterQuery.FilterFieldRange) {
                        queryBitSet = processRangeQueryIntegerTypes(queryBitSet, map, filterQueryElement, type);
                    } else if (filterQueryElement instanceof FilterQuery.FilterFieldGreaterThanInteger) {
                        queryBitSet = processIntegerGreaterThanDefaultTypes(queryBitSet, map, filterQueryElement, type);
                    } else {
                        // does most of the commons multi value types
                        queryBitSet = processMultiValueQueryDefaultTypes(queryBitSet, map, filterQueryElement, type);
                    }
                    break;
                case Date:

                    if (filterQueryElement instanceof FilterQuery.FilterFieldRangeDate) {
                        queryBitSet = processRangeQueryISODateTypes(queryBitSet, map, filterQueryElement, type);
                    } else {
                        queryBitSet = processRangeQueryMultiValueQueryDateYear(queryBitSet, map, filterQueryElement, type);
                    }

                    break;
                case DateYear:
                    // if range query
                    if (filterQueryElement instanceof FilterQuery.FilterFieldRange) {
                        queryBitSet = processRangeQueryDateYearType(queryBitSet, map, filterQueryElement, type);
                    } else {
                        queryBitSet = processRangeQueryMultiValueQueryDateYear(queryBitSet, map, filterQueryElement, type);
                    }
                    break;
            }

        }
        return queryBitSet;
    }
464296
def get_queryset(self, request):
        ''' '''
        qs = super(SubmissionFileAdmin, self).get_queryset(request)
        if request.user.is_superuser:
            return qs
        else:
            return qs.filter(Q(submissions__assignment__course__tutors__pk=request.user.pk) | Q(submissions__assignment__course__owner=request.user)).distinct()
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
1156988
def reporter(self):
        
        # Initialise variables
        header = ''
        row = ''
        databasedict = dict()
        # Load the database sequence type into a dictionary
        strainprofile = os.path.join(self.profilelocation, 'strainprofiles.txt')
        databaseprofile = DictReader(open(strainprofile))
        # Put the strain profile dictionary into a more easily searchable format
        for data in databaseprofile:
            databasedict[data['Strain']] = data['SequenceType']
        for sample in self.metadata.samples:
            closestmatches = list()
            if sample[self.analysistype].reportdir != 'NA':
                if type(sample[self.analysistype].allelenames) == list:
                    # Populate the header with the appropriate data, including all the genes in the list of targets
                    header = 'Strain,SequenceType,Matches,Mismatches,NA,TotalGenes,ClosestDatabaseMatch,{},\n' \
                        .format(','.join(sorted(sample[self.analysistype].allelenames)))
                sortedmatches = sorted(sample[self.analysistype].profilematches.items(),
                                       key=operator.itemgetter(1), reverse=True)[0]
                closestseqtype = sortedmatches[0]
                # Pull out the closest database match
                for strain, seqtype in databasedict.items():
                    if seqtype == closestseqtype:
                        closestmatches.append(strain)
                sample[self.analysistype].closestseqtype = closestseqtype
                nummatches = int(sortedmatches[1])
                numna = 0
                queryallele = list()
                # Get all the alleles into a list
                for gene, allele in sorted(sample[self.analysistype].profiledata[closestseqtype].items()):
                    try:
                        # Extract the allele (anything after the -) from the allele matches
                        query = sample[self.analysistype].allelematches[gene].split('-')[1]
                        if allele == query:
                            queryallele.append(query)
                        else:
                            queryallele.append('{} ({})'.format(query, allele))
                    except KeyError:
                        queryallele.append('NA')
                        numna += 1
                mismatches = len(sample[self.analysistype].alleles) - nummatches - numna
                row += '{},{},{},{},{},{},{},{}'\
                    .format(sample.name, closestseqtype, nummatches, mismatches, numna,
                            len(sample[self.analysistype].alleles), ','.join(closestmatches), ','.join(queryallele))
                row += '\n'
        # Create the report folder
        make_path(self.reportpath)
        # Create the report containing all the data from all samples
        with open(os.path.join(self.reportpath, '{}.csv'.format(self.analysistype)), 'w') as combinedreport:
            # Write the results to this report
            combinedreport.write(header)
            combinedreport.write(row)
1176299
def runSearchRnaQuantificationSets(self, request):
        
        return self.runSearchRequest(
            request, protocol.SearchRnaQuantificationSetsRequest,
            protocol.SearchRnaQuantificationSetsResponse,
            self.rnaQuantificationSetsGenerator)
863753
def by_causes(queryset, cause_string=None):
  
  if cause_string:
    operator, items = get_operator_and_items(cause_string)
    q_obj = SQ()
    for c in items:
      if len(c) > 0:
        q_obj.add(SQ(causes=c), operator)
    queryset = queryset.filter(q_obj)
  return queryset
267587
def queryset(self, request, queryset):
        """"""
        if self.value() == '-1':
            return queryset.filter(latest_version__isnull=True)
        elif self.value() == '0':
            return (
                queryset
                .filter(
                    current_version__isnull=False,
                    latest_version__isnull=False,
                    latest_version=F('current_version')
                )
            )
        elif self.value() == '1':
            return (
                queryset
                .filter(
                    current_version__isnull=False,
                    latest_version__isnull=False
                ).exclude(
                    latest_version=F('current_version')
                )
            )
        else:
            return queryset
879384
def filter(self, dataset):
    """"""
    self.info('Going to filter infrequent routes in the dataset')
    for route in dataset.routes.values():
      self.filter_line(route)