Skip to content

Commit

Permalink
added documentation and removed test readouts
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinDo committed Aug 20, 2024
1 parent cdbcee8 commit d24364b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 59 deletions.
19 changes: 2 additions & 17 deletions src/common/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def load_webapp_env():
return webapp_env

# converts one line from the variant table to a vcf record
def variant_to_vcf(chr, pos, ref, alt, path):
def variant_to_vcf(chr, pos, ref, alt, path, reference_genome="GRCh38"):
#CHROM POS ID REF ALT QUAL FILTER INFO
chr_num = validate_chr(chr)
if not chr_num:
Expand All @@ -46,7 +46,7 @@ def variant_to_vcf(chr, pos, ref, alt, path):
vcf_record = [chr, str(pos), '.', str(ref), str(alt), '.', '.', '.']

file = open(path, "w")
write_vcf_header(["##contig=<ID=%s>"%chr], output_func = file.write, tail = "\n")
write_vcf_header(["##contig=<ID=%s>"%chr], output_func = file.write, tail = "\n", reference_genome=reference_genome)
file.write('\t'.join(vcf_record) + '\n')
file.close()
return True
Expand Down Expand Up @@ -203,11 +203,6 @@ def preprocess_variant(infile, do_liftover=False):
if returncode != 0: return returncode, err_msg, command_output
returncode, err_msg, command_output = execute_command(["mv", infile + ".leftnormalized", infile], "mv")
if returncode != 0: return returncode, err_msg, command_output
print("GRCH37 LEFTNORMALIZE:")
with open(infile, "r") as f:
for line in f:
if not line.startswith('##contig='):
print(f.read())
# check
returncode, err_msg, vcf_errors_pre = check_vcf(infile, ref_genome="GRCh37")
if vcf_errors_pre != '': return 1, err_msg + " " + vcf_errors_pre, command_output
Expand All @@ -223,11 +218,6 @@ def preprocess_variant(infile, do_liftover=False):
if returncode != 0: return returncode, err_msg, command_output
returncode, err_msg, command_output = execute_command(["mv", infile + ".lifted", infile], "mv")
if returncode != 0: return returncode, err_msg, command_output
print("LIFTED FILE:")
with open(infile, "r") as f:
for line in f:
if not line.startswith('##contig='):
print(f.read())

# leftnormalize
returncode, err_msg, command_output = left_align_vcf(infile, outfile= infile + ".leftnormalized", ref_genome="GRCh38")
Expand All @@ -236,11 +226,6 @@ def preprocess_variant(infile, do_liftover=False):
if returncode != 0: return returncode, err_msg, command_output
returncode, err_msg, command_output = execute_command(["mv", infile + ".leftnormalized", infile], "mv")
if returncode != 0: return returncode, err_msg, command_output
print("GRCH38 LEFTNORMALIZE:")
with open(infile, "r") as f:
for line in f:
if not line.startswith('##contig='):
print(f.read())
# check
returncode, err_msg, vcf_errors_pre = check_vcf(infile, ref_genome="GRCh38")
if vcf_errors_pre != '': return 1, err_msg + " " + vcf_errors_pre, command_output
Expand Down
1 change: 0 additions & 1 deletion src/frontend_celery/start_celery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ pwd


source .venv/bin/activate
echo $(which python)
export WEBAPP_ENV=$we
vep_install_dir=$ROOT/tools/ensembl-vep-release-107.0
cpan_dir=$vep_install_dir/cpan
Expand Down
37 changes: 13 additions & 24 deletions src/frontend_celery/webapp/download/download_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,44 +780,30 @@ def get_possible_classes_enigma_pms2_100(class_counts):



def get_possible_classes_enigma_mlh_100(class_counts):



def get_possible_classes_enigma_insight_mmr_100(class_counts):
possible_classes = set()

