Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fomightez/efef613f653c10b2baee9e4897a43c84 to your computer and use it in GitHub Desktop.
Save fomightez/efef613f653c10b2baee9e4897a43c84 to your computer and use it in GitHub Desktop.
Snakemake run test for SO https://stackoverflow.com/q/78260730/8508004 WITH BETTER VESION MATCHING!!!
{
"cells": [
{
"cell_type": "markdown",
"id": "9ca6ae4a-2fbc-449a-ba5e-e5193220baff",
"metadata": {},
"source": [
"## Snakemake run test for SO https://stackoverflow.com/q/78260730/8508004 WITH BETTER VESION MATCHING!!!\n",
"\n",
"Ran in session launched from [here](https://gist.github.com/jtpio/35a72862c8be13dee31b61ebac2d9786) via clicking 'launch binder' badge. (Or click badge below for a fresh session!)\n",
"\n",
"[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gist/jtpio/35a72862c8be13dee31b61ebac2d9786/master?urlpath=/tree)\n",
"\n",
"This run makes the versions more like the OP!!!"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "78fd5e8f-682c-4ff6-a9a9-0c360b4db25b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7.32.4\n"
]
}
],
"source": [
"!snakemake -v"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "8084336a-c10d-4254-9fa1-4703bf2c60e5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]\n"
]
}
],
"source": [
"import sys\n",
"print (sys.version)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "bafc96b3-29d8-44fd-8a58-5866542a4ce0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" README.md\n",
" requirements.txt\n",
" runtime.txt\n",
" Snakefile\n",
"'Snakemake run test for SO question 78260730 with versions matching OP.ipynb'\n"
]
}
],
"source": [
"ls"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "c389f424-d490-4092-afed-2d36ec658e18",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing 's' (str) to file 'Snakefile'.\n"
]
}
],
"source": [
"s='''rule A:\n",
" input:\n",
" i = 'B1477.all_merged_3split_dedupped_sorted.bam'\n",
" output:\n",
" o = 'B1477.all_merged_3split_dedupped_sorted2.bam'\n",
" shell:\n",
" \"cat {input.i} > {output.o}\"\n",
"'''\n",
"%store s >Snakefile"
]
},
{
"cell_type": "markdown",
"id": "3be94589-cefa-46b5-8902-8e4b4ddf7b79",
"metadata": {},
"source": [
"Started runnng with only a `Snakefile` that had the above content."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "411ce30a-4a16-4506-b579-fd845dedaa50",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mBuilding DAG of jobs...\u001b[0m\n",
"\u001b[31mMissingInputException in rule A in file /home/jovyan/Snakefile, line 1:\n",
"Missing input files for rule A:\n",
" output: B1477.all_merged_3split_dedupped_sorted2.bam\n",
" affected files:\n",
" B1477.all_merged_3split_dedupped_sorted.bam\u001b[0m\n"
]
}
],
"source": [
"!snakemake --cores 1"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "68736e64-1d0e-43c0-926a-3680de406a9f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" README.md\n",
" requirements.txt\n",
" runtime.txt\n",
" Snakefile\n",
"'Snakemake run test for SO question 78260730 with versions matching OP.ipynb'\n"
]
}
],
"source": [
"ls"
]
},
{
"cell_type": "markdown",
"id": "edb2993f-2c95-4bcb-ad66-c737d6e6c54f",
"metadata": {},
"source": [
"Make the input file."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "1e551dfa-4008-4bd1-a010-c1a7f83b3d9f",
"metadata": {},
"outputs": [],
"source": [
"!touch B1477.all_merged_3split_dedupped_sorted.bam"
]
},
{
"cell_type": "markdown",
"id": "dc6f344b-4598-4c04-b27f-42f7e0850b03",
"metadata": {},
"source": [
"Now try again."
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "a7cd6cb9-80d8-405f-b77b-d21f6928477c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mBuilding DAG of jobs...\u001b[0m\n",
"\u001b[33mUsing shell: /usr/bin/bash\u001b[0m\n",
"\u001b[33mProvided cores: 1 (use --cores to define parallelism)\u001b[0m\n",
"\u001b[33mRules claiming more threads will be scaled down.\u001b[0m\n",
"\u001b[33mJob stats:\n",
"job count\n",
"----- -------\n",
"A 1\n",
"total 1\n",
"\u001b[0m\n",
"\u001b[33mSelect jobs to execute...\u001b[0m\n",
"\u001b[32m\u001b[0m\n",
"\u001b[32m[Tue Apr 2 18:24:48 2024]\u001b[0m\n",
"\u001b[32mrule A:\n",
" input: B1477.all_merged_3split_dedupped_sorted.bam\n",
" output: B1477.all_merged_3split_dedupped_sorted2.bam\n",
" jobid: 0\n",
" reason: Missing output files: B1477.all_merged_3split_dedupped_sorted2.bam\n",
" resources: tmpdir=/tmp\u001b[0m\n",
"\u001b[32m\u001b[0m\n",
"\u001b[32m[Tue Apr 2 18:24:48 2024]\u001b[0m\n",
"\u001b[32mFinished job 0.\u001b[0m\n",
"\u001b[32m1 of 1 steps (100%) done\u001b[0m\n",
"\u001b[33mComplete log: .snakemake/log/2024-04-02T182447.945729.snakemake.log\u001b[0m\n"
]
}
],
"source": [
"!snakemake --cores 1"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "92f2c41e-0634-4dc0-834d-0dd9774c47b1",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" B1477.all_merged_3split_dedupped_sorted2.bam\n",
" B1477.all_merged_3split_dedupped_sorted.bam\n",
" README.md\n",
" requirements.txt\n",
" runtime.txt\n",
" Snakefile\n",
"'Snakemake run test for SO question 78260730 with versions matching OP.ipynb'\n"
]
}
],
"source": [
"ls"
]
},
{
"cell_type": "markdown",
"id": "1c98de98-a163-4982-a413-6e74c70b742a",
"metadata": {},
"source": [
"Worked, and says reason for run: **`reason: Missing output files: B1477.all_merged_3split_dedupped_sorted2.bam`**.\n",
"\n",
"I didn't see that with version 7.3.8. Nice feature added since then it seems."
]
},
{
"cell_type": "markdown",
"id": "6bb0d2c8-9729-4da2-a54f-1e3004702f6b",
"metadata": {},
"source": [
"#### What if remove the output and do dry run?"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "10be6a4d-c233-46c7-8ab2-2dff15534071",
"metadata": {},
"outputs": [],
"source": [
"!rm -rf B1477.all_merged_3split_dedupped_sorted2.bam"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "73d5dbb3-f4f4-4901-82b5-ed505f89b7a0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" B1477.all_merged_3split_dedupped_sorted.bam\n",
" README.md\n",
" requirements.txt\n",
" runtime.txt\n",
" Snakefile\n",
"'Snakemake run test for SO question 78260730 with versions matching OP.ipynb'\n"
]
}
],
"source": [
"ls"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "80c41494-f8b7-425d-ada4-a3ea539e1c04",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mBuilding DAG of jobs...\u001b[0m\n",
"\u001b[33mJob stats:\n",
"job count\n",
"----- -------\n",
"A 1\n",
"total 1\n",
"\u001b[0m\n",
"\u001b[32m\u001b[0m\n",
"\u001b[32m[Tue Apr 2 18:24:53 2024]\u001b[0m\n",
"\u001b[32mrule A:\n",
" input: B1477.all_merged_3split_dedupped_sorted.bam\n",
" output: B1477.all_merged_3split_dedupped_sorted2.bam\n",
" jobid: 0\n",
" reason: Missing output files: B1477.all_merged_3split_dedupped_sorted2.bam\n",
" resources: tmpdir=/tmp\u001b[0m\n",
"\u001b[32m\u001b[0m\n",
"\u001b[33mJob stats:\n",
"job count\n",
"----- -------\n",
"A 1\n",
"total 1\n",
"\u001b[0m\n",
"\u001b[33mReasons:\n",
" (check individual jobs above for details)\n",
" missing output files:\n",
" A\u001b[0m\n",
"\u001b[33m\u001b[0m\n",
"\u001b[33mThis was a dry-run (flag -n). The order of jobs does not reflect the order of execution.\u001b[0m\n"
]
}
],
"source": [
"!snakemake -n"
]
},
{
"cell_type": "markdown",
"id": "6d6c7086-ccfa-49ad-8713-4fcc8074d7e2",
"metadata": {},
"source": [
"Indicates why it would run the rule: \n",
"\n",
"\n",
"```text\n",
"reason: Missing output files: B1477.all_merged_3split_dedupped_sorted2.bam\n",
"```"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment