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 #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented May 11, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from vidboda May 11, 2023 08:38
Comment on lines -94 to +103
pubmed_info[pmid] = {}
pubmed_info[pmid]['title'] = article['title']
pubmed_info[pmid]['journal'] = article['journal']
pubmed_info[pmid]['year'] = article['year']
pubmed_info[pmid]['author'] = article['authors'][0]
pubmed_info[pmid] = {
'title': article['title'],
'journal': article['journal'],
'year': article['year'],
'author': article['authors'][0],
}
except Exception:
for pubmed_id in litvar_data[0]['pmids']:
pmid = int(pubmed_id)
pubmed_info[pmid] = {}
pubmed_info[pmid]['title'] = ''
pubmed_info[pmid] = {'title': ''}
Copy link
Author

Choose a reason for hiding this comment

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

Function litvar refactored with the following changes:

Comment on lines -121 to +122
match_rsid = re.search(r'^(rs\d+)$', request.form['rsid'])
if match_rsid:
rsid = match_rsid.group(1)
if match_rsid := re.search(r'^(rs\d+)$', request.form['rsid']):
rsid = match_rsid[1]
Copy link
Author

Choose a reason for hiding this comment

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

Function litvar2 refactored with the following changes:

variant_id = match_varid.group(1)
variant_id = match_varid[1]
# genome = request.form['genome']
genome = match_genome.group(1)
genome = match_genome[1]
Copy link
Author

Choose a reason for hiding this comment

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

Function defgen refactored with the following changes:

Comment on lines -346 to +355
genome = match_genome.group(1)
chrom = match_nochr_chrom.group(1)
pos = match_pos.group(1)
ref = match_ref.group(1)
alt = match_alt.group(1)
gene = match_gene_symbol.group(1)
genome = match_genome[1]
chrom = match_nochr_chrom[1]
pos = match_pos[1]
ref = match_ref[1]
alt = match_alt[1]
gene = match_gene_symbol[1]
Copy link
Author

Choose a reason for hiding this comment

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

Function intervar refactored with the following changes:

This removes the following comments ( why? ):

# print(obj)

vv_url = md_utilities.get_vv_api_url()
if vv_url:
if vv_url := md_utilities.get_vv_api_url():
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_vv_instance refactored with the following changes:

external_tools['ClinVar']['version'] = 'v{}'.format(
clinvar_version
)
external_tools['ClinGenSpecificationRegistry']['version'] = 'v{}'.format(
clingen_version
)
external_tools['OncoKBGenes']['version'] = 'v{}'.format(
oncokb_genes_version
)
external_tools['ClinVar']['version'] = f'v{clinvar_version}'
external_tools['ClinGenSpecificationRegistry'][
'version'
] = f'v{clingen_version}'
external_tools['OncoKBGenes']['version'] = f'v{oncokb_genes_version}'
Copy link
Author

Choose a reason for hiding this comment

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

Lines 190-198 refactored with the following changes:

Comment on lines -233 to +228
match_obj = re.search(r'^(.+d[eu][lp])[ATCG]+$', variant)
if match_obj:
variant = match_obj.group(1)
else:
match_obj = re.search(r'^(.+del)[ATCG]+(ins[ACTG])$', variant)
if match_obj:
variant = match_obj.group(1) + match_obj.group(2)
if match_obj := re.search(r'^(.+d[eu][lp])[ATCG]+$', variant):
variant = match_obj[1]
elif match_obj := re.search(r'^(.+del)[ATCG]+(ins[ACTG])$', variant):
variant = match_obj[1] + match_obj[2]
Copy link
Author

Choose a reason for hiding this comment

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

Function clean_var_name refactored with the following changes:

