ljyanesm/fa2tree

View on GitHub

Showing 12 of 12 total issues

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

                            if ( i%3 == 0 and (codon_option == 'codon1' or codon_option == 'codon12') ):
                                ww[file].write(c)
                                printed+=1
Severity: Major
Found in codon_from_fasta.py and 1 other location - About 2 hrs to fix
codon_from_fasta.py on lines 149..151

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 60.

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

                            if ( i%3 == 1 and (codon_option == 'codon2' or codon_option == 'codon12') ):
                                ww[file].write(c)
                                printed+=1
Severity: Major
Found in codon_from_fasta.py and 1 other location - About 2 hrs to fix
codon_from_fasta.py on lines 146..148

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 60.

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

Error: Missing parentheses in call to 'print'. Did you mean print(nt s.description)? (<unknown>, line 13)</unknown>
Open

   print s.description
Severity: Minor
Found in sort_fasta.py by radon

We encountered an error attempting to analyze this line.

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

            max_length = max([len(x["seq"]) for x in markers if x["ID"] == current_marker])
Severity: Major
Found in codon_from_fasta.py and 1 other location - About 1 hr to fix
codon_from_fasta.py on lines 139..139

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 41.

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

                longest_seq = max([len(x["seq"]) for x in markers if x["ID"] == current_marker])
Severity: Major
Found in codon_from_fasta.py and 1 other location - About 1 hr to fix
codon_from_fasta.py on lines 117..117

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 41.

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

            markers[counter]["ID"] = file.readline().replace('\r','').replace('\n', '')
Severity: Minor
Found in codon_from_fasta.py and 1 other location - About 45 mins to fix
codon_from_fasta.py on lines 69..69

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 35.

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

Avoid deeply nested control flow statements.
Open

                if info_percentage <= min_sequence: # Are all my samples complete? or at least with N percentage of information?
                    print("Sample", os.path.basename(opened_files[i]), "only has", str(round(100.0*info_percentage,2)), "% coverage for", m["ID"])
                    num_samples_low_coverage+=1
                    has_enough_coverage[i] = False
            # Check that this gene has enough information on at least N percent of the samples print it to the filtered output
Severity: Major
Found in codon_from_fasta.py - About 45 mins to fix

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

                markers[counter]["seq"] = file.readline().replace('\r','').replace('\n', '')
    Severity: Minor
    Found in codon_from_fasta.py and 1 other location - About 45 mins to fix
    codon_from_fasta.py on lines 68..68

    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 35.

    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

    Avoid deeply nested control flow statements.
    Open

                    for file, m in enumerate(markers):
                        if m["ID"] == current_marker:
                            # eprint("LIB ", opened_files[file], " contains gene ", current_marker)
                            m["seq"] = m["seq"].ljust(longest_seq, "N") # Pad the genes with ? for the lenght of unknowns
                            printed = 0
    Severity: Major
    Found in codon_from_fasta.py - About 45 mins to fix

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

      def read_markers(files, current_marker, markers):
          have_seqs = False
          for counter, file in enumerate(files):
              if (current_marker != markers[counter]["ID"] and current_marker != ""):
                  markers[counter]["seq"] = ""
      Severity: Minor
      Found in codon_from_fasta.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 (m["ID"] != current_marker):
                          num_samples_low_coverage+=1
                          has_enough_coverage[i] = False
                          print("File ", os.path.basename(opened_files[i]), " doesn't contain gene ", current_marker)
                          continue
      Severity: Major
      Found in codon_from_fasta.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if (len(m["seq"]) > 0):
                            info_percentage = 1.0 - m["seq"].count("N") / float(max_length)
                        else:
                            info_percentage = 0.0
                        if info_percentage <= min_sequence: # Are all my samples complete? or at least with N percentage of information?
        Severity: Major
        Found in codon_from_fasta.py - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language