Skip to content

Commit

Permalink
2024-10-23 bug changes (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanreardon authored Oct 25, 2024
1 parent 20ee1e3 commit 5b40001
Show file tree
Hide file tree
Showing 12 changed files with 1,017 additions and 104 deletions.
903 changes: 903 additions & 0 deletions example_output/example.log

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion moalmanac/annotation-databases.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[databases]
[paths]
root = ../datasources
almanac_handle = ${root}/moalmanac/molecular-oncology-almanac.json
cancerhotspots_handle = ${root}/cancerhotspots/hotspots_v2.txt
Expand Down
4 changes: 3 additions & 1 deletion moalmanac/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ include_model_similarity_in_actionability_report = on
include_preclinical_efficacy_in_actionability_report = on

[logging]
; Possible values for level include "NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", and "CRITICAL". They are described
; within the logging module's document: https://docs.python.org/3/library/logging.html#logging-levels.
level = INFO

[versions]
interpreter = 0.7.1
interpreter = 0.7.2
database = v.2024-04-11

[exac]
Expand Down
2 changes: 2 additions & 0 deletions moalmanac/logger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging


class Logger:
@staticmethod
def generate_filename(folder, label):
Expand All @@ -16,6 +17,7 @@ def setup(cls, output_folder, file_prefix, config):
level=config['logging']['level']
)


class Messages:
@staticmethod
def dataframe_size(label, dataframe, add_line_break=False):
Expand Down
16 changes: 6 additions & 10 deletions moalmanac/moalmanac.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def somatic_variants(df, dbs, ontology, config, path_validation):
logger.Messages.general(message="No passed validation sequencing variants to annotate with")
else:
logger.Messages.general(message="No somatic variants detected. Skipping annotation and evaluation.")
evaluated= features.Features.create_empty_dataframe()
evaluated = features.Features.create_empty_dataframe()
logger.Messages.general(message="Annotation and evaluation of somatic variants complete", add_line_break=True)
return evaluated

Expand Down Expand Up @@ -706,8 +706,6 @@ def main(patient, inputs, output_folder, config, dbs, dbs_preclinical=None):


if __name__ == "__main__":
start_time = time.time()

arg_parser = argparse.ArgumentParser(
prog='Molecular Oncology Almanac',
description='A clinical interpretation algorithm for cancer genomics.'
Expand Down Expand Up @@ -854,21 +852,19 @@ def main(patient, inputs, output_folder, config, dbs, dbs_preclinical=None):
config_ini = Ini.read(args.config, extended_interpolation=False, convert_to_dictionary=False)

db_paths = Ini.read(args.dbs, extended_interpolation=True, convert_to_dictionary=True)
db_paths = db_paths['paths']

if args.preclinical_dbs:
preclinical_db_paths = Ini.read(args.preclinical_dbs, extended_interpolation=True, convert_to_dictionary=True)
preclinical_db_paths = preclinical_db_paths['paths']
else:
preclinical_db_paths = None

print(db_paths)
main(
patient=patient_dict,
inputs=inputs_dict,
output_folder=output_directory,
config=config_ini,
dbs=db_paths['databases'],
dbs_preclinical=preclinical_db_paths['preclinical']
dbs=db_paths,
dbs_preclinical=preclinical_db_paths
)

end_time = time.time()
time_statement = "Molecular Oncology Almanac runtime: %s seconds" % round((end_time - start_time), 4)
print(time_statement)
2 changes: 1 addition & 1 deletion moalmanac/preclinical-databases.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[preclinical]
[paths]
root = ../datasources
almanac_gdsc_mappings = ${root}/preclinical/formatted/almanac-gdsc-mappings.json
summary = ${root}/preclinical/formatted/cell-lines.summary.txt
Expand Down
13 changes: 8 additions & 5 deletions moalmanac/run_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@
}

config_ini_path = "config.ini"
dbs_ini_path = "annotation-databases.ini"
dbs_preclinical_ini_path = "preclinical-databases.ini"

config_ini = Ini.read(config_ini_path, extended_interpolation=False, convert_to_dictionary=False)

dbs_ini_path = "annotation-databases.ini"
db_paths = Ini.read(dbs_ini_path, extended_interpolation=True, convert_to_dictionary=True)
db_paths = db_paths['paths']

dbs_preclinical_ini_path = "preclinical-databases.ini"
preclinical_db_paths = Ini.read(dbs_preclinical_ini_path, extended_interpolation=True, convert_to_dictionary=True)
preclinical_db_paths = preclinical_db_paths['paths']


def execute_cmd(command):
Expand All @@ -71,8 +74,8 @@ def execute_cmd(command):
inputs=input_dictionary,
output_folder=output_directory,
config=config_ini,
dbs=db_paths['databases'],
dbs_preclinical=preclinical_db_paths['preclinical']
dbs=db_paths,
dbs_preclinical=preclinical_db_paths
)
end_time = time.time()

