Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Sep 3, 2021
1 parent 05431be commit 331b255
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions FeaVar/FeaVar.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,11 @@ def confirm_seq_feature_in_ref(reference_sequence: str, sequence_feature_positio
A list of the positions (as integers) of the variant type in the sequence feature
"""

test = True

raw_sequence = reference_sequence.replace("-", "")

length = len(raw_sequence)

for position in sequence_feature_positions:

if position > length:
test = False
test = all(position <= length for position in sequence_feature_positions)

logging.debug('Confirm seq feature in reference tests result: {}'.format(test))

Expand All @@ -245,23 +240,14 @@ def check_reference_positions(reference_sequence: str, positions: list) -> bool:

seq_length = len(reference_sequence)

test = True

# check that all positions are in sequence

if all(i <= seq_length for i in positions):

for position in positions:

if reference_sequence[position - 1] == "-":
test = False

return test

else:
if any(i > seq_length for i in positions):

return False

return all(reference_sequence[position - 1] != "-" for position in positions)


def import_metadata(metadata_file_path: str) -> pandas.DataFrame:
"""
Expand All @@ -283,9 +269,7 @@ def import_metadata(metadata_file_path: str) -> pandas.DataFrame:


def vt_count(i):
vt_id = "VT-%03d" % (i,)

return vt_id
return "VT-%03d" % (i,)


def compute_variant_differences_for_naming(dataframe: pandas.DataFrame):
Expand Down Expand Up @@ -363,8 +347,7 @@ def select_var_types_to_plot(df: pandas.DataFrame, count: int) -> pandas.DataFra
"""

vts_to_select = ["VT-%03d" % i for i in range(count)]
df_selected = df[df['VT'].isin(vts_to_select)]
return df_selected
return df[df['VT'].isin(vts_to_select)]


def set_output_directory(output_dir_path: str, output_file_name: str) -> str:
Expand Down Expand Up @@ -447,7 +430,7 @@ def compute_variant_types(alignment_file_path: str, alignment_format: str, vt_po
variants = []
for record in alignment:
sequence = record.seq
sequence_feature_temp = ''.join([sequence[index] for index in vt_positions])
sequence_feature_temp = ''.join(sequence[index] for index in vt_positions)
variants.append([record.id, sequence_feature_temp])

dir_name, file_name = os.path.split(alignment_file_path)
Expand Down

0 comments on commit 331b255

Please sign in to comment.