def __init__(self, **kwargs): filters = [ Filter( Mutation, 'sources', comparators=['in'], choices=list(source_manager.visible_fields.keys()), default=None, nullable=True, as_sqlalchemy=sqlalchemy_filter_from_source_name ), Filter( Site, 'types', comparators=['in'], choices={ site_type.name: site_type for site_type in SiteType.available_types() }, as_sqlalchemy=SiteType.fuzzy_filter, as_sqlalchemy_joins=[SiteType] ), Filter( Gene, 'has_ptm_muts', comparators=['eq'], as_sqlalchemy=lambda value: text('ptm_muts_cnt > 0') if value else text('true') ), Filter( Gene, 'is_known_kinase', comparators=['eq'], as_sqlalchemy=lambda value: Protein.kinase.any() ) ] + [ filter for filter in source_dependent_filters() if filter.has_sqlalchemy # filters without sqlalchemy interface are not supported for table views ] super().__init__(filters) self.update_from_request(request)
def common_filters(protein, default_source='MC3', source_nullable=False, custom_datasets_ids=[]): return [ Filter(Mutation, 'sources', comparators=['in'], choices=list(source_manager.visible_fields.keys()), default=default_source, nullable=source_nullable, as_sqlalchemy=sqlalchemy_filter_from_source_name), Filter(UserMutations, 'sources', comparators=['in'], choices=list(custom_datasets_ids), default=None, nullable=True), Filter(Mutation, 'is_ptm', comparators=['eq']), Filter(Drug, 'groups.name', comparators=['in'], nullable=False, choices=cached_queries.drug_groups, default=['approved'], multiple='all', as_sqlalchemy=True), Filter(Site, 'types', comparators=['in'], choices={ site_type.name: site_type for site_type in SiteType.available_types() }, custom_comparators={'in': SiteType.fuzzy_comparator}, as_sqlalchemy=SiteType.fuzzy_filter, as_sqlalchemy_joins=[Site.types]) ] + source_dependent_filters(protein)
def show(self, refseq): """Show a protein by: + needleplot + tracks (sequence + data tracks) """ protein, filter_manager = self.get_protein_and_manager(refseq) user_datasets = current_user.datasets_names_by_uri() return template( 'protein/show.html', protein=protein, filters=filter_manager, widgets=create_widgets( protein, filter_manager.filters, custom_datasets_names=user_datasets.values()), site_types=['multi_ptm'] + SiteType.available_types(), mutation_types=Mutation.types, )
from models import SiteType, AnySiteType site_types_with_any = SiteType.available_types(include_any=True) site_types = SiteType.available_types() site_types_names = [site_type.name for site_type in site_types] any_site_type = AnySiteType() class Motif: def __init__(self, name, pattern): self.name = name self.pattern = pattern motifs = [ Motif(pattern='.{7}N[^P][STCV].{5}', name='n_linked'), Motif(pattern='.{7}(TAPP|TSAPP|TV.P|[ST].P).{4}', name='o_linked'), Motif(pattern='(.{7}W..W.{4}|.{4}W..W.{7}|.{7}W[ST].C.{4})', name='c_linked') ]