Skip to content

Commit

Permalink
added tmpdir in readscan
Browse files Browse the repository at this point in the history
added centroidStream
  • Loading branch information
cpanse committed Aug 20, 2020
1 parent 8098407 commit 71ba35a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
8 changes: 4 additions & 4 deletions R/rawDiag.R
Original file line number Diff line number Diff line change
Expand Up @@ -487,16 +487,16 @@ plot.XICs <- function(x, y, method='ggplot', ...){
#' op <- par(mfrow = c(3, 3))
#' lapply(S, function(x){ plot.peaklist(x, sub=x$scanType) })
#'
readScans <- function(rawfile, scans){
readScans <- function(rawfile, scans, tmpdir=tempdir()){
mono <- if(Sys.info()['sysname'] %in% c("Darwin", "Linux")) TRUE else FALSE
exe <- file.path(path.package(package = "rawDiag"), "exec", "fgcz_raw.exe")

# TODO(cp): replace asap we have an R .Net binding similar as Rcpp
# the current solution writting and reading from a file is pain-of-the-art
# https://github.com/fgcz/rawDiag/issues/46
tfi <- tempfile()
tfo <- tempfile()
tfstdout <- tempfile()
tfi <- tempfile(tmpdir=tmpdir)
tfo <- tempfile(tmpdir=tmpdir)
tfstdout <- tempfile(tmpdir=tmpdir)

cat(scans, file = tfi, sep="\n")

Expand Down
Binary file modified exec/fgcz_raw.exe
Binary file not shown.
7 changes: 6 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
CSC=mcs
CSCFLAGS=-lib:../exec /r:ThermoFisher.CommonCore.Data.dll /r:ThermoFisher.CommonCore.MassPrecisionEstimator.dll /r:ThermoFisher.CommonCore.RawFileReader.dll /optimize /platform:anycpu


# $(CSC) /target:library rawDiag.cs /out:../exec/rawDiag.dll $(CSCFLAGS)
exe:
$(CSC) /out:../exec/fgcz_raw.exe fgcz_raw.cs $(CSCFLAGS)

dll:
$(CSC) /target:library rawDiag.cs /out:../exec/rawDiag.dll $(CSCFLAGS)
$(CSC) /target:library ../src/fgcz_raw.cs /out:../exec/fgcz_raw.dll $(CSCFLAGS)
14 changes: 13 additions & 1 deletion src/fgcz_raw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ public static void PrintScanAsRcode(this IRawDataPlus rawFile, string filename,
monoisotopicMz = "NA";
}

var scan = Scan.FromFile(rawFile, scanNumber);

if (scanStatistics.IsCentroidScan && centroidStream.Length > 0)
{
Expand All @@ -375,6 +376,12 @@ public static void PrintScanAsRcode(this IRawDataPlus rawFile, string filename,
file.WriteLine("\tpepmass = c({0}, {1}),", pepmass, basepeakIntensity);
file.WriteLine("\tcentroidStream = TRUE,");

file.WriteLine("\tHasCentroidStream = '{0}, Length={1}',", scan.HasCentroidStream, scan.CentroidScan.Length);
if(scan.HasCentroidStream){
file.WriteLine("\tcentroid.mZ = c(" + string.Join(",", scan.CentroidScan.Masses.ToArray()) + "),");
file.WriteLine("\tcentroid.intensity = c(" + string.Join(",", scan.CentroidScan.Intensities.ToArray()) + "),");
}

file.WriteLine("\ttitle = \"File: {0}; SpectrumID: {1}; scans: {2}\",",
Path.GetFileName(rawFile.FileName),
null,
Expand All @@ -389,7 +396,6 @@ public static void PrintScanAsRcode(this IRawDataPlus rawFile, string filename,
}
else
{
var scan = Scan.FromFile(rawFile, scanNumber);

file.WriteLine("e$PeakList[[{0}]] <- list(", count++);
file.WriteLine("\tscan = {0},", scanNumber);
Expand All @@ -399,6 +405,12 @@ public static void PrintScanAsRcode(this IRawDataPlus rawFile, string filename,
file.WriteLine("\tpepmass = c({0}, {1}),", pepmass, basepeakIntensity);
file.WriteLine("\tcentroidStream = FALSE,");

file.WriteLine("\tHasCentroidStream = '{0}, Length={1}',", scan.HasCentroidStream, scan.CentroidScan.Length);
if(scan.HasCentroidStream){
file.WriteLine("\tcentroid.mZ = c(" + string.Join(",", scan.CentroidScan.Masses.ToArray()) + "),");
file.WriteLine("\tcentroid.intensity = c(" + string.Join(",", scan.CentroidScan.Intensities.ToArray()) + "),");
}

file.WriteLine("\ttitle = \"File: {0}; SpectrumID: {1}; scans: {2}\",",
Path.GetFileName(rawFile.FileName),
null,
Expand Down

0 comments on commit 71ba35a

Please sign in to comment.