Skip to content

Commit

Permalink
scaffolding trio assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
yumisims committed Nov 5, 2024
1 parent 36730fc commit 47e93c2
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
25 changes: 23 additions & 2 deletions subworkflows/local/raw_assembly.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ include { HIFIASM as HIFIASM_HIC } from '../../modules/nf-core/hi

include { GFA_TO_FASTA as GFA_TO_FASTA_PRI } from '../../modules/local/gfa_to_fasta'
include { GFA_TO_FASTA as GFA_TO_FASTA_ALT } from '../../modules/local/gfa_to_fasta'
include { GFA_TO_FASTA as GFA_TO_FASTA_HAP1_HIC } from '../../modules/local/gfa_to_fasta'
include { GFA_TO_FASTA as GFA_TO_FASTA_HAP2_HIC } from '../../modules/local/gfa_to_fasta'
include { GFA_TO_FASTA as GFA_TO_FASTA_HAP1_HIC } from '../../modules/local/gfa_to_fasta'
include { GFA_TO_FASTA as GFA_TO_FASTA_HAP2_HIC } from '../../modules/local/gfa_to_fasta'
include { GFA_TO_FASTA as GFA_TO_FASTA_PAT_HIC } from '../../modules/local/gfa_to_fasta'
include { GFA_TO_FASTA as GFA_TO_FASTA_MAT_HIC } from '../../modules/local/gfa_to_fasta'

workflow RAW_ASSEMBLY {
take:
Expand Down Expand Up @@ -54,11 +56,30 @@ workflow RAW_ASSEMBLY {
GFA_TO_FASTA_HAP2_HIC( HIFIASM_HIC.out.hap2_contigs )
}

if ( hifiasm_trio_on ) {
//
// MODULE: RUN HIFIASM IN HIC MODE
//
HIFIASM_HIC(hifi_reads, [], [], [], [], hic_reads)

//
// MODULE: CONVERT HIFIASM-HIC PATERNAL CONTIGS TO FASTA
//
GFA_TO_FASTA_PAT_HIC( HIFIASM_HIC.out.paternal_contigs)

//
// MODULE: CONVERT HIFIASM-HIC MATERNAL CONTIGS TO FASTA
//
GFA_TO_FASTA_MAT_HIC( HIFIASM_HIC.out.maternal_contigs )
}

emit:
primary_contigs = GFA_TO_FASTA_PRI.out.fasta
alternate_contigs = GFA_TO_FASTA_ALT.out.fasta
hap1_hic_contigs = hifiasm_hic_on ? GFA_TO_FASTA_HAP1_HIC.out.fasta : null
hap2_hic_contigs = hifiasm_hic_on ? GFA_TO_FASTA_HAP2_HIC.out.fasta : null
pat_hic_contigs = hifiasm_trio_on ? GFA_TO_FASTA_PAT_HIC.out.fasta : null
mat_hic_contigs = hifiasm_trio_on ? GFA_TO_FASTA_MAT_HIC.out.fasta : null

versions = ch_versions
}
51 changes: 51 additions & 0 deletions workflows/genomeassembly.nf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if (params.cool_bin) { cool_bin = params.cool_bin } else { cool_bin = 1000; }

if (params.polishing_on) { polishing_on = params.polishing_on } else { polishing_on = false; }
if (params.hifiasm_hic_on) { hifiasm_hic_on = params.hifiasm_hic_on } else { hifiasm_hic_on = false; }
if (params.hifiasm_trio_on) { hifiasm_trio_on = params.hifiasm_trio_on } else { hifiasm_trio_on = false; }
if (params.organelles_on) { organelles_on = params.organelles_on } else { organelles_on = false; }

