KarrLab/bpforms

View on GitHub

Showing 397 of 397 total issues

File core.py has 3761 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Classes to represent modified forms of DNA, RNA, and proteins

:Author: Jonathan Karr <karr@mssm.edu>
:Date: 2019-01-31
:Copyright: 2019, Karr Lab
Severity: Major
Found in bpforms/core.py - About 1 wk to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                with gzip.GzipFile(fileobj=f, mode='rb') as gz:
    
                    line = gz.readline().decode('utf-8').strip()
    
                    while line != '':
    Severity: Major
    Found in examples/pdb_analysis.py and 1 other location - About 3 days to fix
    examples/pdb_analysis.py on lines 379..425

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 405.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                    with gzip.open(f, 'rb') as gz:
    
                        line = gz.readline().decode('utf-8').strip()
    
                        while line != '':
    Severity: Major
    Found in examples/pdb_analysis.py and 1 other location - About 3 days to fix
    examples/pdb_analysis.py on lines 264..310

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 405.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                if monomer is None:
                    # add the entry to the alphabet
                    alphabet.monomers[pdb_monomer.id] = pdb_monomer
                    if base_monomer is not None:
                        base_monomers[pdb_monomer] = base_monomer
    Severity: Major
    Found in bpforms/alphabet/dna.py and 1 other location - About 3 days to fix
    bpforms/alphabet/rna.py on lines 811..851

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 386.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                if monomer is None:
                    # add the entry to the alphabet
                    alphabet.monomers[pdb_monomer.id] = pdb_monomer
                    if base_monomer is not None:
                        base_monomers[pdb_monomer] = base_monomer
    Severity: Major
    Found in bpforms/alphabet/rna.py and 1 other location - About 3 days to fix
    bpforms/alphabet/dna.py on lines 661..701

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 386.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function gen_bpform has a Cognitive Complexity of 163 (exceeds 5 allowed). Consider refactoring.
    Open

    def gen_bpform(protein, pro_ids_to_bpform_monomers, monomer_codes,
                   apply_processing=True, apply_modifications=True, include_annotations=True):
        """ Generate BpForm for a modified protein in PRO
    
        Args:
    Severity: Minor
    Found in examples/pro.py - About 3 days 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 build_rna_mod_db has a Cognitive Complexity of 116 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_rna_mod_db(self, alphabet, session, ph=None, major_tautomer=False, dearomatize=False):
            """ Build alphabet from the RNA Modification Database
    
            Args:
                alphabet (:obj:`Alphabet`): alphabet
    Severity: Minor
    Found in bpforms/alphabet/rna.py - About 2 days 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 build_pdb has a Cognitive Complexity of 114 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_pdb(self, alphabet, session, ph=None, major_tautomer=False, dearomatize=False):
            """ Build monomeric forms from PDB CCD
    
            Args:
                alphabet (:obj:`Alphabet`): alphabet
    Severity: Minor
    Found in bpforms/alphabet/rna.py - About 2 days 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 build_pdb_ccd has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_pdb_ccd(self, alphabet, ph=None, major_tautomer=False, dearomatize=False):
            """ Build monomeric forms from PDB CCD
    
            Args:
                alphabet (:obj:`Alphabet`): alphabet
    Severity: Minor
    Found in bpforms/alphabet/dna.py - About 2 days 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 validate has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self):
            """ Check that the biopolymer form is valid and return any errors
    
            * Check that monomeric forms :math:`1 \ldots L-1` can bond to the right (their right bonding attributes are set)
            * Check that monomeric forms :math:`2 \ldots L` can bond to the left (their left bonding attributes are set)
    Severity: Minor
    Found in bpforms/core.py - About 2 days 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

    File rna.py has 912 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """ Alphabet and BpForm to represent modified RNA
    
    :Author: Jonathan Karr <karr@mssm.edu>
    :Date: 2019-02-05
    :Copyright: 2019, Karr Lab
    Severity: Major
    Found in bpforms/alphabet/rna.py - About 2 days to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          for x_link in sorted_x_links:
              if prev_vert and x_link['l_polymer_col'] == x_link['r_polymer_col'] and \
                      x_link['l_pos'] == x_link['r_pos'] and \
                      x_link['l_polymer_col'] == prev_col and \
                      x_link['l_pos'] == prev_pos and \
      Severity: Major
      Found in bpforms/util.py and 1 other location - About 2 days to fix
      bpforms/util.py on lines 590..606

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 239.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          for x_link in sorted_x_links:
              if prev_horz and x_link['l_polymer_row'] == x_link['r_polymer_row'] and \
                      x_link['l_track'] == x_link['r_track'] and \
                      x_link['l_polymer_row'] == prev_row and \
                      x_link['l_track'] == prev_track and \
      Severity: Major
      Found in bpforms/util.py and 1 other location - About 2 days to fix
      bpforms/util.py on lines 620..636

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 239.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function from_str has a Cognitive Complexity of 102 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_str(self, string):
              """ Create biopolymer form its string representation
      
              Args:
                  string (:obj:`str`): string representation of the biopolymer
      Severity: Minor
      Found in bpforms/core.py - About 2 days 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 load_pdb_from_local has a Cognitive Complexity of 98 (exceeds 5 allowed). Consider refactoring.
      Open

      def load_pdb_from_local(max_entries):
          """ read the PDB database and parse the entries from local directory
      
          """
          # get amino acid set (canonical and non-canonical) from bpforms
      Severity: Minor
      Found in examples/pdb_analysis.py - About 1 day 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 run has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
      Open

      def run(in_obo_filename=IN_OBO_FILENAME, in_pkl_filename=IN_PKL_FILENAME, in_tsv_filename=IN_TSV_FILELANE,
              in_monomers_filename=IN_MONOMERS_FILENAME,
              max_num_proteins=None,
              out_pickle_filename=OUT_PICKLE_FILENAME, out_pickle_filename_2=OUT_PICKLE_FILENAME_2,
              out_tsv_filename=OUT_TSV_FILENAME, out_fasta_filename=OUT_FASTA_FILENAME,
      Severity: Minor
      Found in examples/pro.py - About 1 day 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 build_from_pdb has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_from_pdb(self, alphabet, ph=None, major_tautomer=False, dearomatize=False):
              """ Build alphabet from `PDB Chemical Component Dictionary <http://www.wwpdb.org/data/ccd>`_
      
              Args:
                  alphabet (:obj:`Alphabet`): alphabet
      Severity: Minor
      Found in bpforms/alphabet/protein.py - About 1 day 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 gen_genomic_viz has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
      Open

      def gen_genomic_viz(polymers, inter_crosslinks=None, polymer_labels=None, seq_features=None,
                          width=800, cols=1, polymer_margin=25,
                          nt_per_track=100, track_sep=10,
                          polymer_label_font_size=15, seq_font_size=13, tick_label_font_size=10,
                          legend_font_size=13, tooltip_font_size=13,
      Severity: Minor
      Found in bpforms/util.py - About 1 day 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

      File util.py has 778 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """ Utilities for BpForms
      
      :Author: Jonathan Karr <karr@mssm.edu>
      :Date: 2019-02-05
      :Copyright: 2019, Karr Lab
      Severity: Major
      Found in bpforms/util.py - About 1 day to fix

        File protein.py has 765 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """ Alphabet and BpForm to represent modified proteins
        
        :Author: Jonathan Karr <karr@mssm.edu>
        :Date: 2019-02-05
        :Copyright: 2019, Karr Lab
        Severity: Major
        Found in bpforms/alphabet/protein.py - About 1 day to fix
          Severity
          Category
          Status
          Source
          Language