Showing 5 of 12 total issues
Avoid deeply nested control flow statements. Open
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
Avoid deeply nested control flow statements. Open
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
Function read_markers
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
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"] = ""
- Read upRead up
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
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
Avoid deeply nested control flow statements. Open
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?