Skip to content
Draft
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
22 changes: 22 additions & 0 deletions tools/beacon2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Beacon2 Galaxy wrapper drafts

Files included:
- `macros.xml`
- `csv_to_bff.xml`
- `genomicVariations_vcf.xml`
- `genomicVariations_postprocessing.xml`
- `individuals_to_cohorts_csv.xml`

## Design notes

These wrappers are designed around the current Python CLI exposed by Beacon2 RI Tools v2:
- `csv_to_bff.py --output --datasetId --input --entry_type`
- `genomicVariations_vcf.py --output --datasetId --refGen --caseLevelData --numRows --verbosity --json --input --alleleCounts --alleleFrequency`
- `genomicVariations_postprocessing.py --input --datasetId`
- `individuals_to_cohorts_csv.py --input --output --datasetId --cohortId --cohortName --cohortType`

The wrappers generate a temporary `conf/conf.py` at runtime and copy the installed package tree into the job directory before execution. This is meant to cope with the upstream scripts relying on package-relative resources such as `files/headers/*.txt`, `files/deref_schemas/*.json`, and `conf/conf.py`.

## Important caveat

I could validate that the XML files are well-formed, but I did **not** run `planemo test` here. You will still want to adapt test-data paths and, if needed, the exact conda package name/version used by your Bioconda recipe.
47 changes: 0 additions & 47 deletions tools/beacon2/csv2xlsx.xml

This file was deleted.

195 changes: 195 additions & 0 deletions tools/beacon2/csv_to_bff.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
<tool id="beacon2_csv_to_bff" name="Beacon2 CSV to BFF" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
<description>convert Beacon CSV sheets to Beacon Friendly Format JSON</description>
<macros>
<import>macros.xml</import>
</macros>
<expand macro="xrefs"/>
<expand macro="requirements"/>
<expand macro="creators"/>
<expand macro="stdio"/>
<expand macro="version_command"/>
<command detect_errors="exit_code"><![CDATA[
@BEACON2_RUNTIME_SETUP@ &&

cp '$conf_py' 'conf/conf.py' &&

ln -s '$input_csv' '${advanced.entry_type}.csv' &&

csv_to_bff.py
-i .
-o .
-d '$dataset_id'
-e '$advanced.entry_type'
> output.log 2>&1 &&

cp '${advanced.entry_type}.json' output.json
]]></command>
<environment_variables>
<environment_variable name="PYTHONPATH">.:\$PYTHONPATH</environment_variable>
</environment_variables>
<configfiles>
<configfile name="conf_py"><![CDATA[
# Auto-generated by the Galaxy wrapper for Beacon2 CSV to BFF

csv_folder='.'
output_docs_folder='.'
entry_type='${advanced.entry_type}'
only_process_reads_with_allele_frequency=${advanced.only_process_reads_with_allele_frequency}
populations_by_allele_counts = ${advanced.populations_by_allele_counts}
reference_genome='${advanced.reference_genome}'
datasetId='${dataset_id}'
case_level_data=${advanced.case_level_data}
exact_heterozygosity=${advanced.exact_heterozygosity}
num_rows=${advanced.num_rows}
verbosity=${advanced.verbosity}

# Database connection
database_host='${advanced.database.database_host}'
database_port=${advanced.database.database_port}
database_name='${advanced.database.database_name}'

# Credentials (exact same logic as your beacon2-import tool)
#set $db_auth_source = $__user__.extra_preferences.get('beacon2_account|db_auth_source', "")
#set $db_user = $__user__.extra_preferences.get('beacon2_account|db_user', "")
#set $db_password = $__user__.extra_preferences.get('beacon2_account|db_password', "")
#if $db_user == "" or $db_password == "" or $db_auth_source == "":
#set $db_auth_source = "admin"
#set $db_user = "root"
#set $db_password = "example"
#end if

database_user = '$db_user'
database_password = '$db_password'
database_auth_source = '$db_auth_source'
]]></configfile>
</configfiles>

<inputs>
<param name="input_csv" type="data" format="csv" label="Input CSV file"/>
<expand macro="dataset_id"/>
<expand macro="advanced_section"/>
</inputs>

