Skip to content

Commit

Permalink
last update
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoli-dong committed Nov 22, 2023
1 parent b4f8cdb commit 7f8c57b
Show file tree
Hide file tree
Showing 18 changed files with 450 additions and 114 deletions.
30 changes: 30 additions & 0 deletions bin/formatCSV.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
import click
import os
import csv

@click.command()
@click.option("-n", "--sample-name", default="", help="Sample Name.")
@click.option("-o", "--output-csv", default="", help="output csv file")
@click.option("-s", "--sep", default="\t", help="csv file separator")
@click.argument("input_csv", nargs=-1)
def reformat_csv(sample_name, output_csv, input_csv, sep):

for csvfile in input_csv:
with open(csvfile, "r", encoding="utf8") as in_file:
csvreader = csv.DictReader(in_file, delimiter=sep)
header = csvreader.fieldnames
header[0] = "sampleid"

rows = []
for row in csvreader:
row[header[0]] = sample_name
rows.append(row)

with open(output_csv, "w") as file:
writer = csv.DictWriter(file, fieldnames=header, delimiter=sep)
writer.writeheader()
writer.writerows(rows)

if __name__ == "__main__":
reformat_csv()
26 changes: 22 additions & 4 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,39 @@ if(!params.skip_mobsuite) {
//ext.prefix = { "${meta.id}.mobsuite" }
ext.prefix = ""
publishDir = [
path: { "${params.outdir}/${meta.id}/plasmid/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" },
path: { "${params.outdir}/${meta.id}/plasmid/mobsuite" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : "${meta.id}_${filename}" },
pattern: '*.{mobtyper_results.txt,plasmid_*.fasta}'
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: '*.{contig_report.txt,mobtyper_results.txt,plasmid_*.fasta}'
]

}
withName: CSVTK_CONCAT_MOBSUITE{
withName: CSVTK_CONCAT_MOBTYPER_RESULTS {
publishDir = [
path: { "${params.outdir}/report" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },

]
}
withName: CSVTK_CONCAT_CONTIG_REPORT {
publishDir = [
path: { "${params.outdir}/report" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },

]
}
withName: CSVTK_FILTER2{
ext.prefix = { "${meta.id}.contig_report.plasmid" }
ext.args = " -f \'\$molecule_type==\"plasmid\"\' -t"
publishDir = [
path: { "${params.outdir}/${meta.id}/plasmid/mobsuite" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },

]
}
}
}