Comment on lines -245 to +255
match_object = re.search(r'^(\w{3})(\d+)(\w{3}|[X\*=])$', var)
if match_object:
if re.search('d[ue][pl]', match_object.group(3)):
return three2one[match_object.group(1).capitalize()] + \
match_object.group(2) + \
match_object.group(3)
if match_object := re.search(r'^(\w{3})(\d+)(\w{3}|[X\*=])$', var):
if re.search('d[ue][pl]', match_object[3]):
return (
three2one[match_object[1].capitalize()]
+ match_object[2]
+ match_object[3]
)
else:
return three2one[match_object.group(1).capitalize()] + \
match_object.group(2) + \
three2one[match_object.group(3).capitalize()]
match_object = re.search(r'^(\w{3})(\d+_)(\w{3})(\d+.+)$', var)
if match_object:
return three2one[match_object.group(1)].capitalize() + \
match_object.group(2) + \
three2one[match_object.group(3)].capitalize() + \
match_object.group(4)
match_object = re.search(r'^(\w{3})(\d+)\w{3}fsTer\d+$', var)
if match_object:
return three2one[match_object.group(1)].capitalize() + \
match_object.group(2) + \
'fs'
return (
three2one[match_object[1].capitalize()]
+ match_object[2]
+ three2one[match_object[3].capitalize()]
)
if match_object := re.search(r'^(\w{3})(\d+_)(\w{3})(\d+.+)$', var):
return (
three2one[match_object[1]].capitalize()
+ match_object[2]
+ three2one[match_object[3]].capitalize()
+ match_object[4]
)
if match_object := re.search(r'^(\w{3})(\d+)\w{3}fsTer\d+$', var):
return three2one[match_object[1]].capitalize() + match_object[2] + 'fs'
Copy link
Author

Choose a reason for hiding this comment

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

Function three2one_fct refactored with the following changes:

Comment on lines -271 to +279
match_object = re.search(r'^(\w{1})(\d+)([\w\*=]{1})$', var)
if match_object:
return one2three[match_object.group(1).capitalize()] + \
match_object.group(2) + \
one2three[match_object.group(3).capitalize()]
match_object = re.search(r'^(\w{1})(\d+)(d[ue][pl])$', var)
if match_object:
return one2three[match_object.group(1).capitalize()] + \
match_object.group(2) + \
match_object.group(3)
match_object = re.search(r'^(\w{1})(\d+_)(\w{1})(\d+.+)$', var)
if match_object:
return one2three[match_object.group(1).capitalize()] + \
match_object.group(2) + \
one2three[match_object.group(3).capitalize()] + \
match_object.group(4)
if match_object := re.search(r'^(\w{1})(\d+)([\w\*=]{1})$', var):
return (
one2three[match_object[1].capitalize()]
+ match_object[2]
+ one2three[match_object[3].capitalize()]
)
if match_object := re.search(r'^(\w{1})(\d+)(d[ue][pl])$', var):
return (
one2three[match_object[1].capitalize()]
+ match_object[2]
+ match_object[3]
)
if match_object := re.search(r'^(\w{1})(\d+_)(\w{1})(\d+.+)$', var):
return (
one2three[match_object[1].capitalize()]
+ match_object[2]
+ one2three[match_object[3].capitalize()]
+ match_object[4]
)
Copy link
Author

Choose a reason for hiding this comment

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

Function one2three_fct refactored with the following changes:

Comment on lines -294 to +287
short_chr = get_short_chr_name(chr_name)
if short_chr:
if short_chr := get_short_chr_name(chr_name):
Copy link
Author

Choose a reason for hiding this comment

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

Function get_ncbi_chr_name refactored with the following changes:

This removes the following comments ( why? ):

# print(ncbi_name)

Comment on lines -324 to +314
res = curs.fetchone()
if res:
if res := curs.fetchone():
Copy link
Author

Choose a reason for hiding this comment

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

Function get_common_chr_name refactored with the following changes:

Comment on lines -332 to +321
if re.search(rf'^[Cc][Hh][Rr]({nochr_captured_regexp})$', chr_name):
return True
return False
return bool(re.search(rf'^[Cc][Hh][Rr]({nochr_captured_regexp})$', chr_name))
Copy link
Author

Choose a reason for hiding this comment

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

Function is_valid_full_chr refactored with the following changes:

Comment on lines -343 to +330
return match_obj.group(1)
return match_obj[1]
Copy link
Author

Choose a reason for hiding this comment

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

Function get_short_chr_name refactored with the following changes:

Comment on lines -348 to +335
if re.search(rf'^({nochr_captured_regexp})$', chr_name):
return True
return False
return bool(re.search(rf'^({nochr_captured_regexp})$', chr_name))
Copy link
Author

