File pharmgkb.py
has 338 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Transform for PharmGKB drug to drug target data."""
import logging
import os
import re
Function run
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def run(self, data_file: Optional[str] = None):
"""Run the transformation."""
rel_zip_file_name = os.path.join(self.input_base_dir, "relationships.zip")
relationship_file_name = "relationships.tsv"
gene_mapping_zip_file = os.path.join(self.input_base_dir, "pharmgkb_genes.zip")
- 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
Function make_preferred_drug_id
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def make_preferred_drug_id(
self,
pharmgkb_id: str,
drug_id_map: dict,
preferred_ids: dict,
- 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
Function make_id_mapping_file
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def make_id_mapping_file(
self,
map_file: str,
sep: str = "\t",
pharmgkb_id_col: str = "PharmGKB Accession Id",
- 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
Function make_id_mapping_file
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def make_id_mapping_file(
Avoid deeply nested control flow statements. Open
if entity_type == "Gene":
self.make_pharmgkb_gene_node(
fh=node,
this_id=entity_id,
name=entity_name,
Avoid deeply nested control flow statements. Open
if not item:
continue # not xrefs, skip
item = item.strip('"') # remove quotes around each item
Avoid deeply nested control flow statements. Open
if self.key_parsed_ids not in dat:
dat[self.key_parsed_ids] = dict()
dat[self.key_parsed_ids][key] = value
Function make_pharmgkb_chemical_node
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def make_pharmgkb_chemical_node(