-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) | ||
|
||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def import_metadata(metadata_file_path: str) -> pandas.DataFrame: | ||
""" | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def compute_variant_differences_for_naming(dataframe: pandas.DataFrame): | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def set_output_directory(output_dir_path: str, output_file_name: str) -> str: | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
variants.append([record.id, sequence_feature_temp]) | ||
|
||
dir_name, file_name = os.path.split(alignment_file_path) | ||
|
There was a problem hiding this comment.
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:use-any
)invert-any-all
)