Mercurial > repos > nturaga > minfi_pipeline
comparison help/help-scripts/r_dep_gen.R @ 0:84361ce36a11 draft
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
| author | nturaga |
|---|---|
| date | Tue, 19 Apr 2016 11:10:25 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:84361ce36a11 |
|---|---|
| 1 packageExpand = function(packagelist,fl) { | |
| 2 res = NULL | |
| 3 for (i in c(1:length(packagelist))) { | |
| 4 s = packagelist[i] | |
| 5 ls = nchar(s) | |
| 6 spos = which(substr(fl,1,ls) == s,arr.ind=T) | |
| 7 lspos = length(spos) | |
| 8 if (lspos > 0) | |
| 9 { | |
| 10 fullname = fl[spos] | |
| 11 if (grepl('*.gz',fullname)) { | |
| 12 row = paste(ps,fullname,pe,sep='') | |
| 13 res = append(res,row) | |
| 14 } | |
| 15 } | |
| 16 } | |
| 17 return(res) | |
| 18 } | |
| 19 | |
| 20 getPackages = function(packs) | |
| 21 { | |
| 22 packages = unlist(tools::package_dependencies(packs, available.packages(), | |
| 23 which=c("Depends", "Imports"), recursive=TRUE)) | |
| 24 packages = union(packs, packages) | |
| 25 packages | |
| 26 } | |
| 27 | |
| 28 ourargs = commandArgs(TRUE) | |
| 29 if(length(ourargs)==0){ | |
| 30 print("No arguments supplied.") | |
| 31 }else{ | |
| 32 for(i in 1:length(ourargs)){ | |
| 33 eval(parse(text=ourargs[[i]])) | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 unesc = function(x) { | |
| 38 res = x | |
| 39 res = gsub('__lt__','<',res) | |
| 40 res = gsub('__gt__','>',res) | |
| 41 return(res) | |
| 42 } | |
| 43 | |
| 44 our_packages = strsplit(ourpackages," ")[[1]] | |
| 45 ps=unesc(xmlprefix) | |
| 46 pe="?raw=true</package>" | |
| 47 | |
| 48 print(paste('tardir=',tardir,'xmlprefix=',xmlprefix,'ourpackages=',ourpackages,'OUTPATH=',OUTPATH)) | |
| 49 | |
| 50 | |
| 51 setRepositories(ind=1:2) | |
| 52 chooseBioCmirror(ind=7,graphics=F) # canberra - use eg 1 for FredHutch | |
| 53 chooseCRANmirror(ind=5,graphics=F) # Melbourne - use 96 for texas | |
| 54 | |
| 55 ifreq = function(pkg='DESeq2') { | |
| 56 if(require(package=pkg,character.only = T)){ | |
| 57 print(paste(pkg,"is loaded correctly")) | |
| 58 } else { | |
| 59 print(paste("trying to install",pkg)) | |
| 60 install.packages(pkg) | |
| 61 if(require(package=pkg,character.only = T)){ | |
| 62 print(paste(pkg,"installed and loaded correctly")) | |
| 63 } else { | |
| 64 stop(paste("Could not install",pkg)) | |
| 65 } | |
| 66 } | |
| 67 } | |
| 68 | |
| 69 ifreq(pkg="BiocInstaller") | |
| 70 ifreq(pkg="pkgDepTools") | |
| 71 ifreq(pkg="Biobase") | |
| 72 | |
| 73 print.noquote('Greetings! The R you have chosen is using the following repositories:') | |
| 74 print.noquote(biocinstallRepos()) | |
| 75 packages = getPackages(our_packages) | |
| 76 download.packages(pkgs=packages,destdir=tardir, type="source", repos=biocinstallRepos()) | |
| 77 flist = list.files(tardir) | |
| 78 allDeps = makeDepGraph(biocinstallRepos(), type="source", keep.builtin=F, dosize=F) | |
| 79 res = NULL | |
| 80 for (i in c(1:length(our_packages))) { | |
| 81 package = our_packages[i] | |
| 82 io = getInstallOrder(package, allDeps, needed.only=FALSE) | |
| 83 ares = packageExpand(packagelist=io$packages,fl=flist) | |
| 84 res = append(res,ares) | |
| 85 } | |
| 86 ures = unique(res) | |
| 87 tout = "savedeps.xml" | |
| 88 write.table(ures,file=tout,quote=F,sep="\t",row.names=F,col.names=F) | |
| 89 write.table(ures,file=OUTPATH,quote=F,sep="\t",row.names=F,col.names=F) | |
| 90 print.noquote(res) | |
| 91 sessionInfo() | |
| 92 print.noquote(date()) |