# pathogenic
#1 Very Strong (PVS1) AND ≥ 1 Strong (PVS1_Strong, PS1, PS2, PS3, PP1_Strong, PP3_Strong, PP4_Strong)
#1 Very Strong (PVS1) AND ≥ 2 Supporting (PS3_Supporting, PM2_Supporting, PM5_Supporting, PP1, PP3, PP4)
#USELESS: 1 Very Strong (PVS1) AND 1 Moderate (PVS1_Moderate, PS1_Moderate, PS2_Moderate, PS3_Moderate, PM3, PM5, PM6, PP1_Moderate, PP3_Moderate, PP4_Moderate)
#1 Very Strong (PVS1) AND ≥ 1 Moderate (PVS1_Moderate, PS1_Moderate, PS2_Moderate, PS3_Moderate, PM3, PM5, PM6, PP1_Moderate, PP3_Moderate, PP4_Moderate)

#≥ 2 Strong (PVS1_Strong, PS1, PS2, PS3, PP1_Strong, PP3_Strong, PP4_Strong)
#1 Strong (PVS1_Strong, PS1, PS2, PS3, PP1_Strong, PP3_Strong, PP4_Strong) AND ≥ 3 Moderate (PVS1_Moderate, PS1_Moderate, PS2_Moderate, PS3_Moderate, PM3, PM5, PM6, PP1_Moderate, PP3_Moderate, PP4_Moderate)
#1 Strong (PVS1_Strong, PS1, PS2, PS3, PP1_Strong, PP3_Strong, PP4_Strong) AND 2 Moderate (PVS1_Moderate, PS1_Moderate, PS2_Moderate, PS3_Moderate, PM3, PM5, PM6, PP1_Moderate, PP3_Moderate, PP4_Moderate) AND ≥ 2 Supporting (PS3_Supporting, PM2_Supporting, PM5_Supporting, PP1, PP3, PP4)
#1 Strong (PVS1_Strong, PS1, PS2, PS3, PP1_Strong, PP3_Strong, PP4_Strong) AND 1 Moderate (PVS1_Moderate, PS1_Moderate, PS2_Moderate, PS3_Moderate, PM3, PM5, PM6, PP1_Moderate, PP3_Moderate, PP4_Moderate) AND ≥ 4 Supporting (PS3_Supporting, PM2_Supporting, PM5_Supporting, PP1, PP3, PP4)

if class_counts['pvs'] >= 2:
possible_classes.add(5)
if class_counts['pvs'] == 1:
if class_counts['ps'] >= 1 or class_counts['pm'] >= 1 or class_counts['pp'] >= 2:
possible_classes.add(5)
if class_counts['ps'] >= 2:
if class_counts['ps'] >= 3:
possible_classes.add(5)
if class_counts['ps'] == 1:
if class_counts['pm'] >= 3 or (class_counts['pm'] == 2 and class_counts['pp'] >= 2) or (class_counts['pm'] == 1 and class_counts['pp'] >= 4):
possible_classes.add(5)

#Likely Pathogenic
#1 Strong (PVS1_Strong, PS1, PS2, PS3, PP1_Strong, PP4_Strong) AND 1 Moderate (PVS1_Moderate, PS1_Moderate, PS2_Moderate, PS3_Moderate, PM3, PM5, PM6, PP1_Moderate, PP3_Moderate, PP4_Moderate)
#1 Strong (PVS1_Strong, PS1, PS2, PS3, PP1_Strong, PP4_Strong) AND ≥ 2 Supporting (PS3_Supporting, PM2_Supporting, PM5_Supporting, PP1, PP3, PP4)
#1 Strong (PVS1_Strong, PS1, PS2, PS3, PP1_Strong, PP4_Strong) AND 2 Moderate (PVS1_Moderate, PS1_Moderate, PS2_Moderate, PS3_Moderate, PM3, PM5, PM6, PP1_Moderate, PP3_Moderate, PP4_Moderate)

