# HG changeset patch # User galaxytrakr # Date 1777578055 0 # Node ID 706b2bbc64edbbf4d9b87698b8ecf944624a8ec6 # Parent 58006290e654b316c697e51295ae54cd39c84e09 planemo upload commit e5fa85f6befc345ab8f2b0af283f96834038cefd diff -r 58006290e654 -r 706b2bbc64ed plasmidtrakr.xml --- a/plasmidtrakr.xml Thu Apr 30 19:20:50 2026 +0000 +++ b/plasmidtrakr.xml Thu Apr 30 19:40:55 2026 +0000 @@ -1,4 +1,4 @@ - + Screens assemblies against a Mash database and predicts isolate source using a trained machine learning model @@ -8,32 +8,42 @@ '${input_name}.tabular' + > mash_results.tabular && - ## 4. Run PlasmidTrakr prediction - ## We pass the newly named file to the python script - python $__tool_directory__/predict_source.py - -i '${input_name}.tabular' - -b '$model_selection.fields.path' - -t $threshold - -o '$prediction_output' + ## 3. Conditional Logic: Check if Mash produced hits + ## [ -s file ] checks if file exists and has size > 0 + if [ -s mash_results.tabular ]; then + ## Run the prediction script only if there is data + python $__tool_directory__/predict_source.py + -i mash_results.tabular + -b '$model_selection.fields.path' + -t $threshold + -o '$prediction_output'; + + ## Optional: If the script ran but produced no results (e.g. filtered out) + ## ensure we still provide the "No Prediction" fallback + if [ \$(wc -l < '$prediction_output') -le 1 ]; then + echo -e "Run\tPredicted_Source\tConfidence_Score" > '$prediction_output'; + echo -e "${input_name}\tNo Prediction\t0.0" >> '$prediction_output'; + fi + else + ## Skip Python and create the fallback file immediately + echo -e "Run\tPredicted_Source\tConfidence_Score" > '$prediction_output'; + echo -e "${input_name}\tNo Prediction\t0.0" >> '$prediction_output'; + fi ]]> -