BjornFJohansson/pydna

View on GitHub
src/pydna/dseqrecord.py

Summary

Maintainability
F
6 days
Test Coverage

File dseqrecord.py has 1063 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
# license.  Please see the LICENSE.txt file that should have been included
Severity: Major
Found in src/pydna/dseqrecord.py - About 2 days to fix

    Dseqrecord has 47 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Dseqrecord(_SeqRecord):
        """Dseqrecord is a double stranded version of the Biopython SeqRecord [#]_ class.
        The Dseqrecord object holds a Dseq object describing the sequence.
        Additionally, Dseqrecord hold meta information about the sequence in the
        from of a list of SeqFeatures, in the same way as the SeqRecord does.
    Severity: Minor
    Found in src/pydna/dseqrecord.py - About 6 hrs to fix

      Function map_trace_files has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          def map_trace_files(self, pth, limit=25):  # TODO allow path-like objects
              import glob
      
              traces = []
              for name in glob.glob(pth):
      Severity: Minor
      Found in src/pydna/dseqrecord.py - About 5 hrs to fix

      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 a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(
              self,
              record,
              *args,
              # linear=None,
      Severity: Minor
      Found in src/pydna/dseqrecord.py - About 2 hrs to fix

      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 write has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def write(self, filename=None, f="gb"):
              """Writes the Dseqrecord to a file using the format f, which must
              be a format supported by Biopython SeqIO for writing [#]_. Default
              is "gb" which is short for Genbank. Note that Biopython SeqIO reads
              more formats than it writes.
      Severity: Minor
      Found in src/pydna/dseqrecord.py - About 2 hrs to fix

      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 synced has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def synced(self, ref, limit=25):
              """This method returns a new circular sequence (Dseqrecord object), which has been rotated
              in such a way that there is maximum overlap between the sequence and
              ref, which may be a string, Biopython Seq, SeqRecord object or
              another Dseqrecord object.
      Severity: Minor
      Found in src/pydna/dseqrecord.py - About 1 hr to fix

      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):
              """docstring."""
              answer = Dseqrecord(_copy.copy(self))
              answer.seq = self.seq.__getitem__(sl)
              # answer.seq.alphabet = self.seq.alphabet
      Severity: Minor
      Found in src/pydna/dseqrecord.py - About 1 hr to fix

      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 apply_cut has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def apply_cut(self, left_cut, right_cut):
              dseq = self.seq.apply_cut(left_cut, right_cut)
              # TODO: maybe remove depending on https://github.com/BjornFJohansson/pydna/issues/161
      
              if left_cut == right_cut:
      Severity: Minor
      Found in src/pydna/dseqrecord.py - About 1 hr to fix

      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 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def __add__(self, other):
              if hasattr(other, "seq") and hasattr(other.seq, "watson"):
                  other = _copy.deepcopy(other)
                  other_five_prime = other.seq.five_prime_end()
                  if other_five_prime[0] == "5'":
      Severity: Minor
      Found in src/pydna/dseqrecord.py - About 1 hr to fix

      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 __contains__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def __contains__(self, other):
              if other.lower() in str(self.seq).lower():
                  return True
              else:
                  s = self.seq.watson.replace(" ", "")
      Severity: Minor
      Found in src/pydna/dseqrecord.py - About 55 mins to fix

      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 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in src/pydna/dseqrecord.py - About 50 mins to fix

        Function add_feature has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def add_feature(self, x=None, y=None, seq=None, type_="misc", strand=1, *args, **kwargs):
        Severity: Major
        Found in src/pydna/dseqrecord.py - About 50 mins to fix

          Function from_string has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def from_string(
          Severity: Minor
          Found in src/pydna/dseqrecord.py - About 45 mins to fix

            Function looped has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def looped(self):
                    """
                    Circular version of the Dseqrecord object.
            
                    The underlying linear Dseq object has to have compatible ends.
            Severity: Minor
            Found in src/pydna/dseqrecord.py - About 45 mins to fix

            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 from_SeqRecord has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def from_SeqRecord(
            Severity: Minor
            Found in src/pydna/dseqrecord.py - About 45 mins to fix

              Function figure has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def figure(self, feature=0, highlight="\x1b[48;5;11m", plain="\x1b[0m"):
                      """docstring."""
                      if self.features:
                          f = self.features[feature]
                          locations = sorted(self.features[feature].location.parts, key=_SimpleLocation.start.fget)
              Severity: Minor
              Found in src/pydna/dseqrecord.py - About 35 mins to fix

              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 find_aminoacids has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def find_aminoacids(self, other):
                      """
                      >>> from pydna.dseqrecord import Dseqrecord
                      >>> s=Dseqrecord("atgtacgatcgtatgctggttatattttag")
                      >>> s.seq.translate()
              Severity: Minor
              Found in src/pydna/dseqrecord.py - About 35 mins to fix

              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 __mul__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __mul__(self, number):
                      if not isinstance(number, int):
                          raise TypeError("TypeError: can't multiply Dseqrecord by non-int of type {}".format(type(number)))
                      if self.circular:
                          raise TypeError("TypeError: can't multiply circular Dseqrecord.")
              Severity: Minor
              Found in src/pydna/dseqrecord.py - About 25 mins to fix

              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

              There are no issues that match your filters.

              Category
              Status