File dseq.py
has 1427 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2013-2023 by Björn Johansson. All rights reserved.
# This code is part of the Python-dna distribution and governed by its
Dseq
has 47 functions (exceeds 20 allowed). Consider refactoring. Open
class Dseq(_Seq):
"""Dseq holds information for a double stranded DNA fragment.
Dseq also holds information describing the topology of
the DNA fragment (linear or circular).
Function __init__
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def __init__(
self,
watson,
crick=None,
ovhg=None,
- 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 __repr__
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def __repr__(self):
"""Returns a representation of the sequence, truncated if
longer than 30 bp"""
if len(self) > Dseq.trunc:
- 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 cutsite_is_valid
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def cutsite_is_valid(self, cutsite):
"""Returns False if:
- Cut positions fall outside the sequence (could be moved to Biopython)
- Overhang is not double stranded
- Recognition site is not double stranded or is outside the 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 T4
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def T4(self, nucleotides=None):
"""Fill in five prime protruding ends and chewing back
three prime protruding ends by a DNA polymerase providing both
5'-3' DNA polymerase activity and 3'-5' nuclease acitivty
(such as T4 DNA polymerase). This can be done in presence of any
- 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 __getitem__
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def __getitem__(self, sl):
"""Returns a subsequence. This method is used by the slice notation"""
if not self.circular:
x = len(self.crick) - self.ovhg - len(self.watson)
- 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 __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function quick
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def quick(
Function from_string
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def from_string(
Function translate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def translate(self, table="Standard", stop_symbol="*", to_stop=False, cds=False, gap="-"):
Function _fill_in_five_prime
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _fill_in_five_prime(self, nucleotides):
stuffer = ""
type, se = self.five_prime_end()
if type == "5'":
for n in _rc(se):
- 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 __add__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def __add__(self, other):
"""Simulates ligation between two DNA fragments.
Add other Dseq object at the end of the sequence.
Type error is raised if any of the points below are fulfilled:
- 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 _fill_in_three_prime
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _fill_in_three_prime(self, nucleotides):
stuffer = ""
type, se = self.three_prime_end()
if type == "5'":
for n in _rc(se):
- 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 True