Choose a reason for hiding this comment

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

Function is_valid_chr refactored with the following changes:

Comment on lines -354 to +339
if re.search(r'^[Nn][Cc]_0000\d{2}\.\d{1,2}$', chr_name):
return True
return False
return bool(re.search(r'^[Nn][Cc]_0000\d{2}\.\d{1,2}$', chr_name))
Copy link
Author

Choose a reason for hiding this comment

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

Function is_valid_ncbi_chr refactored with the following changes:

Comment on lines -664 to +627
return 'Match failed in {}'.format(text)
return f'Match failed in {text}'
Copy link
Author

Choose a reason for hiding this comment

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

Function get_value_from_tabix_file refactored with the following changes:

Comment on lines -715 to +681
match_obj = re.search(r'^([A-Z][a-z]{2})(\d+)([A-Z][a-z]{2})$', p_name)
if match_obj:
return three2one[match_obj.group(1)], match_obj.group(2), three2one[match_obj.group(3)]
if match_obj := re.search(
r'^([A-Z][a-z]{2})(\d+)([A-Z][a-z]{2})$', p_name
):
return three2one[match_obj[1]], match_obj[2], three2one[match_obj[3]]
Copy link
Author

Choose a reason for hiding this comment

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

Function decompose_missense refactored with the following changes:

