Example #1
0
        protected internal override LibraryKeyProto ToLibraryKeyProto()
        {
            var libraryKeyProto = new LibraryKeyProto()
            {
                KeyType = LibraryKeyProto.Types.KeyType.Crosslink,
                Charge  = Charge
            };

            foreach (var peptideLibraryKey in PeptideLibraryKeys)
            {
                libraryKeyProto.CrosslinkedSequences.Add(peptideLibraryKey.ModifiedSequence);
            }
            foreach (var crosslinker in Crosslinks)
            {
                var crosslinkProto = new LibraryKeyProto.Types.Crosslinker()
                {
                    Name = crosslinker.Name
                };
                foreach (var positions in crosslinker.Positions)
                {
                    var positionsProto = new LibraryKeyProto.Types.Positions();
                    positionsProto.Position.AddRange(positions);
                    crosslinkProto.Positions.Add(positionsProto);
                }
                libraryKeyProto.Crosslinkers.Add(crosslinkProto);
            }
            return(libraryKeyProto);
        }
Example #2
0
        public static LibraryKey Read(ValueCache valueCache, Stream stream)
        {
            int length = PrimitiveArrays.ReadOneValue <int>(stream);

            byte[] buffer = new byte[length];
            stream.Read(buffer, 0, length);
            var proto = new LibraryKeyProto();

            proto.MergeFrom(new CodedInputStream(buffer));
            switch (proto.KeyType)
            {
            case LibraryKeyProto.Types.KeyType.Peptide:
                return(new PeptideLibraryKey(proto.ModifiedSequence, proto.Charge).ValueFromCache(valueCache));

            case LibraryKeyProto.Types.KeyType.PrecursorMz:
                return(new PrecursorLibraryKey(proto));

            case LibraryKeyProto.Types.KeyType.SmallMolecule:
                return(new MoleculeLibraryKey(valueCache, proto));

            case LibraryKeyProto.Types.KeyType.Crosslink:
                return(new CrosslinkLibraryKey(proto));
            }
            return(null);
        }
Example #3
0
 public PrecursorLibraryKey(LibraryKeyProto libraryKeyProto)
 {
     Mz = libraryKeyProto.PrecursorMz;
     if (0 != libraryKeyProto.RetentionTime)
     {
         RetentionTime = libraryKeyProto.RetentionTime;
     }
 }
Example #4
0
 public CrosslinkLibraryKey(LibraryKeyProto libraryKeyProto)
 {
     PeptideLibraryKeys = ImmutableList.ValueOf(libraryKeyProto.CrosslinkedSequences
                                                .Select(sequence => new PeptideLibraryKey(sequence, 0)));
     Crosslinks = ImmutableList.ValueOf(libraryKeyProto.Crosslinkers.Select(crosslinkProto =>
                                                                            new Crosslink(crosslinkProto.Name, crosslinkProto.Positions.Select(pos => pos.Position.ToArray()))));
     Charge = libraryKeyProto.Charge;
 }
Example #5
0
 internal MoleculeLibraryKey(ValueCache valueCache, LibraryKeyProto libraryKeyProto) : this(
         valueCache,
         SmallMoleculeLibraryAttributes.Create(
             valueCache.CacheValue(libraryKeyProto.MoleculeName),
             valueCache.CacheValue(libraryKeyProto.ChemicalFormula),
             libraryKeyProto.InChiKey, libraryKeyProto.OtherKeys),
         Adduct.FromString(libraryKeyProto.Adduct, Adduct.ADDUCT_TYPE.non_proteomic, null))
 {
 }