Esempio n. 1
0
        public static SrmDocument ApplyRules(SrmDocument document, HashSet <MsDataFileUri> dataFiles, out CommonException <RuleError> error)
        {
            error = null;
            if (!document.Settings.DataSettings.MetadataRuleSets.Any())
            {
                return(document);
            }
            try
            {
                var dataSchema = SkylineDataSchema.MemoryDataSchema(document, DataSchemaLocalizer.INVARIANT);
                dataSchema.BeginBatchModifyDocument();
                foreach (var ruleSet in document.Settings.DataSettings.MetadataRuleSets)
                {
                    var metadataExtractor = new MetadataExtractor(dataSchema, typeof(ResultFile));
                    metadataExtractor.ApplyRule(ruleSet, dataFiles);
                }

                dataSchema.CommitBatchModifyDocument(string.Empty, null);
                return(dataSchema.Document);
            }
            catch (CommonException <RuleError> ex)
            {
                error = ex;
                return(document);
            }
        }
Esempio n. 2
0
 public static ExportAnnotationSettings AllAnnotations(SrmDocument document)
 {
     return(EMPTY.ChangeElementTypes(ElementHandler
                                     .GetElementHandlers(SkylineDataSchema.MemoryDataSchema(document, DataSchemaLocalizer.INVARIANT))
                                     .Select(handler => handler.Name))
            .ChangeAnnotationNames(
                document.Settings.DataSettings.AnnotationDefs.Select(annotationDef => annotationDef.Name))
            .ChangePropertyNames(new[] { @"Note" }));
 }
Esempio n. 3
0
        public DocumentAnnotationUpdater(SrmDocument document, IProgressMonitor progressMonitor)
        {
            SkylineDataSchema   = SkylineDataSchema.MemoryDataSchema(document, DataSchemaLocalizer.INVARIANT);
            _annotationUpdaters = new Dictionary <AnnotationDef.AnnotationTarget, AnnotationUpdater>();
            var calculatedAnnotations = document.Settings.DataSettings.AnnotationDefs
                                        .Where(def => null != def.Expression).ToArray();

            foreach (AnnotationDef.AnnotationTarget target in Enum.GetValues(typeof(AnnotationDef.AnnotationTarget)))
            {
                var annotations = ImmutableList.ValueOf(calculatedAnnotations.Where(def => def.AnnotationTargets.Contains(target)));
                if (annotations.Count == 0)
                {
                    continue;
                }
                _annotationUpdaters[target] = new AnnotationUpdater(annotations);
            }

            AnnotationUpdater transitionResultAnnotationUpdater;

            if (_annotationUpdaters.TryGetValue(AnnotationDef.AnnotationTarget.transition_result,
                                                out transitionResultAnnotationUpdater))
            {
                _transitionResultUpdater = new TransitionResultUpdater
                {
                    AnnotationUpdater = transitionResultAnnotationUpdater,
                    SkylineDataSchema = SkylineDataSchema
                };
            }

            AnnotationUpdater precursorResultAnnotationUpdater;

            if (_annotationUpdaters.TryGetValue(AnnotationDef.AnnotationTarget.precursor_result,
                                                out precursorResultAnnotationUpdater))
            {
                _precursorResultUpdater = new PrecursorResultUpdater
                {
                    AnnotationUpdater = precursorResultAnnotationUpdater,
                    SkylineDataSchema = SkylineDataSchema
                };
            }

            RecurseTransitions = _annotationUpdaters.ContainsKey(AnnotationDef.AnnotationTarget.transition) ||
                                 transitionResultAnnotationUpdater != null;
            RecursePrecursors =
                RecurseTransitions || _annotationUpdaters.ContainsKey(AnnotationDef.AnnotationTarget.precursor) ||
                precursorResultAnnotationUpdater != null;
            RecurseMolecules =
                RecursePrecursors || _annotationUpdaters.ContainsKey(AnnotationDef.AnnotationTarget.peptide);
        }
Esempio n. 4
0
 public DocumentAnnotations(SrmDocument document) : this(SkylineDataSchema.MemoryDataSchema(document, SkylineDataSchema.GetLocalizedSchemaLocalizer()))
 {
 }
Esempio n. 5
0
 public DocumentAnnotations(SrmDocument document) : this(SkylineDataSchema.MemoryDataSchema(document, DataSchemaLocalizer.INVARIANT))
 {
 }