-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4078c9a
commit 521639a
Showing
5 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#Read MGF | ||
Construct_SpectraDF <- function(MGF_path) | ||
{ | ||
MGF <- readLines(MGF_path) | ||
|
||
BEGINIONS <- "BEGIN IONS" | ||
ENDIONS <- "END IONS" | ||
|
||
Begin.index <- which(MGF %in% BEGINIONS) | ||
END.index <- which(MGF %in% ENDIONS) | ||
|
||
NumberofSpectra <- length(Begin.index) | ||
message(paste("Number of spectra identified in file", NumberofSpectra)) | ||
|
||
IndvidualSpectraDF <- c() | ||
for (i in 1:NumberofSpectra) | ||
{ | ||
Spectra <- MGF[Begin.index[i]:END.index[i]] | ||
#Get locus of spectra | ||
SpectraID <- gsub(".*=(.+) .*", "\\1", Spectra[2]) | ||
IndvidualSpectraDF[i] <- paste(Spectra, collapse = "#") #replace # with \n when writing the file | ||
names(IndvidualSpectraDF)[i] <- SpectraID | ||
} | ||
IndvidualSpectraDF <- data.frame(IndvidualSpectraDF) | ||
|
||
return(IndvidualSpectraDF) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
if (!requireNamespace("BiocManager", quietly = TRUE)) | ||
install.packages("BiocManager") | ||
|
||
#Install rTandem | ||
BiocManager::install("rTANDEM") | ||
library(rTANDEM) | ||
#Install shinyTandem | ||
BiocManager::install("shinyTANDEM") | ||
library(shinyTANDEM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
library(rTANDEM) | ||
source("ConstructSpectra.R") | ||
source("TandemSearch.R") | ||
source("RemoveIdentification.R") | ||
|
||
MGF.map <- Construct_SpectraDF(MGFPATH) | ||
#Apply tandem search | ||
Results <- TandemSearch() | ||
#Remove identified spectra | ||
Filtered.MGF <- RemoveIdentification(MGF.map, Results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
RemoveIdentification <- function(SpectraDF, Search_results) | ||
{ | ||
IdentifiedSpectra <- Search_results@spectra | ||
rownames(IdentifiedSpectra) <- IdentifiedSpectra$id | ||
#Remove identified spectra from MGF | ||
SpectraDF <- SpectraDF[-rownames(IdentifiedSpectra),] | ||
return(SpectraDF) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
TandemSearch <- function(taxon = 'yeast', format = 'peptide', | ||
FastaPath = system.file("extdata/fasta/scd.fasta.pro", package="rTANDEM"), | ||
MGFPath = system.file("extdata/200217-2-9-.mgf", package="rTANDEM"), | ||
InputPara = system.file("extdata/default_input.xml", package="rTANDEM"), | ||
Output_Path = paste(getwd(), "output.xml", sep="/")) | ||
{ | ||
taxonomy <- rTTaxo(taxon = taxon, format = format, URL = FastaPath) | ||
|
||
param <- rTParam() | ||
param <- setParamValue(param, 'protein', 'taxon', value="yeast") | ||
param <- setParamValue(param, 'list path', 'taxonomy information', taxonomy) | ||
param <- setParamValue(param, 'list path', 'default parameters', | ||
value=InputPara) | ||
param <- setParamValue(param, 'spectrum', 'path', | ||
value=MGFPath) | ||
param <- setParamValue(param, 'output', 'xsl path', | ||
value=system.file("extdata/tandem-input-style.xsl", package="rTANDEM")) | ||
param <- setParamValue(param, 'output', 'path', | ||
value=Output_Path) | ||
|
||
result.path <- tandem(param) | ||
|
||
result.R <- GetResultsFromXML(result.path) | ||
return(result.R) | ||
} |