Skip to content

Commit

Permalink
comments/TODOs on chromatographic mass interval #1
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanse committed Oct 23, 2020
1 parent 592aa2f commit e1580fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
6 changes: 4 additions & 2 deletions R/rawR.R
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ readSpectrum <- function(rawfile, scan = NULL, tmpdir=tempdir(), validate=FALSE)
#' # Example 1: not meaning full but proof-of-concept
#' (rawfile <- file.path(path.package(package = 'rawR'), 'extdata', 'sample.raw'))
#'
#' X <- readChromatogram(rawfile, mass=c(669.8381, 726.8357), tol=1000)
#' C <- readChromatogram(rawfile, mass=c(669.8381, 726.8357), tol=1000)
#'
#' # Example 2: extract iRT peptides
#' iRTpeptide <- c("LGGNEQVTR", "YILAGVENSK", "GTFIIDPGGVIR", "GTFIIDPAAVIR",
Expand Down Expand Up @@ -432,13 +432,14 @@ readChromatogram <- function(rawfile,
#message(length(rv))
rv <- lapply(rv,
function(x){
x$type <- type
x$filename <- rawfile
x$tol <- tol
x$filter <- filter
# x$times.max <- x$times[which.max(x$intensities)][1]
class(x) <- c(class(x), 'rawRchromatogram');
x})
class(rv) <- 'rawRchromatogramSet'

}else{
if (mono){
rvs <- system2("mono", args = c(shQuote(exe), shQuote(rawfile), "chromatogram", shQuote(filter)), stdout=tfstdout)
Expand All @@ -448,6 +449,7 @@ readChromatogram <- function(rawfile,
rv <- read.csv(tfstdout, header = TRUE, comment.char = "#")
}
unlink(c(tfi, tfo, tfstdout))
class(rv) <- 'rawRchromatogramSet'
rv
}

Expand Down
19 changes: 15 additions & 4 deletions src/rawR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -609,17 +609,28 @@ private static void Main(string[] args)
/// <param name="outputData">
/// The output data flag.
/// </param>
/// <param name="filter">
/// The chromatic filter flag.
/// </param>
private static void GetChromatogram(IRawDataPlus rawFile, int startScan, int endScan, bool outputData, string filter = "ms")
{
if (IsValidFilter(rawFile, filter) == false){
Console.WriteLine("# '{0}' is not a valid filter string.", filter);
return;
}

// TODO([email protected]): check mass interval for chromatograms and its dep for diff MS detector types
// TODO([email protected]): return mass intervals to the R enviroment
// Define the settings for getting the Base Peak chromatogram
ChromatogramTraceSettings settingsTIC = new ChromatogramTraceSettings(TraceType.TIC){Filter=filter};
ChromatogramTraceSettings settingsBasePeak = new ChromatogramTraceSettings(TraceType.BasePeak){Filter=filter};
ChromatogramTraceSettings settingsMassRange = new ChromatogramTraceSettings(TraceType.MassRange){Filter=filter};
ChromatogramTraceSettings settingsBasePeak = new ChromatogramTraceSettings(TraceType.BasePeak){
Filter=filter,
MassRanges = new[] {ThermoFisher.CommonCore.Data.Business.Range.Create(100, 1805)}
};
ChromatogramTraceSettings settingsMassRange = new ChromatogramTraceSettings(TraceType.MassRange){
Filter=filter,
MassRanges = new[] {ThermoFisher.CommonCore.Data.Business.Range.Create(50, 2000000)}
};

// Get the chromatogram from the RAW file.
var dataTIC = rawFile.GetChromatogramData(new IChromatogramSettings[] {settingsTIC}, startScan, endScan);
Expand All @@ -638,12 +649,12 @@ private static void GetChromatogram(IRawDataPlus rawFile, int startScan, int end
Console.WriteLine("# Base Peak chromatogram ({0} points)", traceBasePeak[0].Length);
Console.WriteLine("# MassRange chromatogram ({0} points)", traceMassRange[0].Length);

Console.WriteLine("scan,rt,intensity.BasePeak,intensity.TIC,intensity.MassRange");
Console.WriteLine("rt,intensity.BasePeak,intensity.TIC,intensity.MassRange");
if (outputData)
{
for (int i = 0; i < traceBasePeak[0].Length; i++)
{
Console.WriteLine("{0},{1:F3},{2:F0},{3:F0},{4:F0}", i, traceBasePeak[0].Times[i], traceBasePeak[0].Intensities[i], traceTIC[0].Intensities[i], traceMassRange[0].Intensities[i]);
Console.WriteLine("{1:F3},{2:F0},{3:F0},{4:F0}", i, traceBasePeak[0].Times[i], traceBasePeak[0].Intensities[i], traceTIC[0].Intensities[i], traceMassRange[0].Intensities[i]);
}
}
}
Expand Down

0 comments on commit e1580fb

Please sign in to comment.