Expand Down
69 changes: 68 additions & 1 deletion conf/modules_illumina.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ if(!params.skip_illumina_reads_qc){
}
withName: SEQKIT_STATS_INPUT_ILLUMINA {
ext.prefix = { "${meta.id}.seqstats" }
ext.args = '-Ta '
publishDir = [
path: { "${params.outdir}/${meta.id}/reads/illumina_reads/raw/stats" },
mode: params.publish_dir_mode,
Expand Down Expand Up @@ -88,6 +89,7 @@ if(!params.skip_illumina_reads_qc){

withName: SEQKIT_STATS_QC_ILLUMINA{
ext.prefix = { "${meta.id}.bbduk_seqstats" }
ext.args = '-Ta '
publishDir = [
path: { "${params.outdir}/${meta.id}/reads/illumina_reads/qc/stats" },
mode: params.publish_dir_mode,
Expand Down Expand Up @@ -133,6 +135,7 @@ if(!params.skip_illumina_reads_qc){
}
withName: SEQKIT_STATS_QC_ILLUMINA {
ext.prefix = { "${meta.id}.fastp_seqstats" }
ext.args = '-Ta '
publishDir = [
path: { "${params.outdir}/${meta.id}/reads/illumina_reads/qc/stats" },
mode: params.publish_dir_mode,
Expand Down Expand Up @@ -181,6 +184,18 @@ if(!params.skip_illumina_reads_assembly){

}
withName: STATS_SKESA {
//ext.prefix = { "${meta.id}.contigs_stats" }
ext.args = '-t'
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/illumina/skesa" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*",
enabled: false
]

}
withName: STATS_SKESA_REFORMAT {
ext.prefix = { "${meta.id}.contigs_stats" }
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/illumina/skesa" },
Expand All @@ -201,7 +216,20 @@ if(!params.skip_illumina_reads_assembly){

}
withName: STATS_SPADES {
//ext.prefix = { "${meta.id}.contigs_stats" }
ext.args = '-t'
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/illumina/spades" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*",
enabled: false
]

}
withName: STATS_SPADES_REFORMAT {
ext.prefix = { "${meta.id}.contigs_stats" }
//ext.args = '-t'
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/illumina/spades" },
mode: params.publish_dir_mode,
Expand All @@ -221,7 +249,20 @@ if(!params.skip_illumina_reads_assembly){

}
withName: STATS_UNICYCLER {
ext.prefix = { "${meta.id}.contig_stats" }
//ext.prefix = { "${meta.id}.contig_stats" }
ext.args = '-t'
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/illumina/unicycler" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*",
enabled: false
]


}
withName: STATS_UNICYCLER_REFORMAT {
ext.prefix = { "${meta.id}.contigs_stats" }
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/illumina/unicycler" },
mode: params.publish_dir_mode,
Expand All @@ -240,6 +281,18 @@ if(!params.skip_illumina_reads_assembly){

}
withName: STATS_MEGAHIT {
//ext.prefix = { "${meta.id}.contigs_stats" }
ext.args = '-t'
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/illumina/megahit" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*",
enabled: false
]

}
withName: STATS_MEGAHIT_REFORMAT {
ext.prefix = { "${meta.id}.contigs_stats" }
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/illumina/megahit" },
Expand All @@ -263,6 +316,19 @@ if(!params.skip_illumina_reads_assembly){

}
withName: STATS_SHOVILL {
//ext.prefix = { "${meta.id}.contigs_stats" }
ext.args = '-t'
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/illumina/shovill" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*",
enabled: false
]


}
withName: STATS_SHOVILL_REFORMAT {
ext.prefix = { "${meta.id}.contigs_stats" }
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/illumina/shovill" },
Expand All @@ -273,6 +339,7 @@ if(!params.skip_illumina_reads_assembly){

}


withName: CSVTK_CONCAT_STATS_ASM{
publishDir = [
path: { "${params.outdir}/report" },
Expand Down
77 changes: 68 additions & 9 deletions conf/modules_nanopore.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if(!params.skip_illumina_reads_qc){
}
withName: SEQKIT_STATS_INPUT_ILLUMINA {
ext.prefix = { "${meta.id}.seqstats" }
ext.args = '-Ta '
publishDir = [
path: { "${params.outdir}/${meta.id}/reads/illumina_reads/input/stats" },
mode: params.publish_dir_mode,
Expand Down Expand Up @@ -85,6 +86,7 @@ if(!params.skip_illumina_reads_qc){

withName: SEQKIT_STATS_QC_ILLUMINA {
ext.prefix = { "${meta.id}.bbduk_seqstats" }
ext.args = '-Ta '
publishDir = [
path: { "${params.outdir}/${meta.id}/reads/illumina_reads/qc/stats" },
mode: params.publish_dir_mode,
Expand Down Expand Up @@ -130,6 +132,7 @@ if(!params.skip_illumina_reads_qc){
}
withName: SEQKIT_STATS_QC_ILLUMINA {
ext.prefix = { "${meta.id}.fastp_seqstats" }
ext.args = '-Ta '
publishDir = [
path: { "${params.outdir}/${meta.id}/reads/illumina_reads/qc/stats" },
mode: params.publish_dir_mode,
Expand Down Expand Up @@ -170,6 +173,7 @@ if(!params.skip_nanopore_reads_qc){
process {
withName: SEQKIT_STATS_INPUT {
ext.prefix = { "${meta.id}.seqstats" }
ext.args = '-Ta '
publishDir = [
path: { "${params.outdir}/${meta.id}/reads/nanopore_reads/input/stats" },
mode: params.publish_dir_mode,
Expand Down Expand Up @@ -215,6 +219,7 @@ if(!params.skip_nanopore_reads_qc){
}
withName: SEQKIT_STATS_PORECHOP {
ext.prefix = { "${meta.id}.porechop_seqstats" }
ext.args = '-Ta '
publishDir = [
path: { "${params.outdir}/${meta.id}/reads/nanopore_reads/qc/stats" },
mode: params.publish_dir_mode,
Expand All @@ -240,6 +245,7 @@ if(!params.skip_nanopore_reads_qc){
}
withName: SEQKIT_STATS_CHOPPER {
ext.prefix = { "${meta.id}.chopper_seqstats" }
ext.args = '-Ta '
publishDir = [
path: { "${params.outdir}/${meta.id}/reads/nanopore_reads/qc/stats" },
mode: params.publish_dir_mode,
Expand Down Expand Up @@ -270,15 +276,29 @@ if(!params.skip_nanopore_reads_assembly){
pattern: "*"
]
}
withName: SEQKIT_STATS_FLYE {
ext.prefix = { "${meta.id}.flye_contigs.stats" }
withName: STATS_FLYE {
//ext.prefix = { "${meta.id}.flye_contigs.stats" }
ext.args = "-t"
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/nanopore/flye" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*",
enabled: false
]
}
withName: STATS_FLYE_REFORMAT {
ext.prefix = { "${meta.id}.contig_stats" }

publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/nanopore/flye" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*"
]

}

withName: RESTARTGENOME {

publishDir = [
Expand All @@ -297,14 +317,27 @@ if(!params.skip_nanopore_reads_assembly){
pattern: "*"
]
}
withName: SEQKIT_STATS_MEDAKA {
ext.prefix = { "${meta.id}.contigs.stats" }
withName: STATS_MEDAKA {
//ext.prefix = { "${meta.id}.contigs.stats" }
ext.args = "-t"
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/nanopore/medaka" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*",
enabled: false
]
}
withName: STATS_MEDAKA_REFORMAT {
ext.prefix = { "${meta.id}.contig_stats" }

publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/nanopore/medaka" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*"
]

}
withName: CSVTK_CONCAT_STATS_ASM{
publishDir = [
Expand All @@ -328,15 +361,28 @@ if(!params.skip_nanopore_reads_assembly){
pattern: "*"
]
}
withName: SEQKIT_STATS_POLYPOLISH {
ext.prefix = { "${meta.id}.contigs.stats" }
withName: STATS_POLYPOLISH {
//ext.prefix = { "${meta.id}.contigs.stats" }
ext.args = "-t"
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/nanopore/polypolish" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*"
pattern: "*",
enabled: false
]
}
withName: STATS_POLYPOLISH_REFORMAT {
ext.prefix = { "${meta.id}.contig_stats" }

publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/nanopore/polypolish" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*"
]

}
withName: MINIMAP2_ALIGN {
//ext.prefix = { "${meta.id}" }
ext.args = "-x sr"
Expand Down Expand Up @@ -431,14 +477,27 @@ if(!params.skip_nanopore_reads_assembly){
]
}

withName: SEQKIT_STATS_POLCA {
ext.prefix = { "${meta.id}.contigs.stats" }
withName: STATS_POLCA {
//ext.prefix = { "${meta.id}.contigs.stats" }
ext.args = "-t"
publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/nanopore/polca" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*",
enabled: false
]
}
withName: STATS_POLCA_REFORMAT {
ext.prefix = { "${meta.id}.contig_stats" }

publishDir = [
path: { "${params.outdir}/${meta.id}/assembly/nanopore/polca" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
pattern: "*"
]

}
}
}
Expand Down
5 changes: 0 additions & 5 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@
"git_sha": "3ffae3598260a99e8db3207dead9f73f87f90d1f",
"installed_by": ["modules"]
},
"seqkit/stats": {
"branch": "master",
"git_sha": "911696ea0b62df80e900ef244d7867d177971f73",
"installed_by": ["modules"]
},
"shovill": {
"branch": "master",
"git_sha": "8fc1d24c710ebe1d5de0f2447ec9439fd3d9d66a",
Expand Down
Loading

0 comments on commit 7f8c57b

Please sign in to comment.