Skip to content

Commit

Permalink
Cleanup more stylistic issues
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Mar 7, 2021
1 parent 6a17d96 commit 3867b84
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ addopts =
max-line-length = 130
max-complexity = 15
per-file-ignores =
# allow long lines (E501)
website/tests/*:E501
website/tests/test_imports/*:E501,W291
# SQLAlchemy false-positives
Expand Down
2 changes: 1 addition & 1 deletion website/analyses/active_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def save_all(analysis_name: str, data, base_path=None):
datum.to_csv(path / f'{name}.tsv', sep='\t')


def create_gene_list(name: str, list_data: DataFrame, mutation_source: MutationSource=None) -> GeneList:
def create_gene_list(name: str, list_data: DataFrame, mutation_source: MutationSource = None) -> GeneList:
gene_list, created = get_or_create(GeneList, name=name)

if not created:
Expand Down
21 changes: 12 additions & 9 deletions website/analyses/enrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def count_mutated_potential_sites():
print(count, total_length, count/total_length*100)


def test_enrichment_of_ptm_mutations_among_mutations_subset(subset_query, reference_query, iterations_count=100000, subset_size=None, subset_ptms=None):
def test_enrichment_of_ptm_mutations_among_mutations_subset(
subset_query, reference_query, iterations_count=100000, subset_size=None, subset_ptms=None
):
"""Perform tests according to proposed algorithm:
1. Count the number of all ClinVar mutations as C, PTM-associated ClinVar mutations as D=27071
Expand Down Expand Up @@ -134,9 +136,9 @@ def test_enrichment_of_ptm_mutations_among_mutations_subset(subset_query, refere


def get_confirmed_mutations(
sources, only_preferred=True, genes=None, confirmed_by_definition=False,
base_query=None
):
sources, only_preferred=True, genes=None, confirmed_by_definition=False,
base_query=None
):
"""
Utility to generate a query for retrieving confirmed mutations having specific mutation details.
Expand Down Expand Up @@ -240,12 +242,12 @@ def collect_ratios(sources, only_genes_with_ptm_sites=False):
protein = gene.preferred_isoform
filters = and_(
Mutation.protein == protein,
Mutation.is_confirmed == True
Mutation.is_confirmed == True # noqa: E712
)
number_of_all_mutations = Mutation.query.filter(filters).count()
number_of_ptm_mutations = Mutation.query.filter(and_(
filters,
Mutation.precomputed_is_ptm == True
Mutation.precomputed_is_ptm == True # noqa: E712
)).count()
ratios.append(number_of_ptm_mutations/number_of_all_mutations)
return FloatVector(ratios)
Expand Down Expand Up @@ -343,7 +345,6 @@ def load_omim(omim_path='data/omim-gene_phenotype.tsv'):
omim = read_table(omim_path, skiprows=4)
omim_genes = set()


skipped = 0
for i, row in omim.iterrows():
g = Gene.query.filter_by(entrez_id=int(row['Entrez Gene ID'])).first()
Expand Down Expand Up @@ -409,7 +410,7 @@ def count_mutations_from_genes(genes, sources, only_preferred_isoforms=False, st

mutations_filters = and_(
Mutation.protein_id.in_([p.id for p in proteins]),
Mutation.is_confirmed == True,
Mutation.is_confirmed == True, # noqa: E712
Mutation.in_sources(*sources)
)

Expand Down Expand Up @@ -495,7 +496,7 @@ def prepare_for_summing(sources: List[MutationSource], count_distinct_substituti


def most_mutated_sites(
sources: List[MutationSource], site_type: SiteType=None, limit=25, intersection=True,
sources: List[MutationSource], site_type: SiteType = None, limit=25, intersection=True,
exclusive=None, mutation_filter=None
):
"""Sources must have the same value_type (counts/frequencies)"""
Expand Down Expand Up @@ -884,6 +885,8 @@ def sites_mutated_ratio(
if path:
ggplot2.ggsave(str(path), width=width / dpi, height=height / dpi, dpi=dpi, units='in', bg='transparent')

return plot


def ptm_on_random(
source=MC3Mutation, site_type='glycosylation',
Expand Down
2 changes: 1 addition & 1 deletion website/views/cms.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from models import User
from database import db
from database import get_or_create
from app import login_manager, recaptcha, limiter
from app import recaptcha, limiter
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.orm.exc import MultipleResultsFound
from sqlalchemy.exc import IntegrityError, OperationalError
Expand Down

0 comments on commit 3867b84

Please sign in to comment.