Comment on lines -729 to +696
score = re.split(
'{}'.format(sep), dbnsfp_record[score_index]
)[transcript_index]
score = re.split(f'{sep}', dbnsfp_record[score_index])[transcript_index]
if pred_index != score_index:
pred = predictors_translations[translation_mode][
re.split(
'{}'.format(sep),
dbnsfp_record[pred_index]
)[transcript_index]
re.split(f'{sep}', dbnsfp_record[pred_index])[transcript_index]
Copy link
Author

Choose a reason for hiding this comment

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

Function getdbNSFP_results refactored with the following changes:

Comment on lines -777 to +747
# returns most deleterious score of predictors
# when not found in desired transcript
j = 0
k = 0
best_score = threshold
for score in re.split(';', score):
for j, score in enumerate(re.split(';', score)):
if direction == 'lt':
if score != '.' and \
float(score) < float(best_score):
best_score = score
k = j
else:
if score != '.' and \
elif score != '.' and \
float(score) > float(best_score):
best_score = score
k = j
j += 1
best_score = score
k = j
Copy link
Author

Choose a reason for hiding this comment

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

Function get_most_other_deleterious_pred refactored with the following changes:

This removes the following comments ( why? ):

# when not found in desired transcript
# returns most deleterious score of predictors

Comment on lines -803 to +757
value = float(val)
if predictor == 'sift':
value = 1-(float(val))
value = 1-(float(val)) if predictor == 'sift' else float(val)
Copy link
Author

Choose a reason for hiding this comment

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

Function get_preditor_single_threshold_color refactored with the following changes:

Comment on lines -871 to +829
return match_object.group(1)
else:
match_object = re.search(r'_(\d+)[di]', g_name)
if match_object is not None:
return match_object.group(1)
else:
# case of single nt dels ins dup
match_object = re.search(r'^(\d+)[d]', g_name)
if match_object is not None:
return match_object.group(1)
return None
return match_object[1]
match_object = re.search(r'_(\d+)[di]', g_name)
if match_object is not None:
return match_object[1]
# case of single nt dels ins dup
match_object = re.search(r'^(\d+)[d]', g_name)
return match_object[1] if match_object is not None else None
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_pos_end refactored with the following changes:

Comment on lines -889 to +846
return match_object.group(1), match_object.group(2)
else:
match_object = re.search(r'^(\d+)[ATGC]>', name)
if match_object is not None:
return match_object.group(1), match_object.group(1)
else:
# single nt del or delins
match_object = re.search(r'^(\d+)[d]', name)
if match_object is not None:
return match_object.group(1), match_object.group(1)
else:
return match_object[1], match_object[2]
match_object = re.search(r'^(\d+)[ATGC]>', name)
if match_object is not None:
return match_object[1], match_object[1]
# single nt del or delins
match_object = re.search(r'^(\d+)[d]', name)
if match_object is not None:
return match_object[1], match_object[1]
# case where NM wt disagree with genomic wt
if re.search(r'^\d+=', name):
return '-1', '-1'
return None, None
return ('-1', '-1') if re.search(r'^\d+=', name) else (None, None)
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_start_end_pos refactored with the following changes:

Comment on lines -907 to +850
begin_txt = 'VariantValidator error: '
if var == '':
begin_txt = ''
begin_txt = '' if var == '' else 'VariantValidator error: '
Copy link
Author

Choose a reason for hiding this comment

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

Function danger_panel refactored with the following changes:

Comment on lines -919 to +860
# to print general info do not send var neither id_var
# Newly created variant:
c = 'c.'
if re.search(r'N[MR]_', var):
c = ''
c = '' if re.search(r'N[MR]_', var) else 'c.'
Copy link
Author

Choose a reason for hiding this comment

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

Function info_panel refactored with the following changes:

This removes the following comments ( why? ):

# Newly created variant:
# to print general info do not send var neither id_var

Comment on lines -967 to -990
if checked_url:
return checked_url
else:
if not checked_url:
checked_url = test_vv_api_url(
urls['variant_validator_api_hello'],
urls['variant_validator_api']
)
return checked_url
return checked_url
else:
# the other way around
checked_url = test_vv_api_url(
urls['variant_validator_api_hello'],
urls['variant_validator_api']
)
if checked_url:
if checked_url := test_vv_api_url(
urls['variant_validator_api_hello'], urls['variant_validator_api']
):
return checked_url
if checked_url := test_vv_api_url(
urls['variant_validator_api_hello_backup'],
urls['variant_validator_api_backup'],
):
return checked_url
else:
checked_url = test_vv_api_url(
urls['variant_validator_api_hello_backup'],
urls['variant_validator_api_backup']
)
if checked_url:
return checked_url
else:
Copy link
Author

Choose a reason for hiding this comment

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

Function get_vv_api_url refactored with the following changes:

This removes the following comments ( why? ):

# the other way around

assert client.get(
'/auth/variant_list/{}'.format(
list_name,
)
).status_code == http_code
assert client.get(f'/auth/variant_list/{list_name}').status_code == http_code
Copy link
Author

Choose a reason for hiding this comment

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

Function test_variant_list refactored with the following changes:

assert client.get('/gene/{}'.format(name[0])).status_code == 200
assert client.get(f'/gene/{name[0]}').status_code == 200
Copy link
Author

Choose a reason for hiding this comment

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

Function test_gene_page refactored with the following changes:

Comment on lines -100 to +101
print(response.headers['Location'] + 'http://localhost/{}'.format(url))
assert 'http://localhost/{}'.format(url) == response.headers['Location']
print(response.headers['Location'] + f'http://localhost/{url}')
assert f'http://localhost/{url}' == response.headers['Location']
Copy link
Author

Choose a reason for hiding this comment

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

Function test_search_engine refactored with the following changes:

assert client.get('/api/variant/{}/browser/'.format(variant_id[0])).status_code == 200
assert client.get(f'/api/variant/{variant_id[0]}/browser/').status_code == 200
Copy link
Author

Choose a reason for hiding this comment

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

Function test_variant_page refactored with the following changes:

print('-{}'.format(totest))
print(f'-{totest}')
Copy link
Author

Choose a reason for hiding this comment

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

Function test_format_mirs refactored with the following changes:

if match_obj:
password = match_obj.group(1)
if match_obj := re.search(
r'(?!^[0-9]*$)(?!^[a-z]*$)(?!^[A-Z]*$)(?!^[a-zA-Z]*$)(?!^[a-z0-9]*$)(?!^[A-Z0-9]*$)^(.{8,})$',

Check failure

Code scanning / CodeQL

Unmatchable dollar in regular expression Error

This regular expression includes an unmatchable dollar at offset 10.
This regular expression includes an unmatchable dollar at offset 22.
This regular expression includes an unmatchable dollar at offset 34.
This regular expression includes an unmatchable dollar at offset 49.
This regular expression includes an unmatchable dollar at offset 64.
This regular expression includes an unmatchable dollar at offset 79.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants