Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored master branch #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Comment on lines -215 to +219
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function confirm_seq_feature_in_ref refactored with the following changes:


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)
Comment on lines -248 to +249
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function check_reference_positions refactored with the following changes:



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,)
Comment on lines -286 to +272
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function vt_count refactored with the following changes:



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)]
Comment on lines -366 to +350
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function select_var_types_to_plot refactored with the following changes:



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)
Comment on lines -450 to +433
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function compute_variant_types refactored with the following changes:

variants.append([record.id, sequence_feature_temp])

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