예제 #1
0
        public PeptideDocNode GetModifiedNode(LibKey key, SrmSettings settings, SrmSettingsDiff diff)
        {
            var     smallMoleculeKey = key.LibraryKey as MoleculeLibraryKey;
            var     peptideKey       = key.LibraryKey as PeptideLibraryKey;
            Peptide peptide;

            if (smallMoleculeKey != null)
            {
                peptide = new Peptide(CustomMolecule.FromSmallMoleculeLibraryAttributes(smallMoleculeKey.SmallMoleculeLibraryAttributes));
            }
            else if (peptideKey != null)
            {
                peptide = new Peptide(null, peptideKey.UnmodifiedSequence, null, null,
                                      settings.PeptideSettings.Enzyme.CountCleavagePoints(peptideKey.UnmodifiedSequence));
            }
            else
            {
                return(null);
            }
            // First try and create the match from the settings created to match the library explorer.
            Settings = HasMatches
                ? settings.ChangePeptideModifications(mods => MatcherPepMods)
                : settings;
            TransitionGroupDocNode nodeGroup;
            var nodePep = CreateDocNodeFromSettings(key, peptide, diff, out nodeGroup);

            if (nodePep != null)
            {
                if (diff == null)
                {
                    nodePep = (PeptideDocNode)nodePep.ChangeAutoManageChildren(false);
                }
                else
                {
                    // Keep only the matching transition group, so that modifications
                    // will be highlighted differently for light and heavy forms.
                    // Only performed when getting peptides for display in the explorer.
                    nodePep = (PeptideDocNode)nodePep.ChangeChildrenChecked(
                        new DocNode[] { nodeGroup });
                }
                return(nodePep);
            }
            else if (Matches == null)
            {
                return(null);
            }
            bool hasHeavy;

            // Create explicit mods from the found matches.
            nodePep = CreateDocNodeFromMatches(new PeptideDocNode(peptide),
                                               EnumerateSequenceInfos(key.LibraryKey as PeptideLibraryKey, true), false, out hasHeavy);

            if (nodePep == null)
            {
                return(null);
            }

            // Call change settings with the matched modification settings to enumerate the children.
            nodePep = nodePep.ChangeSettings(settings.ChangePeptideModifications(mods =>
                                                                                 !HasMatches ? settings.PeptideSettings.Modifications : MatcherPepMods), diff ?? SrmSettingsDiff.ALL);
            if (nodePep.Children.Count == 0)
            {
                return(null);
            }
            // Select the correct child, only for use with the library explorer.
            if (diff != null && nodePep.Children.Count > 1)
            {
                nodePep =
                    (PeptideDocNode)
                    nodePep.ChangeChildrenChecked(new List <DocNode> {
                    nodePep.Children[hasHeavy ? 1 : 0]
                });
            }
            if (diff == null)
            {
                nodePep = (PeptideDocNode)nodePep.ChangeAutoManageChildren(false);
            }
            return(nodePep);
        }
예제 #2
0
파일: Peptide.cs 프로젝트: rfellers/pwiz
 public Target(SmallMoleculeLibraryAttributes molecule)
 {
     Molecule = CustomMolecule.FromSmallMoleculeLibraryAttributes(molecule);
 }