vanheeringen-lab/gimmemotifs

View on GitHub

Showing 79 of 82 total issues

Function compare_motifs has a Cognitive Complexity of 25 (exceeds 15 allowed). Consider refactoring.
Open

    def compare_motifs(
        self, m1, m2, match="total", metric="wic", combine="mean", pval=False
    ):
        """Compare two motifs.

Severity: Minor
Found in gimmemotifs/comparison.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 _scan_jobs has a Cognitive Complexity of 25 (exceeds 15 allowed). Consider refactoring.
Open

    def _scan_jobs(self, scan_func, scan_seqs):
        if self.ncpus > 1:
            median_len = np.median([len(x) for x in scan_seqs])
            chunksize = 200000 // int(median_len)  # 1000 seqs for len 200
            # prepare for parallel processing
Severity: Minor
Found in gimmemotifs/scanner/base.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 write_equalsize_bedfile has a Cognitive Complexity of 24 (exceeds 15 allowed). Consider refactoring.
Open

def write_equalsize_bedfile(bedfile, size, outfile):
    """Read input from <bedfile>, set the size of all entries to <size> and
    write the result to <outfile>.
    Input file needs to be in BED or WIG format."""
    if size is None or size <= 0:
Severity: Minor
Found in gimmemotifs/utils.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 cluster_motifs_with_report has a Cognitive Complexity of 24 (exceeds 15 allowed). Consider refactoring.
Open

def cluster_motifs_with_report(infile, outfile, outdir, threshold, title=None):
    # Cluster significant motifs

    if title is None:
        title = infile
Severity: Minor
Found in gimmemotifs/motif/cluster.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 determine_file_type has a Cognitive Complexity of 24 (exceeds 15 allowed). Consider refactoring.
Open

def determine_file_type(fname):
    """
    Detect file type.

    The following file types are supported:
Severity: Minor
Found in gimmemotifs/utils.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 format_factors has a Cognitive Complexity of 23 (exceeds 15 allowed). Consider refactoring.
Open

    def format_factors(
        self, max_length=5, html=False, include_indirect=True, extra_str=",(...)"
    ):
        # create a list of factors, in order of de novo > direct/indirect > occurrence
        if hasattr(self, "factor_info"):
Severity: Minor
Found in gimmemotifs/motif/base.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 parse has a Cognitive Complexity of 23 (exceeds 15 allowed). Consider refactoring.
Open

    def parse(self, fo):
        """
        Convert GADEM output to motifs

        Parameters
Severity: Minor
Found in gimmemotifs/tools/gadem.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 select_nonredundant_motifs has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def select_nonredundant_motifs(
    roc_report, pfmfile, fg_table, bg_table, tolerance=0.001
):
    pfmfile = pfmfile_location(pfmfile)
    motifs = read_motifs(pfmfile)
Severity: Minor
Found in gimmemotifs/comparison.py - About 1 hr to fix

    Function parse has a Cognitive Complexity of 22 (exceeds 15 allowed). Consider refactoring.
    Open

        def parse(self, fo):
            """
            Convert MDmodule output to motifs
    
            Parameters
    Severity: Minor
    Found in gimmemotifs/tools/mdmodule.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 motifs has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def motifs(args):
        """Calculate ROC_AUC and other metrics and optionally plot ROC curve."""
        if args.outdir is None:
            raise ValueError("an output directory is required!")
        if not os.path.exists(args.outdir):
    Severity: Minor
    Found in gimmemotifs/commands/motifs.py - About 1 hr to fix

      Function match has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring.
      Open

      def match(args):
          sample = dict([(m.id, m) for m in read_motifs(args.pfmfile)])
          db = dict([(m.id, m) for m in read_motifs(args.dbpfmfile)])
      
          mc = MotifComparer()
      Severity: Minor
      Found in gimmemotifs/commands/match.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 _initialize_matrices has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring.
      Open

          def _initialize_matrices(self, seqs, k=1, alphabet=None):
              if alphabet is None:
                  alphabet = ["A", "C", "G", "T"]
      
              self.frequencies = {}
      Severity: Minor
      Found in gimmemotifs/background.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 cli has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring.
      Open

      def cli(sys_args):
          config = MotifConfig()
          params = config.get_default_params()
          default_pfm_file = os.path.join(config.get_motif_dir(), params["motif_db"])
          default_pfm = params["motif_db"]
      Severity: Minor
      Found in gimmemotifs/cli.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 roc_auc_xlim has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def roc_auc_xlim(x_bla, y_bla, xlim=0.1):
          """
          Computes the ROC Area Under Curve until a certain FPR value.
      
          Parameters
      Severity: Minor
      Found in gimmemotifs/rocmetrics.py - About 1 hr to fix

        Function motif2factor_from_orthologs has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def motif2factor_from_orthologs(
            database: str = "gimme.vertebrate.v5.0",
            database_references: List[str] = None,
            extra_orthologs_references: List[str] = None,
            new_reference: List[str] = None,
        Severity: Minor
        Found in gimmemotifs/orthologs.py - About 1 hr to fix

          Function score_matrices has a Cognitive Complexity of 20 (exceeds 15 allowed). Consider refactoring.
          Open

              def score_matrices(self, matrix1, matrix2, metric, combine):
          
                  if metric in self.metrics and combine in self.combine:
                      s = score(matrix1.tolist(), matrix2.tolist(), metric, combine)
          
          
          Severity: Minor
          Found in gimmemotifs/comparison.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 _unknownfactor2symbols has a Cognitive Complexity of 20 (exceeds 15 allowed). Consider refactoring.
          Open

          def _unknownfactor2symbols(factor, fields):
              """
              Query mygeneinfo for different aliases of our gene
              """
          
          
          Severity: Minor
          Found in gimmemotifs/orthologs.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 diff has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def diff(args):
          
              infiles = args.inputfiles.split(",")
              bgfile = args.bgfile
              outfile = args.outputfile
          Severity: Minor
          Found in gimmemotifs/commands/diff.py - About 1 hr to fix

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

                def _circle(
                    self,
                    subset=None,
                    show_text=True,
                    color=None,
            Severity: Minor
            Found in gimmemotifs/report.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 a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring.
            Open

                def __init__(self, fname=None, split_whitespace=False, fdict=None):
                    """Instantiate fasta object. Optional Fasta-formatted file as argument"""
                    self.ids = []
                    self.seqs = []
                    p = re.compile(r"[^abcdefghiklmnpqrstuvwyzxABCDEFGHIKLMNPQRSTUVWXYZ]")
            Severity: Minor
            Found in gimmemotifs/fasta.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

            Severity
            Category
            Status
            Source
            Language