<outputs>
<data name="out_json" format="json" from_work_dir="output.json" label="${tool.name} on ${on_string}: ${advanced.entry_type}.json"/>
<data name="log" format="txt" from_work_dir="output.log" label="${tool.name} on ${on_string}: execution log"/>
</outputs>

<tests>
<test expect_num_outputs="2">
<!-- test1: individuals.csv -->
<param name="input_csv" value="individuals.csv" />
<param name="advanced|entry_type" value="individuals" />
<param name="dataset_id" value="test_dataset" />
<output name="out_json" file="individuals.json" ftype="json"/>
<output name="log" compare="contains">
<assert_contents>
<has_text text="Successfully converted" />
</assert_contents>
</output>
</test>
<test expect_num_outputs="2">
<!-- test2: genomicVariations.csv -->
<param name="input_csv" value="genomicVariations.csv" />
<param name="advanced|entry_type" value="genomicVariations" />
<param name="dataset_id" value="test_dataset" />
<output name="out_json" file="genomicVariations.json" ftype="json"/>
<output name="log" compare="contains">
<assert_contents>
<has_text text="Successfully converted" />
</assert_contents>
</output>
</test>
<test expect_num_outputs="2">
<!-- test3: cohorts.csv -->
<param name="input_csv" value="cohorts.csv" />
<param name="advanced|entry_type" value="cohorts" />
<param name="dataset_id" value="test_dataset" />
<output name="out_json" file="cohorts.json" ftype="json"/>
<output name="log" compare="contains">
<assert_contents>
<has_text text="Successfully converted" />
</assert_contents>
</output>
</test>
<test expect_num_outputs="2">
<!-- test4: analyses.csv -->
<param name="input_csv" value="analyses.csv" />
<param name="advanced|entry_type" value="analyses" />
<param name="dataset_id" value="test_dataset" />
<output name="out_json" file="analyses.json" ftype="json"/>
<output name="log" compare="contains">
<assert_contents>
<has_text text="Successfully converted" />
</assert_contents>
</output>
</test>
<test expect_num_outputs="2">
<!-- test5: biosamples.csv -->
<param name="input_csv" value="biosamples.csv" />
<param name="advanced|entry_type" value="biosamples" />
<param name="dataset_id" value="test_dataset" />
<output name="out_json" file="biosamples.json" ftype="json"/>
<output name="log" compare="contains">
<assert_contents>
<has_text text="Successfully converted" />
</assert_contents>
</output>
</test>
<test expect_num_outputs="2">
<!-- test6: collections.csv -->
<param name="input_csv" value="collections.csv" />
<param name="advanced|entry_type" value="collections" />
<param name="dataset_id" value="test_dataset" />
<output name="out_json" file="collections.json" ftype="json"/>
<output name="log" compare="contains">
<assert_contents>
<has_text text="Successfully converted" />
</assert_contents>
</output>
</test>
<test expect_num_outputs="2">
<!-- test7: datasets.csv -->
<param name="input_csv" value="datasets.csv" />
<param name="advanced|entry_type" value="datasets" />
<param name="dataset_id" value="test_dataset" />
<output name="out_json" file="datasets.json" ftype="json"/>
<output name="log" compare="contains">
<assert_contents>
<has_text text="Successfully converted" />
</assert_contents>
</output>
</test>
<test expect_num_outputs="2">
<!-- test8: patients.csv -->
<param name="input_csv" value="patients.csv" />
<param name="advanced|entry_type" value="patients" />
<param name="dataset_id" value="test_dataset" />
<output name="out_json" file="patients.json" ftype="json"/>
<output name="log" compare="contains">
<assert_contents>
<has_text text="Successfully converted" />
</assert_contents>
</output>
</test>
<test expect_num_outputs="2">
<!-- test9: runs.csv -->
<param name="input_csv" value="runs.csv" />
<param name="advanced|entry_type" value="runs" />
<output name="out_json" file="runs.json" ftype="json"/>
<param name="dataset_id" value="test_dataset" />
<output name="log" compare="contains">
<assert_contents>
<has_text text="Successfully converted" />
</assert_contents>
</output>
</test>
</tests>

