Skip to content

Commit

Permalink
Merge branch 'develop' into release/v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rernst committed Jul 29, 2021
2 parents 71b60e6 + 47f6985 commit bee5233
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
22 changes: 20 additions & 2 deletions clarity_epp.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,17 @@ def export_merge_file(args):


def export_removed_samples(args):
"""Export removed sampels table."""
"""Export removed samples table."""
clarity_epp.export.sample.removed_samples(lims, args.output_file)


def export_sample_indications(args):
"""Export sample indication table."""
clarity_epp.export.sample.sample_indications(
lims, args.output_file, args.artifact_name, args.sequencing_run, args.sequencing_run_project
)


def export_tapestation(args):
"""Export samplesheets for Tapestation machine."""
clarity_epp.export.tapestation.samplesheet(lims, args.process_id, args.output_file)
Expand Down Expand Up @@ -263,10 +270,21 @@ def placement_complete_step(args):
parser_export_ped.set_defaults(func=export_ped_file)

parser_export_removed_samples = subparser_export.add_parser(
'removed_samples', help='Export removed sampels table', parents=[output_parser]
'removed_samples', help='Export removed samples table', parents=[output_parser]
)
parser_export_removed_samples.set_defaults(func=export_removed_samples)

parser_export_sample_indications = subparser_export.add_parser(
'sample_indications', help='Export sample indication table.', parents=[output_parser]
)
parser_export_sample_indications_group = parser_export_sample_indications.add_mutually_exclusive_group(required=True)
parser_export_sample_indications_group.add_argument('-a', '--artifact_name', help='Artifact name')
parser_export_sample_indications_group.add_argument('-r', '--sequencing_run', help='Sequencing run name')
parser_export_sample_indications.add_argument(
'-p', '--sequencing_run_project', nargs='?', help='Sequencing run project name'
)
parser_export_sample_indications.set_defaults(func=export_sample_indications)

parser_export_tapestation = subparser_export.add_parser(
'tapestation', help='Create tapestation samplesheets', parents=[output_parser]
)
Expand Down
29 changes: 29 additions & 0 deletions clarity_epp/export/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,32 @@ def removed_samples(lims, output_file):
stage=removed_stage.name,
removed_status=sample_removed_status
))


def sample_indications(lims, output_file, artifact_name=None, sequencing_run=None, sequencing_run_project=None):
"""Export table with sample indications. Lookup samples by sample name or sequencing run (project)."""
samples = []

# Get samples by artifact_name
if artifact_name:
artifacts = lims.get_artifacts(name=artifact_name)
samples = {artifact_name: artifact.samples[0] for artifact in artifacts}

# Get samples by sequencing run
elif sequencing_run:
udf_query = {'Dx Sequencing Run ID': sequencing_run}
if sequencing_run_project:
udf_query['Dx Sequencing Run Project'] = sequencing_run_project

artifacts = lims.get_artifacts(type='Analyte', udf=udf_query)
samples = {artifact.name: artifact.samples[0] for artifact in artifacts}

# Write result
if samples:
output_file.write('Sample\tIndication\n')
for sample_name, sample in samples.items():
output_file.write(
'{sample}\t{indication}\n'.format(sample=sample_name, indication=sample.udf['Dx Onderzoeksindicatie'])
)
else:
print("Can't find sample(s).")

0 comments on commit bee5233

Please sign in to comment.