betteridiot/bamnostic

View on GitHub

Showing 46 of 167 total issues

Function __init__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, filepath_or_object, mode="rb", max_cache=128, index_filename=None,
                 filename=None, check_header=False, check_sq=True, reference_filename=None,
                 filepath_index=None, require_index=False, duplicate_filehandle=None,
                 ignore_truncation=False):
        """Initialize the class.
Severity: Minor
Found in bamnostic/bam.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 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, _io):
        """Instantiating the read parser just needs access to the BGZF io.object

        Args:
            io (BgzfReader): parser for processing BGZF files
Severity: Minor
Found in bamnostic/core.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 mate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def mate(self, AlignedSegment):
        """ Gets the mate to a given AlignedSegment.

        Note:
            Slow, when compared to the C-API. Not meant for high-throughput analysis.
Severity: Minor
Found in bamnostic/bam.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 _range_popper has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _range_popper(self, interval_start, interval_stop=None, front=True):
        """Simple pop method that accepts a range instead of a single value. Modifies the original bytearray by removing items

        Note:
            Pops from the front of the list by default. If `front` is set to `False`, it
Severity: Minor
Found in bamnostic/core.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 get_ref has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_ref(self, ref_id=None, idx=False):
        """Interatively unpacks all the bins, linear intervals, and chunks for a given reference

        A reference is comprised of 2 things: 1) a series of bins that reference chunks of aligned
        reads that are grouped within that bin. 2) a series of virtual offsets of the first read of a
Severity: Minor
Found in bamnostic/bai.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_index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _init_index(self):
        """Initialize the index file (BAI)"""

        if self._check_idx:
            # self._index = bamnostic.bai.Bai(self._index_path)
Severity: Minor
Found in bamnostic/bam.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(split_field) > 2:
                            tag = split_field[0]
                            value = split_field[2]
                        else:
                            tag, value = split_field
Severity: Major
Found in bamnostic/bam.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if seg_qual[index] >= base_qual_thresh:
                            yield base, start_pos
                    else:
    Severity: Major
    Found in bamnostic/utils.py - About 45 mins to fix

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

      def _cross_check_header_refs(reads, header="", referencenames = None, referencelengths = None):
          """Modified code from Peter Cock's [BamWriter](https://github.com/peterjc/biopython/blob/SamBam2015/Bio/Sequencing/SamBam/__init__.py#L1714)
          """
          if not header:
              # If the reads argument is a SamIterator or BamIterator this works:
      Severity: Minor
      Found in bamnostic/bam.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 start <= index < stop:
                                  if base == 'A':
                                      adenine[index - start if index-start > 0 else 0] += 1
                                  elif base == 'G':
                                      guanine[index - start if index-start > 0 else 0] += 1
      Severity: Major
      Found in bamnostic/bam.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if qualities is not None:
                                if seg_qual[index] >= base_qual_thresh:
                                    yield base, start_pos
                            else:
                                yield base, start_pos
        Severity: Major
        Found in bamnostic/utils.py - About 45 mins to fix

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

              def get_ref(self, ref_id=None, idx=False):
                  """Iteratively unpacks all the bins, linear intervals, and chunks for a given reference
          
                  A reference is comprised of 2 things: 1) a series of bins that reference chunks of aligned
                  reads that are grouped within that bin. 2) a series of virtual offsets of the first read of a
          Severity: Minor
          Found in bamnostic/csi.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 md_changes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def md_changes(seq, md_tag):
              """Recreates the reference sequence of a given alignment to the extent that the
              MD tag can represent.
          
              Note:
          Severity: Minor
          Found in bamnostic/utils.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 reg2bins has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def reg2bins(rbeg, rend):
              """Generates bin ids which overlap the specified region.
          
              Args:
                  rbeg (int): inclusive beginning position of region
          Severity: Minor
          Found in bamnostic/bai.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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def update(self, others):
                  """ Same as a regular `dict.update`, however, since pypy's `dict.update`
                  doesn't go through `dict.__setitem__`, this is used to ensure it does
          
                  Args:
          Severity: Minor
          Found in bamnostic/utils.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 cigar_changes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def cigar_changes(seq, cigar):
              """Recreates the reference sequence to the extent that the CIGAR string can
                  represent.
          
              Args:
          Severity: Minor
          Found in bamnostic/utils.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
          Severity: Major
          Found in bamnostic/bam.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return
            Severity: Major
            Found in bamnostic/bam.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return data
              Severity: Major
              Found in bamnostic/bgzf.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return
                Severity: Major
                Found in bamnostic/bam.py - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language