<help><![CDATA[
**Beacon2 CSV to BFF**

Converts Beacon CSV files to Beacon Friendly Format (BFF) JSON.
]]></help>
<expand macro="citations"/>
</tool>
103 changes: 103 additions & 0 deletions tools/beacon2/genomicVariations_postprocessing.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<tool id="beacon2_genomic_variations_postprocessing" name="Beacon2 genomicVariations postprocessing" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
<description>add caseLevelData or variantLevelData to existing Beacon genomic variations</description>
<macros>
<import>macros.xml</import>
</macros>
<expand macro="xrefs"/>
<expand macro="requirements"/>
<expand macro="creators"/>
<expand macro="stdio"/>
<expand macro="version_command"/>

<command detect_errors="exit_code"><![CDATA[
@BEACON2_RUNTIME_SETUP@ &&
touch conf/__init__.py &&
cp '$conf_py' 'conf/conf.py' &&
ln -s '$input_csv' 'input.csv' &&
genomicVariations_postprocessing.py
--input 'input.csv'
--datasetId '${dataset_id}'
> output.log 2>&1
]]></command>
<environment_variables>
<environment_variable name="PYTHONPATH">.:\$PYTHONPATH</environment_variable>
</environment_variables>
<!-- SINGLE <configfiles> SECTION -->
<configfiles>
<configfile name="conf_py"><![CDATA[
# Auto-generated by the Galaxy wrapper for Beacon2 CSV to BFF

csv_folder = '.'
output_docs_folder = '.'
entry_type = '${advanced.entry_type}'
only_process_reads_with_allele_frequency = ${advanced.only_process_reads_with_allele_frequency}
populations_by_allele_counts = ${advanced.populations_by_allele_counts}
reference_genome = '${advanced.reference_genome}'
datasetId = '${dataset_id}'
case_level_data = ${advanced.case_level_data}
exact_heterozygosity = ${advanced.exact_heterozygosity}
num_rows = ${advanced.num_rows}
verbosity = ${advanced.verbosity}

# Database connection
database_host = '${advanced.database.database_host}'
database_port = ${advanced.database.database_port}
database_name = '${advanced.database.database_name}'

# Credentials (exact same logic as your beacon2-import tool)
#set $db_auth_source = $__user__.extra_preferences.get('beacon2_account|db_auth_source', "")
#set $db_user = $__user__.extra_preferences.get('beacon2_account|db_user', "")
#set $db_password = $__user__.extra_preferences.get('beacon2_account|db_password', "")
#if $db_user == "" or $db_password == "" or $db_auth_source == "":
#set $db_auth_source = "admin"
#set $db_user = "root"
#set $db_password = "example"
#end if

database_user = '$db_user'
database_password = '$db_password'
database_auth_source = '$db_auth_source'
]]></configfile>
</configfiles>

<inputs>
<param name="input_csv" type="data" format="csv" label="genomicVariations CSV for postprocessing"/>
<expand macro="dataset_id"/>
<!-- Full advanced options (single source of truth, includes custom conf.py) -->
<!-- entry_type is hard-coded above because this tool is single-purpose -->
<expand macro="advanced_section"/>
</inputs>

<outputs>
<expand macro="log_output"/>
</outputs>

<tests>
<test>
<param name="input_csv" value="genomicVariations.csv" />
<param name="dataset_id" value="test_dataset" />
<output name="log" compare="contains">
<assert_contents>
<has_text text="Successfully updated" />
</assert_contents>
</output>
</test>
</tests>

<help><![CDATA[
**Beacon2 genomicVariations Post-processing**

Adds `caseLevelData` or `variantLevelData` to genomic variations that have already been loaded into the Beacon MongoDB.

**New flexible options (Advanced section):**
- Reference genome
- Case-level data generation
- Maximum rows to process (0 = unlimited)
- Allele frequency & population settings
- Verbose logging
- **Custom conf.py** (upload your own optimized config file for full control)

MongoDB credentials are read automatically from your Galaxy user preferences.
]]></help>
<expand macro="citations"/>
</tool>
Loading
Loading