vanheeringen-lab/gimmemotifs

View on GitHub

Showing 79 of 82 total issues

Function diff_plot has a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring.
Open

def diff_plot(
    motifs,
    pwms,
    names,
    freq,
Severity: Minor
Found in gimmemotifs/plot.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

Avoid deeply nested control flow statements.
Open

                    if abs(matrix[i][n]) * height >= 0.5:
                        plt.text(
                            x,
                            y,
                            nuc,
Severity: Major
Found in gimmemotifs/motif/_plotting.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if len(res):
                            for _, gene_name, _, gene_id, *_ in res:
                                motif_set = True
                                if gene_name is not None:
                                    f.write(f"{motif}\t{gene_name}\tOrthologs\tN\n")
    Severity: Major
    Found in gimmemotifs/orthologs.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if "x" not in line and "n" not in line:
                                  line = line.strip().upper()
                                  align.append(line)
                                  if not pfm:
                                      pfm = [[0 for _ in range(4)] for _ in range(len(line))]
      Severity: Major
      Found in gimmemotifs/tools/gadem.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                with open(score_file) as f:
                                    for line in f:
                                        l1, l2, m, sd = line.strip().split("\t")[:4]
                                        self.scoredist[metric][f"{match}_{combine}"].setdefault(
                                            int(l1), {}
        Severity: Major
        Found in gimmemotifs/comparison.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if not pfm:
                                      pfm = [[0 for x in range(4)] for x in range(len(match))]
                                  for pos in range(len(match)):
          Severity: Major
          Found in gimmemotifs/tools/meme.py - About 45 mins to fix

            Function matrix_ic has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring.
            Open

            def matrix_ic(self, ppm1, ppm2, bg=None):
                if bg is None:
                    bg = [0.25, 0.25, 0.25, 0.25]
            
                # xxCATGYT
            Severity: Minor
            Found in gimmemotifs/motif/_comparison.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

            Avoid deeply nested control flow statements.
            Open

                                    if not pfm:
                                        pfm = [[0 for x in range(4)] for x in range(len(match))]
                                    for pos in range(len(match)):
            Severity: Major
            Found in gimmemotifs/tools/memew.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      for pos in range(len(match)):
                                          if match[pos] in nucs:
                                              pfm[pos][nucs[match[pos]]] += 1
                                          else:
                                              for i in range(4):
              Severity: Major
              Found in gimmemotifs/tools/memew.py - About 45 mins to fix

                Function _read_motifs_pfm has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring.
                Open

                def _read_motifs_pfm(handle):
                    p = re.compile(
                        r"(\d+(\.\d+)?(e-\d+)?)\s+(\d+(\.\d+)?(e-\d+)?)\s+(\d+(\.\d+)?(e-\d+)?)\s+(\d+(\.\d+)?(e-\d+)?)"  # noqa: E501
                    )
                    motifs = []
                Severity: Minor
                Found in gimmemotifs/motif/read.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

                Avoid deeply nested control flow statements.
                Open

                                        for pos in range(len(match)):
                                            if match[pos] in nucs:
                                                pfm[pos][nucs[match[pos]]] += 1
                                            else:
                                                for i in range(4):
                Severity: Major
                Found in gimmemotifs/tools/meme.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if warn_no_summit:
                                          logger.warning(
                                              "No summit present in narrowPeak file, "
                                              "using the peak center."
                                          )
                  Severity: Major
                  Found in gimmemotifs/utils.py - About 45 mins to fix

                    Function _upgrade_config has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring.
                    Open

                        def _upgrade_config(self, config_fname=None):
                            changed = False
                            dflt = configparser.ConfigParser()
                            dflt.read(self.default_config)
                    
                    
                    Severity: Minor
                    Found in gimmemotifs/config.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

                    Avoid deeply nested control flow statements.
                    Open

                                        if len(vals) > 5:
                                            strand = vals[5]
                    
                    
                    Severity: Major
                    Found in gimmemotifs/preprocessing.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if m1 not in scores:
                                                  scores[m1] = {}
                                              scores[m1][m2] = s
                      Severity: Major
                      Found in gimmemotifs/comparison.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if len(row) == 4:
                                                    row = [float(x) for x in row]
                                                    pfm.append(row)
                        
                        
                        Severity: Major
                        Found in gimmemotifs/tools/rpmcmc.py - About 45 mins to fix

                          Function plot_logo has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
                          Open

                          def plot_logo(
                              self,
                              fname=None,
                              kind="information",
                              title=True,
                          Severity: Minor
                          Found in gimmemotifs/motif/_plotting.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

                          Avoid too many return statements within this function.
                          Open

                                              return self.max_partial(m1.pfm, m2.pfm, metric, combine)
                          Severity: Major
                          Found in gimmemotifs/comparison.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                                return self.max_subtotal(m1.pfm, m2.pfm, metric, combine)
                            Severity: Major
                            Found in gimmemotifs/comparison.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                              return "unknown"
                              Severity: Major
                              Found in gimmemotifs/utils.py - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language