def __init__(self, *args, **kwargs): super(CompareSetForm, self).__init__(*args, **kwargs) current_release = ReleaseUtils.get_latest_release() current_assembly = ReleaseUtils.get_latest_assembly() current_source = ReleaseUtils.get_default_source() self.fields['diff_current_assembly'] = forms.CharField( initial=current_assembly, widget=forms.Select(choices=FormUtils.get_all_assembly_name_tuples( ))) # @IgnorePep8 self.fields['diff_current_release'] = forms.CharField( initial=int(current_release), widget=forms.Select(choices=FormUtils.get_all_release_name_tuples( source_name="all"))) # @IgnorePep8 self.fields['diff_current_source'] = forms.CharField( initial=current_source, widget=forms.Select( choices=FormUtils.get_all_sources_tuples())) # @IgnorePep8 self.fields['diff_compare_assembly'] = forms.CharField( initial=current_assembly, widget=forms.Select(choices=FormUtils.get_all_assembly_name_tuples( ))) # @IgnorePep8 self.fields['diff_compare_release'] = forms.CharField( initial=int(current_release) - 1, widget=forms.Select(choices=FormUtils.get_all_release_name_tuples( source_name="all"))) # @IgnorePep8 self.fields['diff_compare_source'] = forms.CharField( initial=current_source, widget=forms.Select( choices=FormUtils.get_all_sources_tuples())) # @IgnorePep8
def __init__(self, *args, **kwargs): super(DiffFormRelease, self).__init__(*args, **kwargs) current_release = ReleaseUtils.get_latest_release() current_assembly = ReleaseUtils.get_latest_assembly() default_source = ReleaseUtils.get_default_source() self.fields['species'] = forms.CharField(widget=forms.Select( choices=FormUtils.get_all_species_name_tuples()), required=False) self.fields['diff_me_assembly'] = forms.CharField( initial=current_assembly, widget=forms.Select(choices=FormUtils.get_all_assembly_name_tuples( ))) # @IgnorePep8 self.fields['diff_me_release'] = forms.CharField( initial=current_release, widget=forms.Select(choices=FormUtils.get_all_release_name_tuples( ))) # @IgnorePep8 self.fields['diff_with_assembly'] = forms.CharField( initial=current_assembly, widget=forms.Select(choices=FormUtils.get_all_assembly_name_tuples( ))) # @IgnorePep8 self.fields['diff_with_release'] = forms.CharField( initial=int(current_release) - 1, widget=forms.Select(choices=FormUtils.get_all_release_name_tuples( ))) # @IgnorePep8 self.fields['diff_with_source'] = forms.CharField( initial=default_source, widget=forms.Select( choices=FormUtils.get_all_sources_tuples())) # @IgnorePep8 self.fields['diff_me_source'] = forms.CharField( initial=default_source, widget=forms.Select( choices=FormUtils.get_all_sources_tuples())) # @IgnorePep8
def init_assembly_releases(request): # default is ensembl all_assembly_releases = json.dumps( ReleaseUtils.get_all_assembly_releases()) all_assembly_releases_refseq = json.dumps( ReleaseUtils.get_all_assembly_releases("RefSeq")) all_assembly_releases_ensembl = json.dumps( ReleaseUtils.get_all_assembly_releases("Ensembl")) current_release = ReleaseUtils.get_latest_release() current_assembly = ReleaseUtils.get_latest_assembly() source_name = ReleaseUtils.get_default_source() init_hash = { "all_assembly_releases": all_assembly_releases, "all_assembly_releases_ensembl": all_assembly_releases_ensembl, "all_assembly_releases_refseq": all_assembly_releases_refseq, "current_release": current_release, "current_assembly": current_assembly, "release_name": current_release, "assembly_name": current_assembly, 'release_name_compare': int(current_release) - 1, 'assembly_name_compare': current_assembly, 'source_name': source_name } return init_hash
def init_assembly_releases(request): # default is ensembl all_assembly_releases = json.dumps( ReleaseUtils.get_all_assembly_releases()) all_assembly_releases_refseq = json.dumps( ReleaseUtils.get_all_assembly_releases("RefSeq")) all_assembly_releases_ensembl = json.dumps( ReleaseUtils.get_all_assembly_releases("Ensembl")) current_release = ReleaseUtils.get_latest_release() current_assembly = ReleaseUtils.get_latest_assembly() source_name = ReleaseUtils.get_default_source() software_release_tag = "1.0.0" if settings.SOFTWARE_RELEASE_TAG is None else settings.SOFTWARE_RELEASE_TAG init_hash = { "all_assembly_releases": all_assembly_releases, "all_assembly_releases_ensembl": all_assembly_releases_ensembl, "all_assembly_releases_refseq": all_assembly_releases_refseq, "current_release": current_release, "current_assembly": current_assembly, "release_name": current_release, "assembly_name": current_assembly, 'release_name_compare': int(current_release) - 1, 'assembly_name_compare': current_assembly, 'source_name': source_name, 'software_release_tag': software_release_tag } return init_hash
def get_query_params(cls, request, diff_type=None): params_diff = {} stable_id_cur = request.query_params.get(diff_type + '_stable_id', None) if '.' in stable_id_cur: stable_id, stable_id_version = stable_id_cur.split('.') params_diff['stable_id'] = stable_id params_diff['stable_id_version'] = stable_id_version else: params_diff['stable_id'] = request.query_params.get( diff_type + '_stable_id', None) params_diff['release_short_name'] = request.query_params.get( diff_type + '_release', ReleaseUtils.get_latest_release()) params_diff['assembly_name'] = request.query_params.get( diff_type + '_assembly', ReleaseUtils.get_latest_assembly()) params_diff['source_name'] = request.query_params.get( diff_type + '_source', ReleaseUtils.get_default_source()) # params_diff['expand'] = request.query_params.get('expand', "transcript_release_set,translations, sequence") params_diff['expand_all'] = request.query_params.get( 'expand_all', "true") return params_diff
def get_queryset(self): latest_release = self.kwargs['release_name'] latest_assembly = self.kwargs['assembly_name'] latest_source = self.kwargs['source_name'] if latest_release is None: latest_release = ReleaseUtils.get_latest_release() if latest_assembly is None: latest_assembly = ReleaseUtils.get_latest_assembly() if latest_source is None: latest_source = ReleaseUtils.get_default_source() self.unfiltered_query_set = query_set = Transcript.objects.filter( Q(transcript_release_set__shortname__icontains=latest_release) & Q(assembly__assembly_name__icontains=latest_assembly) & Q(transcript_release_set__source__shortname__icontains=latest_source)) order_by_index = int(self.request.query_params.get('order[0][column]', 0)) orderable = bool(self.request.query_params.get('columns[{}][orderable]'.format(order_by_index), 'false')) if order_by_index == 0 or not orderable: order_by_index = 1 order_by = self.request.query_params.get('columns[{}][data]'.format(order_by_index), self.default_order_by).\ replace('.', '__') order_by_dir = self.request.query_params.get('order[0][dir]', 'asc') if order_by_dir == 'desc': order_by = '-{}'.format(order_by) search_queries = self.request.query_params.get('search[value]', '').strip().split(' ') q = Q() if len(search_queries) > 0 and search_queries[0] != u'': for params in self.search_parameters: if "genes" == params: for query in search_queries: temp = { '{}__hgnc__name__icontains'.format(params): query, } q |= Q(**temp) else: for query in search_queries: if not query.isdigit() and params in ["transcript_id", "stable_id_version", "loc_start", "loc_end"]: continue temp = { '{}__icontains'.format(params): query, } q |= Q(**temp) query_set = query_set.filter(q).distinct() if order_by == '': return query_set return query_set.order_by(order_by)