File mutations.py
has 862 lines of code (exceeds 250 allowed). Consider refactoring. Open
from abc import ABCMeta, abstractmethod
from collections import UserList, OrderedDict
from functools import lru_cache
from typing import Type, Iterable, Mapping, List, Dict, TYPE_CHECKING
Mutation
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class Mutation(BioModel, MutatedMotifs):
__table_args__ = (
db.Index('mutation_index', 'alt', 'protein_id', 'position'),
db.UniqueConstraint('alt', 'protein_id', 'position')
)
Function affected_motifs
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def affected_motifs(self, sites: Iterable[Site] = None):
if self.were_affected_motifs_precomputed:
return self.precomputed_affected_motifs
from analyses.motifs import mutate_sequence
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_affected_ptm_sites
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_affected_ptm_sites(self, site_filter=lambda x: x):
"""Get PTM sites that might be affected by this mutation,
when taking into account -7 to +7 spans of each PTM site.
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if not has_motif(mutated_sequence, motif.pattern):
affected_motifs.append((motif, self.position - site.position + 7))
Function is_close_to_some_site
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def is_close_to_some_site(self, left, right, sites=None):
"""Check if the mutation lies close to any of sites.
Arguments define span around each site to be checked:
(site_pos - left, site_pos + right)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function impact_on_ptm
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def impact_on_ptm(self, site_filter=None):
"""How intense might be an impact of the mutation on a PTM site.
It describes impact on the closest PTM site or on a site chosen by
MIMP algorithm (so it applies only when 'network-rewiring' is returned)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function impact_on_specific_ptm
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def impact_on_specific_ptm(self, site: Site, ignore_mimp=False):
if self.position == site.position:
return 'direct'
elif site in self.meta_MIMP.sites and not ignore_mimp:
return 'network-rewiring'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function details_proxy
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def details_proxy(target_class, key, managed=False):
"""Creates an AssociationProxy targeting MutationDetails descendants.
The proxy enables easy filtering and retrieval of the otherwise deeply
hidden information and should be owned by (i.e. declared in) Mutation model.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return 'distal'
Avoid too many return
statements within this function. Open
return 'none'
Avoid too many return
statements within this function. Open
return 'distal'
Avoid too many return
statements within this function. Open
return 'none'