Expand Down
4 changes: 2 additions & 2 deletions moalmanac/simplified_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ def main(patient, input_file, output_folder, config, dbs, dbs_preclinical=None):
input_file=args.input,
output_folder=output_directory,
config=config_ini,
dbs=db_paths,
dbs_preclinical=preclinical_db_paths
dbs=db_paths['databases'],
dbs_preclinical=preclinical_db_paths['preclinical'] if preclinical_db_paths else None
)

end_time = time.time()
Expand Down
14 changes: 8 additions & 6 deletions moalmanac/templates/report_table/table_biological.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ <h4 class="panel-title">Variants and Features that may be Biologically Relevant<
<table class="table table-hover table-striped table-condensed">
{% include 'report_table/columns_biological.html' %}
<tbody>
{% for label, group in report.alterations[report.alterations['score_bin'] == 'Biologically Relevant'].groupby('feature_type') %}
<tr>
<td>{{ label }}</td>
<td>{{ ', '.join(group['feature_display'].sort_values().tolist()) }}</td>
</tr>
{% endfor %}
{% if not report.alterations.empty %}
{% for label, group in report.alterations[report.alterations['score_bin'] == 'Biologically Relevant'].groupby('feature_type') %}
<tr>
<td>{{ label }}</td>
<td>{{ ', '.join(group['feature_display'].sort_values().tolist()) }}</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
Expand Down
52 changes: 27 additions & 25 deletions moalmanac/templates/report_table/table_prognostic.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,33 @@ <h4 class="panel-title">Variants and Features associated with Prognostic Informa
<table class="table table-hover table-striped table-condensed">
{% include 'report_table/columns_prognosis.html' %}
<tbody>
{% for index in report.alterations[report.alterations['prognostic_predictive_implication'].notnull()].sort_values(['prognostic_predictive_implication_map', 'prognostic_score_bin_map'], ascending=[False, False]).index.tolist() %}
<tr>
<td>{{ report.alterations.loc[index, 'prognostic_predictive_implication'] }}
<br>
{{ report.alterations.loc[index, 'prognostic_score_bin'] }}
<br>
{% include 'modals/evidence_prognosis.html' %}
<td>{{ report.alterations.loc[index, 'feature_type'] }}</td>
<td>{{ report.alterations.loc[index, 'feature_display'] }}</td>
<td>
{% if report.alterations.loc[index, 'favorable_prognosis'] == 1.0 %}
Favorable
{% else %}
Not favorable
{% endif %}
<br>
{{ report.alterations.loc[index, 'prognostic_description'] }}
{% if report.alterations.loc[index, 'prognostic_url'] != "" %}
<a href="{{ report.alterations.loc[index, 'prognostic_url'] }}" target="_blank">
[source]
</a>
{% endif %}
</td>
</tr>
{% endfor %}
{% if not report.alterations.empty %}
{% for index in report.alterations[report.alterations['prognostic_predictive_implication'].notnull()].sort_values(['prognostic_predictive_implication_map', 'prognostic_score_bin_map'], ascending=[False, False]).index.tolist() %}
<tr>
<td>{{ report.alterations.loc[index, 'prognostic_predictive_implication'] }}
<br>
{{ report.alterations.loc[index, 'prognostic_score_bin'] }}
<br>
{% include 'modals/evidence_prognosis.html' %}
<td>{{ report.alterations.loc[index, 'feature_type'] }}</td>
<td>{{ report.alterations.loc[index, 'feature_display'] }}</td>
<td>
{% if report.alterations.loc[index, 'favorable_prognosis'] == 1.0 %}
Favorable
{% else %}
Not favorable
{% endif %}
<br>
{{ report.alterations.loc[index, 'prognostic_description'] }}
{% if report.alterations.loc[index, 'prognostic_url'] != "" %}
<a href="{{ report.alterations.loc[index, 'prognostic_url'] }}" target="_blank">
[source]
</a>
{% endif %}
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
Expand Down
52 changes: 27 additions & 25 deletions moalmanac/templates/report_table/table_resistance.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,33 @@ <h4 class="panel-title">Variants and Features associated with Therapeutic Resist
<table class="table table-hover table-striped table-condensed">
{% include 'report_table/columns_therapies.html' %}
<tbody>
{% for index in report.alterations[report.alterations['resistance_predictive_implication'].notnull()].sort_values(['resistance_predictive_implication_map', 'resistance_score_bin_map'], ascending=[False, False]).index.tolist() %}
<tr>
<td>{{ report.alterations.loc[index, 'resistance_predictive_implication'] }}
<br>
{{ report.alterations.loc[index, 'resistance_score_bin'] }}
<br>
{% include 'modals/evidence_resistance.html' %}
<td>{{ report.alterations.loc[index, 'feature_type'] }}</td>
<td>{{ report.alterations.loc[index, 'feature_display'] }}</td>
<td>
{% if report.alterations.loc[index, 'resistance_therapy_name'] != '' %}
{{ report.alterations.loc[index, 'resistance_therapy_name'] }}
{% else %}
{{ report.alterations.loc[index, 'resistance_therapy_type'] }}
{% endif %}
<br>
{{ report.alterations.loc[index, 'resistance_description'] }}
{% if report.alterations.loc[index, 'resistance_url'] != "" %}
<a href="{{ report.alterations.loc[index, 'resistance_url'] }}" target="_blank">
[source]
</a>
{% endif %}
</td>
</tr>
{% endfor %}
{% if not report.alterations.empty %}
{% for index in report.alterations[report.alterations['resistance_predictive_implication'].notnull()].sort_values(['resistance_predictive_implication_map', 'resistance_score_bin_map'], ascending=[False, False]).index.tolist() %}
<tr>
<td>{{ report.alterations.loc[index, 'resistance_predictive_implication'] }}
<br>
{{ report.alterations.loc[index, 'resistance_score_bin'] }}
<br>
{% include 'modals/evidence_resistance.html' %}
<td>{{ report.alterations.loc[index, 'feature_type'] }}</td>
<td>{{ report.alterations.loc[index, 'feature_display'] }}</td>
<td>
{% if report.alterations.loc[index, 'resistance_therapy_name'] != '' %}
{{ report.alterations.loc[index, 'resistance_therapy_name'] }}
{% else %}
{{ report.alterations.loc[index, 'resistance_therapy_type'] }}
{% endif %}
<br>
{{ report.alterations.loc[index, 'resistance_description'] }}
{% if report.alterations.loc[index, 'resistance_url'] != "" %}
<a href="{{ report.alterations.loc[index, 'resistance_url'] }}" target="_blank">
[source]
</a>
{% endif %}
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
Expand Down
57 changes: 29 additions & 28 deletions moalmanac/templates/report_table/table_sensitive.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,35 @@ <h4 class="panel-title">Variants and Features associated with Therapeutic Sensit
<table class="table table-hover table-striped table-condensed">
{% include 'report_table/columns_therapies.html' %}
<tbody>
{% for index in report.alterations[report.alterations['sensitive_predictive_implication'].notnull()].sort_values(['sensitive_predictive_implication_map', 'sensitive_score_bin_map'], ascending=[False, False]).index.tolist() %}

