本文整理汇总了C#中SrmDocument.ChangeMeasuredResults方法的典型用法代码示例。如果您正苦于以下问题:C# SrmDocument.ChangeMeasuredResults方法的具体用法?C# SrmDocument.ChangeMeasuredResults怎么用?C# SrmDocument.ChangeMeasuredResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SrmDocument
的用法示例。
在下文中一共展示了SrmDocument.ChangeMeasuredResults方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportResults
/// <summary>
/// This function will add the given replicate, from dataFile, to the given document. If the replicate
/// does not exist, it will be added. If it does exist, it will be appended to.
/// </summary>
public static SrmDocument ImportResults(SrmDocument doc, string docPath, string replicate, MsDataFileUri dataFile,
OptimizableRegression optimize, IProgressMonitor progressMonitor, out ProgressStatus status)
{
using (var docContainer = new ResultsMemoryDocumentContainer(null, docPath) {ProgressMonitor = progressMonitor})
{
// Make sure library loading happens, which may not happen, if the doc
// parameter is used as the baseline document.
docContainer.SetDocument(doc, null);
SrmDocument docAdded;
do
{
doc = docContainer.Document;
var listChromatograms = new List<ChromatogramSet>();
if (doc.Settings.HasResults)
listChromatograms.AddRange(doc.Settings.MeasuredResults.Chromatograms);
int indexChrom = listChromatograms.IndexOf(chrom => chrom.Name.Equals(replicate));
if (indexChrom != -1)
{
var chromatogram = listChromatograms[indexChrom];
var paths = chromatogram.MSDataFilePaths;
var listFilePaths = paths.ToList();
listFilePaths.Add(dataFile);
listChromatograms[indexChrom] = chromatogram.ChangeMSDataFilePaths(listFilePaths);
}
else
{
listChromatograms.Add(new ChromatogramSet(replicate, new[] {dataFile.Normalize()},
Annotations.EMPTY, optimize));
}
var results = doc.Settings.HasResults
? doc.Settings.MeasuredResults.ChangeChromatograms(listChromatograms)
: new MeasuredResults(listChromatograms, doc.Settings.IsResultsJoiningDisabled);
docAdded = doc.ChangeMeasuredResults(results);
}
while (!docContainer.SetDocument(docAdded, doc, true));
status = docContainer.LastProgress;
return docContainer.Document;
}
}
示例2: ChangeStandardConcentrationCount
private SrmDocument ChangeStandardConcentrationCount(SrmDocument srmDocument, int pointCount)
{
var measuredResults = srmDocument.Settings.MeasuredResults;
var standardConcentrations = measuredResults.Chromatograms
.Where(chrom => Equals(chrom.SampleType, SampleType.STANDARD))
.Select(chrom => chrom.AnalyteConcentration)
.OfType<double>()
.Distinct()
.ToArray();
Array.Sort(standardConcentrations);
Array.Reverse(standardConcentrations);
var topConcentrations = new HashSet<double>(standardConcentrations.Take(pointCount));
var newChromatograms = measuredResults.Chromatograms.ToArray();
for (int i = 0; i < newChromatograms.Length; i++)
{
var chrom = newChromatograms[i];
if (Equals(SampleType.STANDARD, chrom.SampleType) && chrom.AnalyteConcentration.HasValue)
{
if (!topConcentrations.Contains(chrom.AnalyteConcentration.Value))
{
chrom = chrom.ChangeSampleType(SampleType.UNKNOWN);
}
}
newChromatograms[i] = chrom;
}
measuredResults = measuredResults.ChangeChromatograms(newChromatograms);
return srmDocument.ChangeMeasuredResults(measuredResults);
}
示例3: ImportResults
private SrmDocument ImportResults(SrmDocument doc, string nameResult, IEnumerable<MsDataFileUri> dataSources,
OptimizableRegression optimizationFunction)
{
var results = doc.Settings.MeasuredResults;
var chrom = GetChromatogramByName(nameResult, results);
if (chrom == null)
{
// If the chromatogram, is not in the current set, then delete the cache
// file to make sure it is not on disk before starting.
FileEx.SafeDelete(ChromatogramCache.FinalPathForName(DocumentFilePath, nameResult), true);
chrom = new ChromatogramSet(nameResult, dataSources, Annotations.EMPTY, optimizationFunction);
if (results == null)
results = new MeasuredResults(new[] {chrom});
else
{
// Add the new result to the end.
var listChrom = new List<ChromatogramSet>(results.Chromatograms) {chrom};
results = results.ChangeChromatograms(listChrom.ToArray());
}
}
else
{
// Append to an existing chromatogram set
var dataFilePaths = new List<MsDataFileUri>(chrom.MSDataFilePaths);
foreach (var sourcePath in dataSources)
{
if (!dataFilePaths.Contains(sourcePath))
dataFilePaths.Add(sourcePath);
}
// If no new paths added, just return without changing.
if (dataFilePaths.Count == chrom.FileCount)
return doc;
int replaceIndex = results.Chromatograms.IndexOf(chrom);
var arrayChrom = results.Chromatograms.ToArray();
arrayChrom[replaceIndex] = chrom.ChangeMSDataFilePaths(dataFilePaths);
results = results.ChangeChromatograms(arrayChrom);
}
if (results != null && Program.DisableJoining)
results = results.ChangeIsJoiningDisabled(true);
return doc.ChangeMeasuredResults(results);
}
示例4: FilterFiles
/// <summary>
/// Filters document chromatograms for all but a selected set of files.
/// </summary>
private SrmDocument FilterFiles(SrmDocument doc, Func<ChromFileInfo, bool> selectFilesToKeepFunc)
{
if (doc.Settings.MeasuredResults == null)
return doc;
var measuredResultsNew = doc.Settings.MeasuredResults.FilterFiles(selectFilesToKeepFunc);
// If nothing changed, don't create a new document instance
if (measuredResultsNew != null &&
ArrayUtil.ReferencesEqual(measuredResultsNew.Chromatograms, doc.Settings.MeasuredResults.Chromatograms))
{
return doc;
}
return doc.ChangeMeasuredResults(measuredResultsNew);
}