#≥ 3 Moderate (PVS1_Moderate, PS1_Moderate, PS2_Moderate, PS3_Moderate, PM3, PM5, PM6, PP1_Moderate, PP3_Moderate, PP4_Moderate)
#2 Moderate (PVS1_Moderate, PS1_Moderate, PS2_Moderate, PS3_Moderate, PM3, PM5, PM6, PP1_Moderate, PP3_Moderate, PP4_Moderate) AND ≥ 2 Supporting (PS3_Supporting, PM2_Supporting, PM5_Supporting, PP1, PP3, PP4)
#1 Moderate (PVS1_Moderate, PS1_Moderate, PS2_Moderate, PS3_Moderate, PM3, PM5, PM6, PP1_Moderate, PP3_Moderate, PP4_Moderate) AND ≥ 4 Supporting (PS3_Supporting, PM2_Supporting, PM5_Supporting, PP1, PP3, PP4)

#1 Very Strong (PVS1) AND 1 Supporting (PS3_Supporting, PM2_Supporting, PM5_Supporting, PP1, PP3, PP4)
if class_counts['ps'] == 1:
if (class_counts['pm'] >= 1 and class_counts['pm'] <= 2) or class_counts['pp'] >= 2:
possible_classes.add(4)
if class_counts['ps'] == 2:
possible_classes.add(4)
if class_counts['pm'] >= 3:
possible_classes.add(4)
if class_counts['pm'] == 2 and class_counts['pp'] >= 2:
Expand All @@ -828,22 +814,25 @@ def get_possible_classes_enigma_mlh_100(class_counts):
possible_classes.add(4)

#Benign
#≥ 2 Strong (BS1, BS2, BS3, BS4, BP5_Strong)
#1 Stand Alone (BA1, BS1_Stand Alone)
if class_counts['ba'] >= 1:
possible_classes.add(1)
if class_counts['bs'] >= 2:
possible_classes.add(1)

#Likely Benign
#1 Strong (BS1, BS2, BS3, BS4, BP5_Strong) AND 1 Supporting (BS3_Supporting, BS4_Supporting, BP4, BP5, BP7)
if class_counts['bs'] == 1 and class_counts['bp'] == 1:
possible_classes.add(2)
if class_counts['bp'] >= 2:
possible_classes.add(1)

return possible_classes







#######################################
########### DECISION MAKING ###########
#######################################
Expand Down
27 changes: 13 additions & 14 deletions src/frontend_celery/webapp/download/download_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,30 +200,29 @@ def calculate_class(scheme_type = None, version = None, selected_classes = ''):
elif 'acmg' in scheme_type:
class_counts = download_functions.get_class_counts(selected_classes) # count how often we have each strength

# get a set of possible classes depending on selected criteria depending on the gene and version
if 'brca1' in scheme_type and version == "v1.0.0":
possible_classes = download_functions.get_possible_classes_enigma_brca1_1_0_0(class_counts) # get a set of possible classes depending on selected criteria
possible_classes = download_functions.get_possible_classes_enigma_brca1_1_0_0(class_counts)
elif 'brca1' in scheme_type and version == "v1.1.0":
possible_classes = download_functions.get_possible_classes_enigma_brca12_1_1_0(class_counts) # get a set of possible classes depending on selected criteria
possible_classes = download_functions.get_possible_classes_enigma_brca12_1_1_0(class_counts)
elif 'brca2' in scheme_type and version == "v1.0.0":
possible_classes = download_functions.get_possible_classes_enigma_brca2_1_0_0(class_counts) # get a set of possible classes depending on selected criteria
possible_classes = download_functions.get_possible_classes_enigma_brca2_1_0_0(class_counts)
elif 'brca2' in scheme_type and version == "v1.1.0":
possible_classes = download_functions.get_possible_classes_enigma_brca12_1_1_0(class_counts) # get a set of possible classes depending on selected criteria
possible_classes = download_functions.get_possible_classes_enigma_brca12_1_1_0(class_counts)
elif 'palb2' in scheme_type and (version == "v1.0.0" or version == "v1.1.0"):
possible_classes = download_functions.get_possible_classes_enigma_palb2(class_counts) # get a set of possible classes depending on selected criteria
possible_classes = download_functions.get_possible_classes_enigma_palb2(class_counts)
elif 'tp53' in scheme_type and version == "v1.4.0":
possible_classes = download_functions.get_possible_classes_enigma_tp53(class_counts) # get a set of possible classes depending on selected criteria
possible_classes = download_functions.get_possible_classes_enigma_tp53(class_counts)
elif 'atm' in scheme_type and version == "v1.1.0":
possible_classes = download_functions.get_possible_classes_enigma_atm_1_1_0(class_counts) # get a set of possible classes depending on selected criteria
possible_classes = download_functions.get_possible_classes_enigma_atm_1_1_0(class_counts)
elif 'atm' in scheme_type and version == "v1.3.0":
possible_classes = download_functions.get_possible_classes_enigma_atm_1_3_0(class_counts) # get a set of possible classes depending on selected criteria
possible_classes = download_functions.get_possible_classes_enigma_atm_1_3_0(class_counts)
elif 'pten' in scheme_type and version == "v3.0.0":
possible_classes = download_functions.get_possible_classes_enigma_pten(class_counts) # get a set of possible classes depending on selected criteria
possible_classes = download_functions.get_possible_classes_enigma_pten(class_counts)
elif 'pten' in scheme_type and version == "v3.1.0":
possible_classes = download_functions.get_possible_classes_enigma_pten_310(class_counts) # get a set of possible classes depending on selected criteria
elif 'pms2' in scheme_type and version == "v1.0.0":
possible_classes = download_functions.get_possible_classes_enigma_pms2_100(class_counts) # get a set of possible classes depending on selected criteria
elif 'mlh1' in scheme_type and version == "v1.0.0":
possible_classes = download_functions.get_possible_classes_enigma_mlh_100(class_counts) # get a set of possible classes depending on selected criteria
possible_classes = download_functions.get_possible_classes_enigma_pten_310(class_counts)
elif any([gene_symbol in scheme_type for gene_symbol in ['pms2', 'mlh1', 'msh2', 'msh6']]) and version == "v1.0.0": # MMR genes
possible_classes = download_functions.get_possible_classes_enigma_insight_mmr_100(class_counts)
else:
raise RuntimeError('The class could not be calculated with given parameters. Did you specify a supported scheme and version? (either "acmg" or VUS "task-force" based)')

Expand Down
4 changes: 1 addition & 3 deletions src/frontend_celery/webapp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ def import_one_variant_heredicare(self, vid, user_id, user_roles, import_variant

def fetch_heredicare(vid, user_id, conn:Connection, insert_variant = True, perform_annotation = True):
heredicare_interface = Heredicare()
print("THE VID: " + str(vid))
variant, status, message = heredicare_interface.get_variant(vid)
print(variant)

if status != 'success': # error in variant retrieval from heredicare
return status, message
Expand Down Expand Up @@ -566,7 +564,7 @@ def validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn: Connec


tmp_file_path = functions.get_random_temp_file("vcf")
functions.variant_to_vcf(chrom, pos, ref, alt, tmp_file_path)
functions.variant_to_vcf(chrom, pos, ref, alt, tmp_file_path, genome_build)

do_liftover = genome_build == 'GRCh37'
returncode, err_msg, command_output = functions.preprocess_variant(tmp_file_path, do_liftover = do_liftover)
Expand Down
13 changes: 13 additions & 0 deletions src/frontend_celery/webapp/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ <h4>Overview</h4>
<div class="bst bsb">
<h4>Changelog</h4>

<div class="underline">v 1.13.7 (20.08.2024)</div>
<div>
General changes:
<ul>
<li>Added ACMG schemes for MMR genes (pms2, mlh1, msh2, msh6)</li>
</ul>
Bugfixes:
<ul>
<li>Fixed some minor issues with HerediCaRe up- and downloads</li>
<li>Downgraded CrossMap to v0.7.0 because v0.7.3 yields wrong results for specific variants</li>
</ul>
</div>

<div class="underline">v 1.13.6 (16.08.2024)</div>
<div>
General changes:
Expand Down

0 comments on commit d24364b

Please sign in to comment.