Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Pan1c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexis Mergez
Pan1c
Commits
54bfb1b1
Commit
54bfb1b1
authored
11 months ago
by
Alexis Mergez
Browse files
Options
Downloads
Patches
Plain Diff
Update Snakefile
parent
8b1ca53c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!12
v1.7
Pipeline
#184152
failed
11 months ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Snakefile
+54
-31
54 additions, 31 deletions
Snakefile
with
54 additions
and
31 deletions
Snakefile
+
54
−
31
View file @
54bfb1b1
configfile: "config.yaml"
## Modules
import os
import numpy as np
import gzip
import re
# Getting the list of haplotypes (SAMPLES)
"""
Main variables used in the workflow
"""
# Retrieving the list of haplotypes (SAMPLES) in data/haplotypes
SAMPLES = np.unique([
os.path.basename(f).split('.fa')[0]
for f in os.listdir("data/haplotypes/")
if re.search(r".fa", f)
])
# Retrieving the list of haplotypes excluding the reference
SAMPLES_NOREF = [
sample
for sample in SAMPLES
if sample != os.path.basename(config['reference']).split('.fa')[0]
]
# Storing the number of haplotypes
nHAP = len(SAMPLES)
#
G
et
t
ing the list of chromosomes
#
R
et
riev
ing the list of chromosomes
from the fasta index of the reference
with gzip.open("data/haplotypes/"+config['reference'], "r") as handle:
CHRLIST = [line.decode().split("#")[-1].split('\n')[0] for line in handle.readlines() if line.decode()[0] == ">"]
#
Configuring steps
to
b
e
d
one
#
Adjusting the requested outputs according
to
th
e
c
on
fig fil
e
def which_analysis():
# Creating a list with default analysis steps (to prevent the function from returning an empty list)
analysis_inputs = [
...
...
@@ -30,25 +40,36 @@ def which_analysis():
expand("output/panacus.reports/{chromosome}.histgrowth.html", chromosome=CHRLIST), # panacus histgrowth
expand("output/chrGraphs.figs/{chromosome}.1Dviz.png", chromosome=CHRLIST), # visualizations from odgi on chromosome graphs
"output/pan1c.pggb."+config['name']+".chrGraph.general.stats.tsv" # chromosomes graph statistics
]
]
# Optionals analysis steps
if config["get_PAV"] == "True":
if config["get_PAV"] == "True":
# Adding PAV matrix creation
analysis_inputs.append("output/pav.matrices")
if config["get_allASM_SyRI"] == "True":
if config["get_allASM_SyRI"] == "True":
# Creating the figure for all assemblies
analysis_inputs.append("output/asm.syri.figs/pan1c."+config['name']+".allAsm.syri.png")
if config["get_ASMs_SyRI"] == "True":
if config["get_ASMs_SyRI"] == "True":
# Creating SyRI for each figures
analysis_inputs.append(
expand("output/asm.syri.figs/pan1c."+config['name']+".{haplotype}.syri.png", haplotype=SAMPLES_NOREF), # syri for haplotypes
)
return analysis_inputs
"""
Rules
"""
# Main target rule
rule all:
input:
"output/pan1c.pggb."+config['name']+".gfa", # Final graph (main output)
"output/pan1c.pggb."+config['name']+".gfa.metadata", # Metadata for the final (also in top of gfa files as # line)
which_analysis()
"""
Tool rules
"""
rule samtools_index:
# Samtools faidx to index compressed fasta
input:
...
...
@@ -64,10 +85,10 @@ rule samtools_index:
"faidx {input.fa}"
"""
Pre-processing section
Preparing pggb inputs
"""
Pre-processing section : preparing pggb inputs
"""
rule ragtag_scaffolding:
# Scaffold input haplotype against the reference to infer chromosome scale sequences
input:
...
...
@@ -91,6 +112,25 @@ rule ragtag_scaffolding:
-o {output}
"""
rule clustering:
# Read ragtagged fastas and split chromosome sequences into according bins
input:
expand('data/hap.ragtagged/{haplotype}.ragtagged.fa.gz', haplotype=SAMPLES)
output:
expand('data/chrInputs/{chromosome}.fa.gz', chromosome=CHRLIST)
threads: workflow.cores
params:
apppath=config["app.path"]
shell:
"""
mkdir -p $(dirname {output[0]})
apptainer run {params.apppath}/pan1c-env.sif python scripts/inputClustering.py \
--fasta {input} --output $(dirname {output[0]})
for file in $(dirname {output[0]})/*.fa; do
apptainer run --app bgzip {params.apppath}/PanGeTools.sif -@ {threads} $file
done
"""
rule create_allAsm_syri_fig:
# Create a SyRI figure containing all input assemblies
input:
...
...
@@ -140,28 +180,10 @@ rule create_sglAsm_syri_fig:
"""
"""
Core section
"""
rule clustering:
# Read ragtagged fastas and split chromosome sequences into according bins
input:
expand('data/hap.ragtagged/{haplotype}.ragtagged.fa.gz', haplotype=SAMPLES)
output:
expand('data/chrInputs/{chromosome}.fa.gz', chromosome=CHRLIST)
threads: workflow.cores
params:
apppath=config["app.path"]
shell:
"""
mkdir -p $(dirname {output[0]})
apptainer run {params.apppath}/pan1c-env.sif python scripts/inputClustering.py \
--fasta {input} --output $(dirname {output[0]})
for file in $(dirname {output[0]})/*.fa; do
apptainer run --app bgzip {params.apppath}/PanGeTools.sif -@ {threads} $file
done
"""
Core section : Running PGGB
"""
rule create_pggb_input_syri_fig:
input:
fasta='data/chrInputs/{chromosome}.fa.gz'
...
...
@@ -372,12 +394,13 @@ rule core_statistics:
"""
"""
Post-processing section :
The graph for each chromosome are made as well as some basic statistics.
In this section, more stats are produced but more specifics ones requiring dedicated tools (Panacus, PAVs for Panache ...).
It also contains rules to use the graph itself.
"""
"""
rule get_pav:
# Create PAV matrix readable by panache for a given chromosome scale graph
input:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment