annotate PSM2SAM.R @ 3:16c4cc7793e9 draft default tip

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit d4b5497065b853ed094aebc9e4185e9995c5e0e0
author galaxyp
date Wed, 01 Nov 2017 19:28:25 -0400
parents 757ecf27b4a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
1 #!/usr/bin/env Rscript
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
2
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
3 ## begin warning handler
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
4 withCallingHandlers({
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
5
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
6 library(methods) # Because Rscript does not always do this
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
7
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
8 options('useFancyQuotes' = FALSE)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
9
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
10 suppressPackageStartupMessages(library("optparse"))
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
11 suppressPackageStartupMessages(library("RGalaxy"))
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
12
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
13
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
14 option_list <- list()
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
15
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
16 option_list$exon_anno <- make_option('--exon_anno', type='character')
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
17 option_list$proteinseq <- make_option('--proteinseq', type='character')
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
18 option_list$procodingseq <- make_option('--procodingseq', type='character')
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
19 option_list$bam_file <- make_option('--bam', type='character')
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
20 option_list$idpDB_file <- make_option('--idpDB', type='character')
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
21 option_list$pepXmlTab_file <- make_option('--pepXmlTab', type='character')
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
22 option_list$peptideShakerPsmReport_file <- make_option('--peptideShakerPsmReport', type='character')
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
23 option_list$variantAnnotation_file <- make_option('--variantAnnotation', type='character')
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
24 option_list$searchEngineScore <- make_option('--searchEngineScore', type='character')
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
25
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
26
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
27 opt <- parse_args(OptionParser(option_list=option_list))
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
28
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
29
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
30 psm2sam <- function(
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
31 exon_anno_file = GalaxyInputFile(required=TRUE),
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
32 proteinseq_file = GalaxyInputFile(required=TRUE),
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
33 procodingseq_file = GalaxyInputFile(required=TRUE),
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
34 bam_file = GalaxyInputFile(required=TRUE),
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
35 idpDB_file = GalaxyInputFile(required=FALSE),
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
36 pepXmlTab_file = GalaxyInputFile(required=FALSE),
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
37 peptideShakerPsmReport_file = GalaxyInputFile(required=FALSE),
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
38 variantAnnotation_file = GalaxyInputFile(required=FALSE),
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
39 searchEngineScore = GalaxyCharacterParam(required=FALSE)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
40 )
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
41 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
42 options(stringsAsFactors = FALSE)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
43
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
44 if (length(bam_file) == 0)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
45 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
46 stop("BAM file must be specified to provide sequence headers")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
47 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
48
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
49 outputHeader = grep("^@(?!PG)", readLines(bam_file, n=500, warn=FALSE), value=TRUE, perl=TRUE)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
50 if (length(outputHeader) == 0)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
51 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
52 stop("failed to read header lines from bam_file")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
53 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
54
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
55 # load customProDB from GitHub (NOTE: downloading the zip is faster than cloning the repo with git2r or devtools::install_github)
3
16c4cc7793e9 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit d4b5497065b853ed094aebc9e4185e9995c5e0e0
galaxyp
parents: 2
diff changeset
56 download.file("https://github.com/chambm/customProDB/archive/9db2223ef9932e50124b92d1bc49206af1f40fb3.zip", "customProDB.zip", quiet=TRUE)
0
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
57 unzip("customProDB.zip")
3
16c4cc7793e9 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit d4b5497065b853ed094aebc9e4185e9995c5e0e0
galaxyp
parents: 2
diff changeset
58 devtools::load_all("customProDB-9db2223ef9932e50124b92d1bc49206af1f40fb3")
0
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
59
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
60 # load proBAMr from GitHub
2
757ecf27b4a9 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 969036a4673f5565185badb0d4fe513a7b784261
galaxyp
parents: 0
diff changeset
61 download.file("https://github.com/chambm/proBAMr/archive/a03edf68f51215be40717c5374f39ce67bd2e68b.zip", "proBAMr.zip", quiet=TRUE)
0
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
62 unzip("proBAMr.zip")
2
757ecf27b4a9 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 969036a4673f5565185badb0d4fe513a7b784261
galaxyp
parents: 0
diff changeset
63 devtools::load_all("proBAMr-a03edf68f51215be40717c5374f39ce67bd2e68b")
0
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
64
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
65 psmInputLength = length(idpDB_file)+length(pepXmlTab_file)+length(peptideShakerPsmReport_file)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
66 if (psmInputLength == 0)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
67 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
68 stop("one of the input PSM file parameters must be specified")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
69 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
70 else if (psmInputLength > 1)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
71 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
72 stop("only one of the input PSM file parameters can be specified")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
73 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
74
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
75 if (length(idpDB_file) > 0)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
76 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
77 if (length(searchEngineScore) == 0)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
78 stop("searchEngineScore parameter must be specified when reading IDPicker PSMs, e.g. 'MyriMatch:MVH'")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
79 passedPSM = readIdpDB(idpDB_file, searchEngineScore)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
80 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
81 else if (length(pepXmlTab_file) > 0)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
82 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
83 if (length(searchEngineScore) == 0)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
84 stop("searchEngineScore parameter must be specified when reading pepXmlTab PSMs, e.g. 'mvh'")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
85 passedPSM = readPepXmlTab(pepXmlTab_file, searchEngineScore)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
86 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
87 else if (length(peptideShakerPsmReport_file) > 0)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
88 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
89 if (length(searchEngineScore) > 0)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
90 warning("searchEngineScore parameter is ignored when reading PeptideShaker PSM report")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
91 passedPSM = readPeptideShakerPsmReport(peptideShakerPsmReport_file)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
92 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
93
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
94 load(exon_anno_file)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
95 load(proteinseq_file)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
96 load(procodingseq_file)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
97
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
98 if (length(variantAnnotation_file) > 0)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
99 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
100 load(variantAnnotation_file) # variantAnnotation list, with members snvprocoding/snvproseq and indelprocoding/indelproseq
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
101
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
102 varprocoding = unique(rbind(variantAnnotation$snvprocoding, variantAnnotation$indelprocoding))
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
103 varproseq = unique(rbind(variantAnnotation$snvproseq, variantAnnotation$indelproseq))
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
104 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
105 else
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
106 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
107 varprocoding = NULL
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
108 varproseq = NULL
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
109 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
110
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
111 # add proBAMr program key
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
112 outputHeader = c(outputHeader, paste0("@PG\tID:proBAMr\tVN:", packageVersion("proBAMr")))
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
113
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
114 # first write header lines to the output SAM
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
115 writeLines(outputHeader, "output.sam")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
116
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
117 # then write the PSM "reads"
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
118 PSMtab2SAM(passedPSM, exon,
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
119 proteinseq, procodingseq,
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
120 varproseq, varprocoding,
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
121 outfile = "output.sam",
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
122 show_progress = FALSE)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
123
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
124 invisible(NULL)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
125 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
126
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
127 params <- list()
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
128 for(param in names(opt))
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
129 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
130 if (!param == "help")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
131 params[param] <- opt[param]
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
132 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
133
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
134 setClass("GalaxyRemoteError", contains="character")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
135 wrappedFunction <- function(f)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
136 {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
137 tryCatch(do.call(f, params),
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
138 error=function(e) new("GalaxyRemoteError", conditionMessage(e)))
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
139 }
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
140
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
141
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
142 suppressPackageStartupMessages(library(RGalaxy))
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
143 do.call(psm2sam, params)
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
144
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
145 ## end warning handler
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
146 }, warning = function(w) {
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
147 cat(paste("Warning:", conditionMessage(w), "\n"))
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
148 invokeRestart("muffleWarning")
90ecb65017a0 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/bumbershoot/psm2sam commit 9910ed076e4b8a3f083351b89fa861d0a4a93beb
galaxyp
parents:
diff changeset
149 })