This example uses code from the example Batch Processing of Spectra Using Sequential and Parallel Computing on the Matlab Documentation web site for the Bioinformatics Toolbox. Please see that web page for additional information about what is actually being done.

The data needed for this example were downloaded from the Clinical Proteomics Program Biomarker Profiling, Discovery and Identification web site to the Flux cluster and placed in the folder /scratch/data/examples/matlab/ovarian/OvarianCD_PostQAQC.

The original example from the MathWorks web site sets up the parallel processing as part of a single function. Our purpose here is to show how to wrap a function that is not parallel into a looping structure, so we present here a modified version of the code that processes a single file.

Processing a single file

Here is the function code, which can be found on Flux as /scratch/data/examples/matlab/ovarian/spec.m if you wish to copy it.

function [ Y ] = spec(file, index)

% Open and read file
fid = fopen(file,'r');
ftext = textscan(fid, '%f%f');

% Assign values to vectors
signal = ftext{1};
intensity = ftext{2};

% Resample the signal to 15000 points between 2000 and 11900
mzout = (sqrt(2000)+(0:(15000-1))' * diff(sqrt([2000,11900]))/15000).^2;
[mz,YR] = msresample(signal, intensity, mzout);

% Align the spectrograms to two good reference peaks
P = [3883.766 7766.166];
YA = msalign(mz, YR, P, 'WIDTH', 2);

% Estimate and adjust the background
YB = msbackadj(mz, YA, 'STEP', 50, 'WINDOW', 50);

% Reduce the noise using a nonparametric filter
Y(:,1) = mslowess(mz, YB, 'SPAN', 5);

The spec function takes a file name and an index as arguments, as in

spec('/scratch/data/examples/matlab/ovarian/OvarianCD_PostQAQC/Cancer/daf-0601.txt', 1);

or, as we will do in the examples, with the filename in a variable

spec(filename, 1);