Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MohmedSoudy authored Jul 17, 2021
1 parent 4078c9a commit 521639a
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ConstructSpectra.R
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)
}
9 changes: 9 additions & 0 deletions Installtion.R
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)
10 changes: 10 additions & 0 deletions Main.R
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)
9 changes: 9 additions & 0 deletions RemoveIdentification.R
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)
}

25 changes: 25 additions & 0 deletions TandemSearch.R
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)
}

0 comments on commit 521639a

Please sign in to comment.