Skip to content

Commit

Permalink
Merge pull request #306 from daichengxin/dev
Browse files Browse the repository at this point in the history
Add warning info and set mass accurancy automatic for DIA when Dalton input(Don't merge)
  • Loading branch information
ypriverol authored Oct 18, 2023
2 parents 490a547 + 0202115 commit 00c1251
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
8 changes: 4 additions & 4 deletions modules/local/assemble_empirical_library/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ process ASSEMBLE_EMPIRICAL_LIBRARY {

script:
def args = task.ext.args ?: ''
mass_acc_ms1 = meta['precursormasstoleranceunit'].toLowerCase().endsWith('ppm') ? meta['precursormasstolerance'] : 5
mass_acc_ms2 = meta['fragmentmasstoleranceunit'].toLowerCase().endsWith('ppm') ? meta['fragmentmasstolerance'] : 13

if (params.mass_acc_automatic) {
mass_acc = "--quick-mass-acc --individual-mass-acc"
mass_acc = '--quick-mass-acc --individual-mass-acc'
} else if (meta['precursormasstoleranceunit'].toLowerCase().endsWith('ppm') && meta['fragmentmasstoleranceunit'].toLowerCase().endsWith('ppm')){
mass_acc = "--mass-acc ${meta['fragmentmasstolerance']} --mass-acc-ms1 ${meta['precursormasstolerance']}"
} else {
mass_acc = "--mass-acc $mass_acc_ms2 --mass-acc-ms1 $mass_acc_ms1"
mass_acc = '--quick-mass-acc --individual-mass-acc'
}
scan_window = params.scan_window_automatic ? '--individual-windows' : "--window $params.scan_window"

Expand Down
7 changes: 4 additions & 3 deletions modules/local/diann_preliminary_analysis/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ process DIANN_PRELIMINARY_ANALYSIS {

// I am using here the ["key"] syntax, since the preprocessed meta makes
// was evaluating to null when using the dot notation.
mass_acc_ms1 = meta['precursormasstoleranceunit'].toLowerCase().endsWith('ppm') ? meta['precursormasstolerance'] : 5
mass_acc_ms2 = meta['fragmentmasstoleranceunit'].toLowerCase().endsWith('ppm') ? meta['fragmentmasstolerance'] : 13

if (params.mass_acc_automatic) {
mass_acc = '--quick-mass-acc --individual-mass-acc'
} else if (meta['precursormasstoleranceunit'].toLowerCase().endsWith('ppm') && meta['fragmentmasstoleranceunit'].toLowerCase().endsWith('ppm')){
mass_acc = "--mass-acc ${meta['fragmentmasstolerance']} --mass-acc-ms1 ${meta['precursormasstolerance']}"
} else {
mass_acc = "--mass-acc $mass_acc_ms2 --mass-acc-ms1 $mass_acc_ms1"
mass_acc = '--quick-mass-acc --individual-mass-acc'
}

scan_window = params.scan_window_automatic ? '--individual-windows' : '--window $params.scan_window'
time_corr_only = params.time_corr_only ? '--time-corr-only' : ''

Expand Down
11 changes: 8 additions & 3 deletions modules/local/diannsummary/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ process DIANNSUMMARY {

script:
def args = task.ext.args ?: ''
mass_acc_ms1 = meta["precursormasstoleranceunit"].toLowerCase().endsWith("ppm") ? meta["precursormasstolerance"] : 5
mass_acc_ms2 = meta["fragmentmasstoleranceunit"].toLowerCase().endsWith("ppm") ? meta["fragmentmasstolerance"] : 13

mass_acc = params.mass_acc_automatic ? "--quick-mass-acc --individual-mass-acc" : "--mass-acc $mass_acc_ms2 --mass-acc-ms1 $mass_acc_ms1"
if (params.mass_acc_automatic) {
mass_acc = '--quick-mass-acc --individual-mass-acc'
} else if (meta['precursormasstoleranceunit'].toLowerCase().endsWith('ppm') && meta['fragmentmasstoleranceunit'].toLowerCase().endsWith('ppm')){
mass_acc = "--mass-acc ${meta['fragmentmasstolerance']} --mass-acc-ms1 ${meta['precursormasstolerance']}"
} else {
mass_acc = '--quick-mass-acc --individual-mass-acc'
}

scan_window = params.scan_window_automatic ? "--individual-windows" : "--window $params.scan_window"
species_genes = params.species_genes ? "--species-genes": ""

Expand Down
9 changes: 7 additions & 2 deletions modules/local/individual_final_analysis/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ process INDIVIDUAL_FINAL_ANALYSIS {

script:
def args = task.ext.args ?: ''
mass_acc_ms1 = meta["precursormasstoleranceunit"].toLowerCase().endsWith("ppm") ? meta["precursormasstolerance"] : 5
mass_acc_ms2 = meta["fragmentmasstoleranceunit"].toLowerCase().endsWith("ppm") ? meta["fragmentmasstolerance"] : 13
scan_window = params.scan_window

if (params.mass_acc_automatic | params.scan_window_automatic){
mass_acc_ms2 = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 11 | tr -cd \"[0-9]\")"
scan_window = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 19 | tr -cd \"[0-9]\")"
mass_acc_ms1 = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 15 | tr -cd \"[0-9]\")"
} else if (meta['precursormasstoleranceunit'].toLowerCase().endsWith('ppm') && meta['fragmentmasstoleranceunit'].toLowerCase().endsWith('ppm')){
mass_acc_ms1 = meta["precursormasstolerance"]
mass_acc_ms2 = meta["fragmentmasstolerance"]
} else {
mass_acc_ms2 = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 11 | tr -cd \"[0-9]\")"
scan_window = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 19 | tr -cd \"[0-9]\")"
mass_acc_ms1 = "\$(cat ${diann_log} | grep \"Averaged recommended settings\" | cut -d ' ' -f 15 | tr -cd \"[0-9]\")"
}

"""
Expand Down
8 changes: 8 additions & 0 deletions workflows/dia.nf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ workflow DIA {

meta = ch_result.meta.unique { it[0] }

if (!params.mass_acc_automatic)
{
if (meta['fragmentmasstoleranceunit'].toLowerCase().endsWith('da') || meta['precursormasstoleranceunit'].toLowerCase().endsWith('da'))
{
log.info "Warning: DIA-NN only supports ppm unit tolerance for MS1 and MS2. Falling back to `mass_acc_automatic`=`true` to automatically determine the tolerance by DIA-NN!"
}
}

DIANNCFG(meta)
ch_software_versions = ch_software_versions.mix(DIANNCFG.out.version.ifEmpty(null))

Expand Down

0 comments on commit 00c1251

Please sign in to comment.