Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions epp/useq_finance_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def initialize_project_run_data(pool_id: str) -> Dict[str, Any]:
'first_submission_date': None,
'received_date': set(),
'project_comments': None,
'run_comments' : None,
'times_sequenced': 0,
'pool': pool_id,
'lims_runtype': None,
Expand Down Expand Up @@ -274,6 +275,7 @@ def process_run_artifact(lims: Lims, sample_artifact: Artifact, sample_meta: Dic
pid_sequenced (Dict[str, Set]): Dictionary tracking when projects were sequenced
"""
protocol_name = get_step_protocol(lims, step_id=sample_artifact.parent_process.id)
# print('test', protocol_name)
run_data['lims_runtype'] = protocol_name.split("-", 1)[1].lower().strip()

if not run_data['run_date']:
Expand Down Expand Up @@ -518,6 +520,7 @@ def get_seq_finance(lims: Lims, step_uri: str) -> str:
runs[pool.id] = {}

run_date = None
run_comments = ''
pool_parent_process = pool.parent_process # BCL to FastQ

# Try to determine the date this run was sequenced
Expand All @@ -532,6 +535,7 @@ def get_seq_finance(lims: Lims, step_uri: str) -> str:
for process in processes:

if process.type.name in Config.RUN_PROCESSES:
run_comments = process.udf.get('Run Comments', '')
run_date = process.date_run
break

Expand Down Expand Up @@ -628,6 +632,8 @@ def get_seq_finance(lims: Lims, step_uri: str) -> str:
run_meta['date'] = sample.date_received
runs[pool.id][project_id]['run_date'] = run_meta['date']
else:


# Process sample artifacts
sample_artifacts = lims.get_artifacts(samplelimsid=sample.id)
for sample_artifact in sample_artifacts:
Expand All @@ -636,7 +642,7 @@ def get_seq_finance(lims: Lims, step_uri: str) -> str:
continue

process_name = sample_artifact.parent_process.type.name

# print('test', process_name)
# Handle different process types
if process_name in Config.ISOLATION_PROCESSES:
process_isolation_artifact(
Expand All @@ -660,7 +666,7 @@ def get_seq_finance(lims: Lims, step_uri: str) -> str:
runs[pool.id][project_id], run_meta,
run_date, pid_sequenced
)

# print('Run artifact found', project_id, process_name)
elif process_name in Config.ANALYSIS_PROCESSES and application != 'SNP Fingerprinting':
process_analysis_artifact(
sample_artifact, sample, sample_meta,
Expand Down Expand Up @@ -698,10 +704,12 @@ def get_seq_finance(lims: Lims, step_uri: str) -> str:
# sample_meta['Sequenced'] = True
###Check if sample_meta['Sequenced'] = True needs to be set####


# Fetch and update costs
costs = fetch_project_costs(project_id, run_meta)
update_run_costs(runs[pool.id][project_id], costs, application)

runs[pool.id][project_id]['run_comments'] = run_comments
# Deduplicate and convert sets to strings
runs_dedup = deduplicate_runs(runs)
return render_template('seq_finance_overview_template.csv', {'pools': runs_dedup})
Expand Down
4 changes: 2 additions & 2 deletions resources/seq_finance_overview_template.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
errors;pool_name;project_name;project_id;open_date;contact_name;contact_email;account;project_budget_number;sample_type;nr_samples;isolation_step_costs;isolation_personell_costs;libraryprep_step_costs;libraryprep_personell_costs;plate_step_costs;plate_personell_costs;sequencing_step_costs;sequencing_personell_costs;analysis_step_costs;analysis_personell_costs;total_step_costs;total_personell_costs;billing_institute;billing_department;billing_street;billing_postalcode;billing_city;billing_country;requested_runtype;lims_runtype;requested_libraryprep;lims_libraryprep;lims_isolation;requested_analysis;sequencing_succesful;description;order_number;comments_and_agreements;deb_nr;vat_nr;nr_samples_isolated;nr_samples_prepped;nr_samples_sequenced;nr_samples_analyzed;nr_lanes;
errors;pool_name;project_name;project_id;open_date;contact_name;contact_email;account;project_budget_number;sample_type;nr_samples;isolation_step_costs;isolation_personell_costs;libraryprep_step_costs;libraryprep_personell_costs;plate_step_costs;plate_personell_costs;sequencing_step_costs;sequencing_personell_costs;analysis_step_costs;analysis_personell_costs;total_step_costs;total_personell_costs;billing_institute;billing_department;billing_street;billing_postalcode;billing_city;billing_country;requested_runtype;lims_runtype;requested_libraryprep;lims_libraryprep;lims_isolation;requested_analysis;sequencing_succesful;description;order_number;comments_and_agreements;deb_nr;vat_nr;nr_samples_isolated;nr_samples_prepped;nr_samples_sequenced;nr_samples_analyzed;nr_lanes;run_comments
{%- for pool in pools %}
{%- for run in pools[pool] %}
{{ pools[pool][run]['errors'] }};{{ pools[pool][run]['pool'] }};{{ pools[pool][run]['name'] }};{{ pools[pool][run]['id'] }};{{ pools[pool][run]['open_date'] }};{{ pools[pool][run]['contact_name'] }};{{ pools[pool][run]['contact_email'] }};{{ pools[pool][run]['lab_name'] }};{{ pools[pool][run]['budget_nr'] }};{{ pools[pool][run]['type'] }};{{ pools[pool][run]['nr_samples_submitted'] }};{{ pools[pool][run]['isolation_step_costs'] }};{{ pools[pool][run]['isolation_personell_costs'] }};{{ pools[pool][run]['libprep_step_costs'] }};{{ pools[pool][run]['libprep_personell_costs'] }};NA;NA;{{ pools[pool][run]['run_step_costs'] }};{{ pools[pool][run]['run_personell_costs'] }};{{ pools[pool][run]['analysis_step_costs'] }};{{ pools[pool][run]['analysis_personell_costs'] }};{{ pools[pool][run]['total_step_costs'] }};{{ pools[pool][run]['total_personell_costs'] }};{{ pools[pool][run]['institute'] }};{{ pools[pool][run]['department'] }};{{ pools[pool][run]['street'] }};{{ pools[pool][run]['postalcode'] }};{{ pools[pool][run]['city'] }};{{ pools[pool][run]['country'] }};{{ pools[pool][run]['requested_runtype'] }};{{ pools[pool][run]['lims_runtype'] }};{{ pools[pool][run]['requested_library_prep'] }};{{ pools[pool][run]['lims_library_prep'] }};{{ pools[pool][run]['lims_isolation'] }};{{ pools[pool][run]['requested_analysis'] }};{{ pools[pool][run]['succesful'] }};{{ pools[pool][run]['description'] }};{{ pools[pool][run]['order_nr'] }};{{ pools[pool][run]['project_comments'] }};{{ pools[pool][run]['deb_nr'] }};{{ pools[pool][run]['vat_nr'] }};{{ pools[pool][run]['nr_samples_isolated'] }};{{ pools[pool][run]['nr_samples_prepped'] }};{{ pools[pool][run]['nr_samples_sequenced'] }};{{ pools[pool][run]['nr_samples_analyzed'] }};{{ pools[pool][run]['run_lanes'] }}
{{ pools[pool][run]['errors'] }};{{ pools[pool][run]['pool'] }};{{ pools[pool][run]['name'] }};{{ pools[pool][run]['id'] }};{{ pools[pool][run]['open_date'] }};{{ pools[pool][run]['contact_name'] }};{{ pools[pool][run]['contact_email'] }};{{ pools[pool][run]['lab_name'] }};{{ pools[pool][run]['budget_nr'] }};{{ pools[pool][run]['type'] }};{{ pools[pool][run]['nr_samples_submitted'] }};{{ pools[pool][run]['isolation_step_costs'] }};{{ pools[pool][run]['isolation_personell_costs'] }};{{ pools[pool][run]['libprep_step_costs'] }};{{ pools[pool][run]['libprep_personell_costs'] }};NA;NA;{{ pools[pool][run]['run_step_costs'] }};{{ pools[pool][run]['run_personell_costs'] }};{{ pools[pool][run]['analysis_step_costs'] }};{{ pools[pool][run]['analysis_personell_costs'] }};{{ pools[pool][run]['total_step_costs'] }};{{ pools[pool][run]['total_personell_costs'] }};{{ pools[pool][run]['institute'] }};{{ pools[pool][run]['department'] }};{{ pools[pool][run]['street'] }};{{ pools[pool][run]['postalcode'] }};{{ pools[pool][run]['city'] }};{{ pools[pool][run]['country'] }};{{ pools[pool][run]['requested_runtype'] }};{{ pools[pool][run]['lims_runtype'] }};{{ pools[pool][run]['requested_library_prep'] }};{{ pools[pool][run]['lims_library_prep'] }};{{ pools[pool][run]['lims_isolation'] }};{{ pools[pool][run]['requested_analysis'] }};{{ pools[pool][run]['succesful'] }};{{ pools[pool][run]['description'] }};{{ pools[pool][run]['order_nr'] }};{{ pools[pool][run]['project_comments'] }};{{ pools[pool][run]['deb_nr'] }};{{ pools[pool][run]['vat_nr'] }};{{ pools[pool][run]['nr_samples_isolated'] }};{{ pools[pool][run]['nr_samples_prepped'] }};{{ pools[pool][run]['nr_samples_sequenced'] }};{{ pools[pool][run]['nr_samples_analyzed'] }};{{ pools[pool][run]['run_lanes'] }};{{ pools[pool][run]['run_comments'] }}
{%- endfor %}
{%- endfor %}
Loading