// Declare constants to toggle BUSCO for alts
Expand Down Expand Up @@ -49,17 +50,22 @@ include { POLISHING } from '../subwo
include { SCAFFOLDING } from '../subworkflows/local/scaffolding'
include { SCAFFOLDING as SCAFFOLDING_HAP1 } from '../subworkflows/local/scaffolding'
include { SCAFFOLDING as SCAFFOLDING_HAP2 } from '../subworkflows/local/scaffolding'
include { SCAFFOLDING as SCAFFOLDING_PAT } from '../subworkflows/local/scaffolding'
include { SCAFFOLDING as SCAFFOLDING_MAT } from '../subworkflows/local/scaffolding'
include { KEEP_SEQNAMES as KEEP_SEQNAMES_PRIMARY } from '../modules/local/keep_seqnames'
include { KEEP_SEQNAMES as KEEP_SEQNAMES_HAPLOTIGS } from '../modules/local/keep_seqnames'
include { HIC_MAPPING } from '../subworkflows/local/hic_mapping'
include { HIC_MAPPING as HIC_MAPPING_HAP1 } from '../subworkflows/local/hic_mapping'
include { HIC_MAPPING as HIC_MAPPING_HAP2 } from '../subworkflows/local/hic_mapping'
include { HIC_MAPPING as HIC_MAPPING_PAT } from '../subworkflows/local/hic_mapping'
include { HIC_MAPPING as HIC_MAPPING_MAT } from '../subworkflows/local/hic_mapping'
include { GENOME_STATISTICS as GENOME_STATISTICS_RAW } from '../subworkflows/local/genome_statistics'
include { GENOME_STATISTICS as GENOME_STATISTICS_RAW_HIC } from '../subworkflows/local/genome_statistics'
include { GENOME_STATISTICS as GENOME_STATISTICS_PURGED } from '../subworkflows/local/genome_statistics'
include { GENOME_STATISTICS as GENOME_STATISTICS_POLISHED } from '../subworkflows/local/genome_statistics'
include { GENOME_STATISTICS as GENOME_STATISTICS_SCAFFOLDS } from '../subworkflows/local/genome_statistics'
include { GENOME_STATISTICS as GENOME_STATISTICS_SCAFFOLDS_HAPS } from '../subworkflows/local/genome_statistics'
include { GENOME_STATISTICS as GENOME_STATISTICS_SCAFFOLDS_TRIO } from '../subworkflows/local/genome_statistics'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -428,6 +434,51 @@ workflow GENOMEASSEMBLY {
[],
set_busco_alts
)
}

if ( hifiasm_trio_on ) {
//
// SUBWORKFLOW: MAP HIC DATA TO THE HAP1 CONTIGS
//
HIC_MAPPING_PAT ( RAW_ASSEMBLY.out.pat_hic_contigs, crams_ch, hic_aligner_ch, 'pat' )
ch_versions = ch_versions.mix(HIC_MAPPING_HAP1.out.versions)

//
// SUBWORKFLOW: SCAFFOLD PAT
//
SCAFFOLDING_PAT( HIC_MAPPING_PAT.out.bed, RAW_ASSEMBLY.out.pat_hic_contigs, cool_bin, 'pat' )
ch_versions = ch_versions.mix(SCAFFOLDING_PAT.out.versions)

//
// SUBWORKFLOW: MAP HIC DATA TO THE HAP2 CONTIGS
//
HIC_MAPPING_MAT ( RAW_ASSEMBLY.out.mat_hic_contigs, crams_ch, hic_aligner_ch, 'mat' )
ch_versions = ch_versions.mix(HIC_MAPPING_MAT.out.versions)

//
// SUBWORKFLOW: SCAFFOLD MAT
//
SCAFFOLDING_MAT( HIC_MAPPING_MAT.out.bed, RAW_ASSEMBLY.out.mat_hic_contigs, cool_bin, 'mat' )
ch_versions = ch_versions.mix(SCAFFOLDING_MAT.out.versions)

//
// LOGIC: CREATE A CHANNEL FOR THE FULL PAT/MAT ASSEMBLY
//
SCAFFOLDING_PAT.out.fasta.combine(SCAFFOLDING_PAT.out.fasta)
.map{meta_s, fasta_s, meta_h, fasta_h -> [ [id:meta_h.id], fasta_s, fasta_h ]}
.set{ stats_trio_input_ch }

//
// SUBWORKFLOW: CALCULATE ASSEMBLY STATISTICS FOR PAT/MAT ASSEMBLY
//
GENOME_STATISTICS_SCAFFOLDS_TRIO( stats_trio_input_ch,
PREPARE_INPUT.out.busco,
GENOMESCOPE_MODEL.out.hist,
GENOMESCOPE_MODEL.out.ktab,
[],
[],
set_busco_alts
)

}

Expand Down

0 comments on commit 47e93c2

Please sign in to comment.