Mercurial > repos > tomnl > create_msp
diff frag4feature.R @ 18:49e063070647 draft
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit a598583947118bd50cfe5ae12d955c20d6e502a6
author | tomnl |
---|---|
date | Tue, 17 Jul 2018 12:30:24 -0400 |
parents | dd6a4d101f9a |
children |
line wrap: on
line diff
--- a/frag4feature.R Thu Jun 14 09:25:22 2018 -0400 +++ b/frag4feature.R Tue Jul 17 12:30:24 2018 -0400 @@ -3,7 +3,7 @@ library(xcms) print(sessionInfo()) -xset_pa_filename_fix <- function(opt, pa, xset){ +xset_pa_filename_fix <- function(opt, pa, xset=NULL){ if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)){ @@ -26,19 +26,22 @@ pa@puritydf$filename <- basename(pa@fileList[match(pa@puritydf$filename, old_filenames)]) pa@grped_df$filename <- basename(pa@fileList[match(pa@grped_df$filename, old_filenames)]) } - print(pa@fileList) - print(xset@filepaths) + print(pa@fileList) + + if(!is.null(xset)){ + + print(xset@filepaths) - if(!all(basename(pa@fileList)==basename(xset@filepaths))){ - if(!all(names(pa@fileList)==basename(xset@filepaths))){ - print('FILELISTS DO NOT MATCH') - message('FILELISTS DO NOT MATCH') - quit(status = 1) - }else{ - xset@filepaths <- unname(pa@fileList) - } - } - + if(!all(basename(pa@fileList)==basename(xset@filepaths))){ + if(!all(names(pa@fileList)==basename(xset@filepaths))){ + print('FILELISTS DO NOT MATCH') + message('FILELISTS DO NOT MATCH') + quit(status = 1) + }else{ + xset@filepaths <- unname(pa@fileList) + } + } + } return(list(pa, xset)) } @@ -56,12 +59,15 @@ make_option("--cores", default=4), make_option("--mzML_files", type="character"), make_option("--galaxy_names", type="character"), - make_option("--grp_peaklist", type="character") + make_option("--grp_peaklist", type="character"), + make_option("--use_group", action="store_true") ) # store options opt<- parse_args(OptionParser(option_list=option_list)) +print(opt) + loadRData <- function(rdata_path, name){ #loads an RData file, and returns the named xset object if it is there load(rdata_path) @@ -111,10 +117,19 @@ createDB = TRUE } +if(is.null(opt$use_group)){ + fix <- xset_pa_filename_fix(opt, pa, xset) + pa <- fix[[1]] + xset <- fix[[2]] + use_group=FALSE +}else{ + # if are only aligning to the group not eah file we do not need to align the files between the xset and pa object + print('use_group') + fix <- xset_pa_filename_fix(opt, pa) + pa <- fix[[1]] + use_group=TRUE +} -fix <- xset_pa_filename_fix(opt, pa, xset) -pa <- fix[[1]] -xset <- fix[[2]] if(is.null(opt$grp_peaklist)){ grp_peaklist = NA @@ -130,7 +145,7 @@ pa <- msPurity::frag4feature(pa=pa, xset=xset, ppm=opt$ppm, plim=opt$plim, intense=opt$mostIntense, convert2RawRT=convert2RawRT, db_name='alldata.sqlite', out_dir=opt$out_dir, grp_peaklist=grp_peaklist, - create_db=createDB) + create_db=createDB, use_group=use_group) save(pa, file=file.path(opt$out_dir, 'frag4feature.RData'))