<tr>
<td>{{ report.alterations.loc[index, 'sensitive_predictive_implication'] }}
<br>
{{ report.alterations.loc[index, 'sensitive_score_bin'] }}
<br>
{% include 'modals/evidence_sensitive.html' %}
</td>
<td>{{ report.alterations.loc[index, 'feature_type'] }}</td>
<td>{{ report.alterations.loc[index, 'feature_display'] }}
<td>
{% if report.alterations.loc[index, 'sensitive_therapy_name'] != '' %}
{{ report.alterations.loc[index, 'sensitive_therapy_name'] }}
{% else %}
{{ report.alterations.loc[index, 'sensitive_therapy_type'] }}
{% endif %}
<br>
{{ report.alterations.loc[index, 'sensitive_description'] }}
{% if report.alterations.loc[index, 'sensitive_url'] != "" %}
<a href="{{ report.alterations.loc[index, 'sensitive_url'] }}" target="_blank">
[source]
</a>
{% endif %}
{% include 'modals/efficacy.html' %}
</td>
</tr>
{% endfor %}
{% if not report.alterations.empty %}
{% for index in report.alterations[report.alterations['sensitive_predictive_implication'].notnull()].sort_values(['sensitive_predictive_implication_map', 'sensitive_score_bin_map'], ascending=[False, False]).index.tolist() %}
<tr>
<td>{{ report.alterations.loc[index, 'sensitive_predictive_implication'] }}
<br>
{{ report.alterations.loc[index, 'sensitive_score_bin'] }}
<br>
{% include 'modals/evidence_sensitive.html' %}
</td>
<td>{{ report.alterations.loc[index, 'feature_type'] }}</td>
<td>{{ report.alterations.loc[index, 'feature_display'] }}
<td>
{% if report.alterations.loc[index, 'sensitive_therapy_name'] != '' %}
{{ report.alterations.loc[index, 'sensitive_therapy_name'] }}
{% else %}
{{ report.alterations.loc[index, 'sensitive_therapy_type'] }}
{% endif %}
<br>
{{ report.alterations.loc[index, 'sensitive_description'] }}
{% if report.alterations.loc[index, 'sensitive_url'] != "" %}
<a href="{{ report.alterations.loc[index, 'sensitive_url'] }}" target="_blank">
[source]
</a>
{% endif %}
{% include 'modals/efficacy.html' %}
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
Expand Down

0 comments on commit 5b40001

Please sign in to comment.